protected void NextQuestionBtn_Click(object sender, EventArgs e) { int crrQuestionNum = (int) ViewState["CurrentQuestionNumber"]; TestService testService = new TestService(_db); QuestionService questionService = new QuestionService(_db); TestReportService testReportService = new TestReportService(); Test ts = Session["Test"] as Test; Question q = null; if (ts!= null) { ClearAllOptions(); q = testService.FindQuestionInTestByIndex(ts.Id, crrQuestionNum); if (q != null) { QuestionText.Text = q.Description; NextQuestionBtn.Text = testService.IsLastQuestionInTest(q, ts) ? "Finish Test" : "Next"; string type = questionService.GetQuestionType(q); IRuleAction rule = ruleActions.FirstOrDefault(r => r.IsValidated(type)); rule.Action.Invoke(); } else { QuestionText.Text = ""; NextQuestionBtn.Visible = false; SubmitTestBtn.Visible = true; } } crrQuestionNum++; ViewState["CurrentQuestionNumber"] = crrQuestionNum; }
private void DisplayTextOption() { int crrQuestionNum = (int) ViewState["CurrentQuestionNumber"]; TestService testService = new TestService(_db); QuestionService questionService = new QuestionService(_db); Test ts = Session["Test"] as Test; Question q = testService.FindQuestionInTestByIndex(ts.Id, crrQuestionNum); TextBoxAnswer.Visible = true; }
private void DisplayRadioBoxOptions() { int crrQuestionNum = (int) ViewState["CurrentQuestionNumber"]; TestService testService = new TestService(_db); QuestionService questionService = new QuestionService(_db); Test ts = Session["Test"] as Test; Question q = testService.FindQuestionInTestByIndex(ts.Id, crrQuestionNum); RadioButtonListAnswer.Visible = true; List<string> optionsContent = new List<string>(); foreach(QuestionOption qo in q.QuestionOption) { optionsContent.Add(qo.Content); } RadioButtonListAnswer.DataSource = optionsContent; RadioButtonListAnswer.DataBind(); }