Esempio n. 1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                timer1.Stop();

                //TODO: QuestionsPerSession
                //QuestionForm qf = new QuestionForm(controller.GetTranslationsForSession(SettingsManager.Current.QuestionPerSession);

                QuestionSession session = new QuestionSession(controller.GetTranslationsForSession(2));
                QuestionForm    qf      = new QuestionForm(session);

                qf.FormClosed += (d, a) => { controller.Save(); timer1.Start(); };
                qf.Show();
                qf.Activate();
            }
        }
Esempio n. 2
0
        public IActionResult AnswerCurrentQuestion(Question question)
        {
            int             questionIndex     = questionContainer.GetAllQuestions().FindIndex(a => a.ID == question.ID);
            int             nextQuestionIndex = questionIndex + 1;
            List <Question> questionList      = new List <Question>(questionContainer.GetAllQuestions());

            if (nextQuestionIndex > (questionList.Count - 1))
            {
                QuestionSession questionSession = new QuestionSession();
                questionSession.DateFinished = DateTime.Now;
                questionSessionContainer.AddQuestionSession(questionSession);
                return(RedirectToAction("Overview"));
            }
            else
            {
                Question nextQuestion = questionList.ElementAt(nextQuestionIndex);
                questionContainer.AnswerQuestion(question);
                return(RedirectToAction("AnswerQuestion", new { id = nextQuestion.ID }));
            }
        }
Esempio n. 3
0
        public void VerifyInitializingQuestionSession()
        {
            // Arrange
            QuestionSessionDTO questionSessionDTO = new QuestionSessionDTO();

            questionSessionDTO.ID            = 6;
            questionSessionDTO.AmountCorrect = 0;
            questionSessionDTO.AmountWrong   = 0;
            questionSessionDTO.UserID        = 2;
            questionSessionDTO.DateFinished  = DateTime.Today;

            // Act
            QuestionSession questionSession = new QuestionSession(questionSessionDTO);

            // Assert
            Assert.IsNotNull(questionSessionDTO);
            Assert.IsNotNull(questionSession);
            Assert.AreEqual(questionSession.ID, questionSessionDTO.ID);
            Assert.AreEqual(questionSession.UserID, questionSessionDTO.UserID);
            Assert.AreEqual(questionSession.AmountCorrect, 0);
            Assert.AreEqual(questionSession.AmountWrong, 0);
            Assert.AreEqual(questionSession.DateFinished, questionSessionDTO.DateFinished);
        }