private void bTest1_Click(object sender, EventArgs e) { bFinish.Show(); User.NameOfTest = cbListTests.SelectedValue.ToString(); pTestsMain.Hide(); lNameTest.Text = "Test: " + User.NameOfTest; lScore.Text = ""; DB.GetAmountOfQuestions(); AddToList.SetDefaultAnswers(); pCenter.Show(); pTriggers.Show(); User.NumQuestion = 1; User.TotalScore = 0; TestFinished = false; bBack.Hide(); bNext.Show(); ShowQuestions(); pLeft.Hide(); tbQ1.BackColor = Color.FromName("White"); tbQ2.BackColor = Color.FromName("White"); tbQ3.BackColor = Color.FromName("White"); tbQ4.BackColor = Color.FromName("White"); TestFinished = false; }
public void ShowQuestions() { User.NameOfTest = cbListTests.SelectedValue.ToString(); if (User.NumQuestion < User.AmountOfQuestions) { bBack.Show(); bNext.Show(); } if (User.NumQuestion > 1) { bBack.Show(); bNext.Show(); } if (User.NumQuestion == 1) { bBack.Hide(); bNext.Show(); } if (User.NumQuestion == 0) { User.NumQuestion = 1; bBack.Hide(); bNext.Hide(); return; } User.AmountOfQuestions = 0; DB.GetAmountOfQuestions(); if (User.AmountOfQuestions == 1) { bDeleteQuestion.Hide(); } else { bDeleteQuestion.Show(); } if (User.NumQuestion == User.AmountOfQuestions) { bNext.Hide(); bBack.Show(); } DB.GetQAnswers(User.NumQuestion); tbAnsw1.Text = User.AnswerQ1; tbAnsw2.Text = User.AnswerQ2; tbAnsw3.Text = User.AnswerQ3; tbAnsw4.Text = User.AnswerQ4; User.Question = (DB.LoadTest1(@"SELECT Questions FROM " + User.NameOfTest + " WHERE numQuestion = " + User.ArrOfQuestions[User.NumQuestion])); rtbAddQuestion.Text = User.Question; AddToList.SetDefaultAnswers(); DB.GetCorrectAnswer(); if ((User.CorrectAnswer.ElementAt(User.NumQuestion)) == tbAnsw1.Text) { rbAA.Checked = true; } ; if ((User.CorrectAnswer.ElementAt(User.NumQuestion)) == tbAnsw2.Text) { rbBB.Checked = true; } ; if ((User.CorrectAnswer.ElementAt(User.NumQuestion)) == tbAnsw3.Text) { rbCC.Checked = true; } ; if ((User.CorrectAnswer.ElementAt(User.NumQuestion)) == tbAnsw4.Text) { rbDD.Checked = true; } ; lInfo.Text = "Test: " + User.NameOfTest; lQuestion.Text = "Question " + User.NumQuestion + "/" + User.AmountOfQuestions; if (lQuestion.Text == "Question 1/1") { bBack.Hide(); bNext.Hide(); } if (lQuestion.Text == "Question 0/0") { MessageBox.Show("Test without questions"); } }