Beispiel #1
0
        /// <summary>
        /// Starts the test
        /// </summary>
        public void TestStart()
        {
            if (IsTestInProgress)
            {
                return;
            }

            if (CurrentTest == null || TestStartupArgs == null || ClientsInTest == null || ClientsInTest.Count == 0)
            {
                throw new Exception("Not ready to start test");
            }

            // Send package indicating the start of the test
            var TestStartPackage = DataPackage.StartTestPackage(TestStartupArgs);

            foreach (var client in ClientsInTest)
            {
                // Send start command with args
                IoCServer.Network.Send(client, TestStartPackage);

                // Reset the client for new test
                client.ResetForNewTest(CurrentTest.Questions.Count);
            }

            IsTestInProgress = true;

            TimeLeft = CurrentTest.Info.Duration;

            // Start cutdown
            mTestTimer.Start();
            OnTimerUpdated.Invoke();
        }
Beispiel #2
0
        protected IEnumerator CountTime()
        {
            do
            {
                yield return(null);

                currentTime += Time.deltaTime;
                OnTimerUpdated?.Invoke(currentTime);
            } while (Active);
        }
Beispiel #3
0
        /// <summary>
        /// Fired every time timer's cycle elapses
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HandleTimer(object sender, ElapsedEventArgs e)
        {
            TimeLeft = TimeLeft.Subtract(new TimeSpan(0, 0, 1));

            OnTimerUpdated.Invoke();

            if (TimeLeft.Equals(TimeSpan.Zero))
            {
                TimesUp();
            }
        }
Beispiel #4
0
 /// <summary>
 /// Stops the timer
 /// </summary>
 private void StopTimer()
 {
     mTestTimer.Start();
     OnTimerUpdated.Invoke();
 }
Beispiel #5
0
 private void SetTimeLeft(float timeLeft)
 {
     this.timeLeft = Math.Max(0, timeLeft);
     OnTimerUpdated?.Invoke(this);
 }