Esempio n. 1
0
        private void CreateHistoryRecord(int quizid, int completed)
        {
            var questions = qe.Quiz.Find(quizid).Question;

            int total = questions.Count;

            int correctcount = qe.Quiz.Find(quizid).Question.Count(x => x.Correct == true);

            double correctpercentage = (double)correctcount / (double)total * 100;

            correctpercentage = Math.Round(correctpercentage, 1);

            QuizHistory qh = new QuizHistory();

            qh.QuizID            = quizid;
            qh.Completed         = completed;
            qh.CorrectPercentage = correctpercentage;

            qe.QuizHistory.Add(qh);

            qe.SaveChanges();

            foreach (var q in questions)
            {
                QuizHistoryDetail qhd = new QuizHistoryDetail();
                qhd.QuizHistoryID = qh.ID;
                qhd.QuestionID    = q.ID;
                qhd.Correct       = q.Correct;

                qe.QuizHistoryDetail.Add(qhd);
            }

            qe.SaveChanges();
        }
Esempio n. 2
0
        private void btnView_Click(object sender, RoutedEventArgs e)
        {
            QuizHistory qh = (sender as Button).DataContext as QuizHistory;

            QuizHistoryDetailWindow qhdw = new QuizHistoryDetailWindow(this, qh.ID);

            qhdw.ShowDialog();
        }