private void btnOK_Click(object sender, RoutedEventArgs e) { if (lstview_Quiz.SelectedItem != null) { int quizid = (lstview_Quiz.SelectedItem as QuizInfo).QuizID; string title = (lstview_Quiz.SelectedItem as QuizInfo).QuizTitle; if ((lstview_Quiz.SelectedItem as QuizInfo).FinishedPercentageText == "Completed") { QuizEntities qe = new QuizEntities(); var quiz = qe.Quiz.Find(quizid); foreach (var q in quiz.Question) { q.Answered = false; q.Correct = false; } qe.SaveChanges(); } QuizWindow qw = new QuizWindow(this, quizid, title); qw.Show(); this.Hide(); } }
private void rbn_Correct_Checked(object sender, RoutedEventArgs e) { RadioButton rbn = sender as RadioButton; var q = qe.Question.Find((rbn.DataContext as Question).ID); q.Answered = true; q.Correct = true; qe.SaveChanges(); StackPanel sp = rbn.Parent as StackPanel; StackPanel spmain = sp.Parent as StackPanel; (spmain.Children[3] as StackPanel).Visibility = System.Windows.Visibility.Visible; ((spmain.Children[3] as StackPanel).Children[0] as TextBlock).Visibility = System.Windows.Visibility.Visible; sp.IsEnabled = false; answered_question += 1; if (answered_question == no_of_available_question) { int not_answered_count = qe.Quiz.Find(quizid).Question.Count(x => x.Answered == false); if (not_answered_count != 0) { btnNext.Visibility = System.Windows.Visibility.Visible; } else { var quiz = qe.Quiz.Find(quizid); quiz.Completed += 1; qe.SaveChanges(); CreateHistoryRecord(quizid, quiz.Completed); MessageBox.Show("Finished"); } } }