예제 #1
0
        public override bool StoreActivity()
        {
            // Save completed Drill to the database. Auto-increment Activity ID in database.
            DrillDB.AddCompletedDrill(this, Student);


            return(true);
        }
예제 #2
0
 private void btnSubmitAnswer_Click(object sender, EventArgs e)
 {
     try
     {
         double answer    = Convert.ToDouble(txtAnswer.Text);
         bool   isCorrect = Drill.CheckAnswer(answer);
         if (!isCorrect && Drill.NumberOfAttempts > 0)
         {
             MessageBox.Show("Incorrect answer.\n\nTry again.", "Incorrect answer.");
         }
         else if (!isCorrect)
         {
             if (Drill.NumberOfAttempts > 0)
             {
                 MessageBox.Show("Incorrect, please try again.", "Incorrect Answer");
             }
             else
             {
                 MessageBox.Show($"Incorrect answer.\n\nThe correct answer is: {Drill.Question.Answer}", "Incorrect Answer");
                 txtAnswer.Text = "";
                 Drill.GetNextQuestion();
                 txtQuestion.Text = Drill.Question.NewQuestion;
             }
         }
         else
         {
             MessageBox.Show("Correct!", "Correct Answer");
             txtAnswer.Text = "";
             Drill.GetNextQuestion();
             txtQuestion.Text = Drill.Question.NewQuestion;
             txtAnswer.Focus();
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("Please enter a number.", e.GetType().ToString());
     }
     catch (Exception f)
     {
         MessageBox.Show(f.Message);
         // I am not understanding what the Activity History class is for, so I'm not sure how to call this method
         DrillDB.AddCompletedDrill(Drill, Student);
         this.Hide();
         frmHomePage HomePage = new frmHomePage(Student.UserId);
         HomePage.ShowDialog();
     }
 }