private void btn_FinnishQuiz_Click(object sender, RoutedEventArgs e) { TimeSpan testDuration = TimeSpan.FromSeconds((SelectedQuiz.TimeToComplete * 60) - time); _timer.Stop(); if (SelectedQuiz.ShowResult == true) { MessageBox.Show("Thanks for doing the Quiz your score is : " + CurrentPoints.Sum().ToString()); } else { MessageBox.Show("Your teacher will get back to you with a result"); } UtilityTestVerktyg.Quizzes.Remove(UtilityTestVerktyg.SelectedQuiz); var userGrade = new Grade { CompletionDate = DateTime.Now, QuizId = SelectedQuizId, UserId = LoggedInUserId, UserScore = CurrentPoints.Sum(), UserGrade = (CurrentPoints.Sum() > QuizLength / 2) ? "G" : "IG", TimeToComplete = testDuration.ToString(@"mm\:ss") }; Repo.SaveUserQuizScore(userGrade); this.Close(); }
private void QuizWindowClosed(object sender, EventArgs e) { if (!Repo.DoesGradeExcist(SelectedQuizId, LoggedInUserId)) { Quizzes.Remove(UtilityTestVerktyg.SelectedQuiz); var userGrade = new Grade { CompletionDate = DateTime.Now, QuizId = SelectedQuizId, UserId = LoggedInUserId, UserScore = CurrentPoints.Sum(), UserGrade = (CurrentPoints.Sum() > QuizLength / 2) ? "G" : "IG" }; Repo.SaveUserQuizScore(userGrade); } UtilityTestVerktyg.GetUserGrade(LoggedInUserId); lv_Result.ItemsSource = UtilityTestVerktyg.UserGrades; UtilityTestVerktyg.SelectedQuiz = null; }