private void btnQuestionImage_Click(object sender, EventArgs e) { Question question = SelectedQuestion; if (question != null && question.Image != null) { //Show the image if not already shown if (!ImageTracker.ImageDisplayShown(question.Name)) { ImageDisplay id = new ImageDisplay(question.Name, question.Image); id.Show(); id.TopMost = true; id.BringToFront(); } else { ImageTracker.FindImageDisplay(question.Name).Focus(); } } }
private void treeViewQuestionDisplay_AfterSelect(object sender, TreeViewEventArgs e) { if (SelectedQuestion == null) { return; } //Display the question text rtbQuestion.Rtf = SelectedQuestion.QuestionText; //Update the marks display UpdateMarksDisplay(); //Show the question name lblQuestionNumber.Text = SelectedQuestion.Name; //Show the correct answer page and any answer already entered #region Answer switch (SelectedQuestion.AnswerType) { case AnswerType.None: { panelAnswerLongContainer.Enabled = false; panelAnswerLongContainer.Visible = false; panelAnswerShortContainer.Enabled = false; panelAnswerShortContainer.Visible = false; tlpMultiAnswerContainer.Enabled = false; tlpMultiAnswerContainer.Visible = false; labelAnswerText.Visible = false; break; } case AnswerType.Multi: { panelAnswerLongContainer.Enabled = false; panelAnswerLongContainer.Visible = false; panelAnswerShortContainer.Enabled = false; panelAnswerShortContainer.Visible = false; tlpMultiAnswerContainer.Enabled = true; tlpMultiAnswerContainer.Visible = true; labelAnswerText.Visible = true; labelOptionA.Text = SelectedQuestion?.OptionA; labelOptionB.Text = SelectedQuestion?.OptionB; labelOptionC.Text = SelectedQuestion?.OptionC; labelOptionD.Text = SelectedQuestion?.OptionD; //Select the answer that has been selected (if so) switch (SelectedQuestionAnswer.SelectedOption) { case MultiChoiceOption.A: { bool flag = changesMade; rbOptionA_Click(sender, e); changesMade = flag; break; } case MultiChoiceOption.B: { bool flag = changesMade; rbOptionB_Click(sender, e); changesMade = flag; break; } case MultiChoiceOption.C: { bool flag = changesMade; rbOptionC_Click(sender, e); changesMade = flag; break; } case MultiChoiceOption.D: { bool flag = changesMade; rbOptionD_Click(sender, e); changesMade = flag; break; } default: rbOptionA.Checked = false; rbOptionB.Checked = false; rbOptionC.Checked = false; rbOptionD.Checked = false; break; } break; } case AnswerType.Open: { panelAnswerLongContainer.Enabled = true; panelAnswerLongContainer.Visible = true; panelAnswerShortContainer.Enabled = false; panelAnswerShortContainer.Visible = false; tlpMultiAnswerContainer.Enabled = false; tlpMultiAnswerContainer.Visible = false; labelAnswerText.Visible = true; //Stop the changesMade flag from being flipped by changing the answer text, this stops it autosaving every time the user goes to another question. bool flag = changesMade; //Show the entered answer rtbAnswerLong.Text = SelectedQuestionAnswer.LongAnswer; changesMade = flag; break; } case AnswerType.Single: { panelAnswerLongContainer.Enabled = false; panelAnswerLongContainer.Visible = false; panelAnswerShortContainer.Enabled = true; panelAnswerShortContainer.Visible = true; tlpMultiAnswerContainer.Enabled = false; tlpMultiAnswerContainer.Visible = false; labelAnswerText.Visible = true; bool flag = changesMade; // Show the entered answer textBoxAnswerShort.Text = SelectedQuestionAnswer.ShortAnswer; changesMade = flag; break; } } #endregion //Show or hide the image button if (SelectedQuestion.Image != null) { btnQuestionImage.Enabled = true; btnQuestionImage.Visible = true; //Show the image if not already shown if (!ImageTracker.ImageDisplayShown(SelectedQuestion.Name)) { ImageDisplay id = new ImageDisplay(SelectedQuestion.Name, SelectedQuestion.Image); id.Show(); id.TopMost = true; id.BringToFront(); } else { ImageTracker.FindImageDisplay(SelectedQuestion.Name).Focus(); } } else { btnQuestionImage.Enabled = false; btnQuestionImage.Visible = false; } //Update unanswered questions listBoxUnansweredQuestions.Items.Clear(); listBoxUnansweredQuestions.Items.AddRange(UnattemptedQuestions.ToArray()); //Do an autosave if changes have been made and the assessment is a proper assessment (not a practice) if (Script.Published && changesMade) { SaveToFile(true); } }