private void buttonRetakeTest_Click(object sender, EventArgs e) { TestController testController = new TestController(); List <QuestionModel> questions = testController.LoadQuestions(test); CurrentQuestionWindow currentQuestionWindow = new CurrentQuestionWindow(user, test, questions, 0); this.Close(); currentQuestionWindow.Show(); }
private void buttonTakeTest_Click(object sender, EventArgs e) { if (selectedTest != null) { List <QuestionModel> questions = testController.LoadQuestions(selectedTest); CurrentQuestionWindow currentQuestionWindow = new CurrentQuestionWindow(user, selectedTest, questions, 0); this.Close(); currentQuestionWindow.Show(); } else { MessageBox.Show("Select test"); } }
private void buttonSend_Click(object sender, EventArgs e) { var checkedButton = this.groupBox1.Controls.OfType <RadioButton>() .FirstOrDefault(r => r.Checked); UserChoice userChoice = new UserChoice(checkedButton.Text); foreach (UserChoice answer in questions[currentQuestion].Answers) { if (answer.Equals(userChoice)) { score += questions[currentQuestion].Value; } } if (currentQuestion == questions.Count - 1) { TestController testController = new TestController(); int maxScore = 0; foreach (QuestionModel question in questions) { maxScore += question.Value; } double scr = Convert.ToDouble(score); scr = scr / maxScore * 100; score = Convert.ToInt32(scr); testController.WriteTestResults(test, user, score); this.Close(); Results resultsWindow = new Results(user, test, score); resultsWindow.Show(); } else { currentQuestion++; this.Close(); CurrentQuestionWindow currentQuestionWindow = new CurrentQuestionWindow(user, test, questions, currentQuestion, score); currentQuestionWindow.Show(); } }