Ejemplo n.º 1
0
        public static ImageDisplay FindImageDisplay(string questionName)
        {
            ImageDisplay d = (from x in list
                              where x.Text.Contains(questionName)
                              select x).First();

            return(d);
        }
Ejemplo n.º 2
0
        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();
                }
            }
        }
Ejemplo n.º 3
0
 public static void DeregisterImageDisplay(ImageDisplay d)
 {
     list.Remove(d);
 }
Ejemplo n.º 4
0
 public static void RegisterImageDisplay(ImageDisplay d)
 {
     list.Add(d);
 }
Ejemplo n.º 5
0
        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);
            }
        }