コード例 #1
0
        public override bool StoreActivity()
        {
            // Save completed Drill to the database. Auto-increment Activity ID in database.
            DrillDB.AddCompletedPlacement(this, Student);


            return(true);
        }
コード例 #2
0
        private void btnSubmitAnswer_Click_1(object sender, EventArgs e)
        {
            try
            {
                int  answer    = int.Parse(txtAnswer.Text);
                bool isCorrect = Placement.CheckAnswer(answer);
                if (!isCorrect && Placement.NumberOfAttempts > 0)
                {
                    MessageBox.Show("Incorrect answer.\n\nTry again.", "Incorrect answer.");
                }
                else if (!isCorrect)
                {
                    if (Placement.NumberOfAttempts > 0)
                    {
                        MessageBox.Show("Incorrect, please try again.", "Incorrect Answer");
                    }
                    else
                    {
                        MessageBox.Show($"Incorrect answer.\n\nThe correct answer is: {Placement.Question.Answer}", "Incorrect Answer");
                        txtAnswer.Text = "";
                        Placement.GetNextQuestion();
                        txtQuestion.Text = Placement.Question.NewQuestion;
                    }
                }
                else
                {
                    MessageBox.Show("Correct!", "Correct Answer");
                    txtAnswer.Text = "";

                    Placement.GetNextQuestion();
                    txtQuestion.Text = Placement.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
                Student.StudentLevel = Placement.Student.StudentLevel;

                //Add student level. studentid, and class to the studentinfo class to store ActivityData
                StudentInfoDB.AddToStudentInfo(Student);
                DrillDB.AddCompletedPlacement(Placement, Student);
                MessageBox.Show("Congratulation you just finish your placement and currently at level " + Student.studentLevel);
                this.Hide();
                frmHomePage HomePage = new frmHomePage(Student);
                HomePage.ShowDialog();
            }
        }
コード例 #3
0
ファイル: frmDrill.cs プロジェクト: poodleartist/testMath
 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();
     }
 }