public override bool StoreActivity()
        {
            // Save completed Drill to the database. Auto-increment Activity ID in database.
            DrillDB.AddCompletedPlacement(this, Student);


            return(true);
        }
Exemple #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();
            }
        }