Пример #1
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);
            }
        }
Пример #2
0
        public void NotifyAssessmentOpened()
        {
            //Reset the image tracker
            ImageTracker.Reset();

            //Load questions into tree view
            Util.PopulateTreeView(treeViewQuestionDisplay, Script);

            //Select the first question
            if (treeViewQuestionDisplay.Nodes.Count > 0)
            {
                treeViewQuestionDisplay.SelectedNode = treeViewQuestionDisplay.Nodes[0];
            }

            //Set the mode:
            if (Script.Published)
            {
                CurMode = Mode.Assessment;
            }
            else
            {
                CurMode = Mode.Practice;
            }

            //Set the stage:
            if (Script.Started)
            {
                //Handle an already started assessment
                if (Script.TimeData.HasReadingTime && DateTime.Now < Script.TimeData.ReadingFinishTime)
                {
                    CurStage = Stage.Reading;
                }
                else if (DateTime.Now < Script.TimeData.PlannedFinishTime)
                {
                    CurStage = Stage.Running;
                }
                else
                {
                    CurStage = Stage.Completed;
                }
            }
            else
            {
                //AssessmentScript has not been started yet:
                Script.Started = true;
                Script.TimeData.TimeStarted = DateTime.Now;
                if (Script.TimeData.HasReadingTime)
                {
                    CurStage = Stage.Reading;
                }
                else
                {
                    CurStage = Stage.Running;
                }
            }

            //Cache the total number of marks
            TotalMarksCache = Script.TotalMarks;

            //Set the maximum for the progress bar
            progressBarMarksAttempted.Maximum = TotalMarksCache;

            //Update the unattempted list
            listBoxUnansweredQuestions.Items.Clear();
            listBoxUnansweredQuestions.Items.AddRange(UnattemptedQuestions.ToArray());

            //Display the times
            UpdateTimeDisplay(true);
        }