Example #1
0
        private void setScore(int index, Boolean isEnd)
        {
            ExamSubQuestionPanel examSubQuestionPanel = examMainQuestionPanelList[shortCutButtonList[index].MainQuestionNo].SubQuestionPanelsList[shortCutButtonList[index].SubQuestionNo];
            int score = int.Parse(examSubQuestionPanel.StudentScorePanel.ScoreTextBox.Text);

            string value = "";

            switch (examSubQuestionPanel.Type)
            {
            case 0:
                ExamOXPanel examOXPanel = (ExamOXPanel)examSubQuestionPanel;
                value = examOXPanel.Answer.ToString();
                break;

            case 1:
                ExamShortAnswerQuestionPanel examShortAnswerQuestionPanel = (ExamShortAnswerQuestionPanel)examSubQuestionPanel;
                value = examShortAnswerQuestionPanel.AnswerPanel.AnswerLabel.Text;
                break;

            case 2:
                ExamEssayQuestionPanel examEssayQuestionPanel = (ExamEssayQuestionPanel)examSubQuestionPanel;
                value = examEssayQuestionPanel.AnswerPanel.AnswerLabel.Text;
                break;

            case 3:
                ExamMultipleChoiceQuestionPanel examMultipleChoiceQuestionPanel = (ExamMultipleChoiceQuestionPanel)examSubQuestionPanel;
                value = examMultipleChoiceQuestionPanel.Answer.ToString();
                break;

            default: break;
            }

            isScoredList[index] = true;

            if (isEnd)
            {
                try
                {
                    mainController.professorChangeScore(value, room_id, index + 1, student_id, score);
                }
                catch (Exception error)
                {
                    Console.WriteLine(error);
                }
            }
            else
            {
                (new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        mainController.professorChangeScore(value, room_id, index + 1, student_id, score);
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error);
                    }
                }))).Start();
            }
        }
Example #2
0
        private void multiple_enter_answer(object sender, EventArgs e)
        {
            RadioButton                     radioButton                     = (RadioButton)sender;
            ExamMultipleChoicePanel         multipleChoicePanel             = (ExamMultipleChoicePanel)radioButton.Parent;
            ExamSubQuestionPanel            multipleChoiceQuestionPanel     = (ExamSubQuestionPanel)multipleChoicePanel.Parent;
            ExamMultipleChoiceQuestionPanel examMultipleChoiceQuestionPanel = (ExamMultipleChoiceQuestionPanel)multipleChoiceQuestionPanel;
            int index = Find_shortCutButton_index(multipleChoiceQuestionPanel);

            submitAnswer(examMultipleChoiceQuestionPanel.Answer.ToString(), index + 1);
            shortCutButtonList[index].BackColor = Color.GreenYellow;
        }
Example #3
0
        private void setAnswers(JArray jArray)
        {
            int count = jArray.Count;

            for (int i = 0; i < count; i++)
            {
                int     num      = (int)jArray[i]["question_num"];
                int     score    = (int)jArray[i]["score"];
                string  value    = (string)jArray[i]["value"];
                Boolean isScored = (Boolean)jArray[i]["is_scored"];

                isScoredList[num - 1] = isScored;
                ExamSubQuestionPanel subQuestionPanel = examMainQuestionPanelList[shortCutButtonList[num - 1].MainQuestionNo].SubQuestionPanelsList[shortCutButtonList[num - 1].SubQuestionNo];
                subQuestionPanel.StudentScorePanel.ScoreTextBox.Text = score.ToString();
                int type = subQuestionPanel.Type;
                if (type == 0)
                {
                    ExamOXPanel oxPanel = (ExamOXPanel)subQuestionPanel;
                    oxPanel.checkAnswer(value);
                }
                else if (type == 1)
                {
                    ExamShortAnswerQuestionPanel shortAnswerQuestionPanel = (ExamShortAnswerQuestionPanel)subQuestionPanel;
                    shortAnswerQuestionPanel.AnswerPanel.AnswerLabel.Text   = value;
                    shortAnswerQuestionPanel.AnswerPanel.AnswerTextBox.Text = value;
                    if (!value.Equals(""))
                    {
                        shortAnswerQuestionPanel.AnswerPanel.AnswerLabel.Visible   = true;
                        shortAnswerQuestionPanel.AnswerPanel.AnswerTextBox.Visible = false;
                    }
                }
                else if (type == 2)
                {
                    ExamEssayQuestionPanel essayQuestionPanel = (ExamEssayQuestionPanel)subQuestionPanel;
                    essayQuestionPanel.AnswerPanel.AnswerLabel.Text   = value;
                    essayQuestionPanel.AnswerPanel.AnswerTextBox.Text = value;
                    if (!value.Equals(""))
                    {
                        essayQuestionPanel.AnswerPanel.AnswerLabel.Visible   = true;
                        essayQuestionPanel.AnswerPanel.AnswerTextBox.Visible = false;
                    }
                }
                else
                {
                    ExamMultipleChoiceQuestionPanel multipleChoiceQuestionPanel = (ExamMultipleChoiceQuestionPanel)subQuestionPanel;
                    multipleChoiceQuestionPanel.checkAnswer(value);
                }
            }
        }
Example #4
0
        private void initShortCutButton()
        {
            int index = 0, count = examMainQuestionPanelList.Count, i;
            int locationY;
            int locationX;

            for (i = 0; i < count; i++)
            {
                int subCount = examMainQuestionPanelList[i].SubQuestionPanelsList.Count;

                for (int j = 0; j < subCount; j++)
                {
                    ShortCutButton shortCutButton = new ShortCutButton(customFonts, index + 1);
                    locationY = (index / 4) * 27;
                    locationX = (index % 4) * 77;
                    this.examShortCutPanel.Controls.Add(shortCutButton);
                    this.shortCutButtonList.Add(shortCutButton);
                    shortCutButton.Location       = new Point(locationX, locationY);
                    shortCutButton.MainQuestionNo = i;
                    shortCutButton.SubQuestionNo  = j;
                    shortCutButton.Click         += shortCutButton_Click_1;
                    index++;

                    if (!isStudent)
                    {
                        isScoredList.Add(false);
                        examMainQuestionPanelList[i].SubQuestionPanelsList[j].ExamScorePanel.ScoreTextBox.BackColor     = Color.White;
                        examMainQuestionPanelList[i].SubQuestionPanelsList[j].StudentScorePanel.Visible                 = true;
                        examMainQuestionPanelList[i].SubQuestionPanelsList[j].StudentScorePanel.ScoreTextBox.LostFocus += ScoreTextBox_LostFocus;
                    }
                    if (isStudent)
                    {
                        ExamSubQuestionPanel examSubQuestionPanel = examMainQuestionPanelList[i].SubQuestionPanelsList[j];

                        switch (examSubQuestionPanel.Type)
                        {
                        case 0:
                            ExamOXPanel examOXPanel = (ExamOXPanel)examSubQuestionPanel;
                            examOXPanel.OButton.Click += ox_enter_answer;
                            examOXPanel.XButton.Click += ox_enter_answer;
                            break;

                        case 1:
                            ExamShortAnswerQuestionPanel examShortAnswerQuestionPanel = (ExamShortAnswerQuestionPanel)examSubQuestionPanel;
                            examShortAnswerQuestionPanel.AnswerPanel.AnswerTextBox.LostFocus += short_enter_answer;
                            break;

                        case 2:
                            ExamEssayQuestionPanel examEssayQuestionPanel = (ExamEssayQuestionPanel)examSubQuestionPanel;
                            examEssayQuestionPanel.AnswerPanel.AnswerTextBox.LostFocus += essay_enter_answer;
                            break;

                        case 3:
                            ExamMultipleChoiceQuestionPanel examMultipleChoiceQuestionPanel = (ExamMultipleChoiceQuestionPanel)examSubQuestionPanel;
                            add_event_at_radiobutton(examMultipleChoiceQuestionPanel.ChoicePaneList);
                            break;

                        default: break;
                        }
                    }
                }
            }
        }
Example #5
0
        private void loadQuestions(JArray questions)
        {
            int cnt   = questions.Count;
            int index = 1;

            for (int i = 0; i < cnt; i++)
            {
                JObject question     = (JObject)questions[i];
                JArray  subQuestions = (JArray)question["subQuestions"];
                int     subCnt       = subQuestions.Count;
                string  mainQuestion = (string)question["question"];
                ExamMainQuestionPanel       examMainQuestionPanel;
                List <ExamSubQuestionPanel> examSubQuestionPanelList = new List <ExamSubQuestionPanel>();
                for (int j = 0; j < subCnt; j++)
                {
                    int    type        = (int)subQuestions[j]["type"];
                    int    score       = (int)subQuestions[j]["score"];
                    string subQuestion = (string)subQuestions[j]["question"];
                    if (type == 0)
                    {
                        ExamOXPanel examOXPanel = new ExamOXPanel(customFonts, (index++).ToString() + ". " + subQuestion, score);
                        examSubQuestionPanelList.Add(examOXPanel);
                        if (!isStudent)
                        {
                            examOXPanel.OButton.Click -= examOXPanel.oButton_Click_1;
                            examOXPanel.XButton.Click -= examOXPanel.xButton_Click_1;
                        }
                    }
                    else if (type == 1)
                    {
                        ExamShortAnswerQuestionPanel examShortAnswerQuestionPanel = new ExamShortAnswerQuestionPanel(customFonts, (index++).ToString() + ". " + subQuestion, score);
                        examSubQuestionPanelList.Add(examShortAnswerQuestionPanel);
                        if (!isStudent)
                        {
                            examShortAnswerQuestionPanel.AnswerPanel.AnswerTextBox.ReadOnly = true;
                        }
                    }
                    else if (type == 2)
                    {
                        int maxLength = (int)subQuestions[j]["maxLength"];
                        ExamEssayQuestionPanel examEssayQuestionPanel = new ExamEssayQuestionPanel(customFonts, (index++).ToString() + ". " + subQuestion, score, maxLength);
                        examSubQuestionPanelList.Add(examEssayQuestionPanel);
                        if (!isStudent)
                        {
                            examEssayQuestionPanel.AnswerPanel.AnswerTextBox.ReadOnly = true;
                        }
                    }
                    else
                    {
                        JArray   examples   = (JArray)subQuestions[j]["examples"];
                        int      exampleCnt = examples.Count;
                        string[] example    = new string[exampleCnt];
                        for (int t = 0; t < exampleCnt; t++)
                        {
                            example[t] = (string)examples[t]["example"];
                        }
                        ExamMultipleChoiceQuestionPanel examMultipleChoiceQuestionPanel = new ExamMultipleChoiceQuestionPanel(customFonts, (index++).ToString() + ". " + subQuestion, score, example, isStudent);
                        examSubQuestionPanelList.Add(examMultipleChoiceQuestionPanel);
                    }
                }
                examMainQuestionPanel = new ExamMainQuestionPanel(customFonts, mainQuestion, examSubQuestionPanelList);
                examMainQuestionPanelList.Add(examMainQuestionPanel);
                this.examMainQuestionPanelList[i].Location = new Point(30, 30);
                this.examPanel.Controls.Add(this.examMainQuestionPanelList[i]);
                if (i != 0)
                {
                    examMainQuestionPanelList[i].Visible = false;
                }
            }

            this.examPageNavigationPanel.WholePageLabel.Text = cnt.ToString();
            this.examPageNavigationPanel.NowPageTextBox.Text = "1";
        }