Exemplo n.º 1
0
        private void parseSTR()
        {
            string[]  testPRS   = testSTR.Split('|');
            ArrayList questions = new ArrayList();

            for (int i = 10; i < testPRS.Length - 2; i += 3)
            {
                string[]  test_11       = testPRS[i].Split('&');
                int       testType      = Int32.Parse(test_11[0]);
                string    test_Question = test_11[1];
                ArrayList questionList  = new ArrayList();
                int       question_rate = 1;
                string[]  questiond     = testPRS[i + 1].Split('$');
                for (int j = 0; j < 4; j++)
                {
                    string[] questions_ = questiond[j].Split('-');
                    if (testType == 1 || testType == 2)
                    {
                        Answer_type_1 ans = new Answer_type_1();
                        ans.isChecked   = bool.Parse(questions_[0]);
                        ans.answer_text = questions_[1];
                        questionList.Add(ans);
                    }
                    if (testType == 3)
                    {
                        Answer_type_2 ans = new Answer_type_2();
                        ans.answer_text       = questions_[1];
                        ans.answer_equal_text = questions_[1];
                        questionList.Add(ans);
                    }
                }
                question_rate = Int32.Parse(testPRS[i + 2]);
                questions.Add(new Question(test_Question, questionList, question_rate, testType));
            }
            int numberOfAllQuestion = Int32.Parse(testPRS[0]);
            int maxOfGraduate       = Int32.Parse(testPRS[1]);
            int numberOfQuestion    = Int32.Parse(testPRS[2]);
            int maxOfGraduateUser   = Int32.Parse(testPRS[3]);
            int testTime            = Int32.Parse(testPRS[4]);
            int questionTime        = Int32.Parse(testPRS[5]);

            // Parse question of grad
            int[] gradearr = new int[4];
            for (int i = 0; i < 4; i++)
            {
                gradearr[i] = Int32.Parse(testPRS[6 + i]);
            }
            userQuestionTypeCount = gradearr;
            test       = new Test(numberOfQuestion, questions, maxOfGraduate, gradearr, testTime, questionTime, numberOfAllQuestion, maxOfGraduateUser);
            userTestid = new int[numberOfQuestion];
        }
Exemplo n.º 2
0
        private void query_save()
        {
            ArrayList ans      = new ArrayList();
            String    grad_txt = textBox2.Text.ToString() == "" ? "0" : textBox2.Text.ToString();
            int       grad_q   = int.Parse(grad_txt) > 4 ? 4 : int.Parse(grad_txt);

            grad_q = grad_q < 1 ? 1 : grad_q;

            if (comboBox1.SelectedItem.ToString() == "Выбор правильного(ых) ответа(ов)")
            {
                int       checked_c = 0;
                ArrayList answers   = new ArrayList();
                for (int i = 0; i < checkBoxes.Count; i++)
                {
                    Answer_type_1 ans1 = new Answer_type_1();
                    ans1.isChecked = ((CheckBox)checkBoxes[i]).Checked;
                    checked_c     += ((CheckBox)checkBoxes[i]).Checked == true ? 1 : 0;
                    if (checked_c == 0 && i == checkBoxes.Count - 1)
                    {
                        ans1.isChecked = true;
                        checked_c      = 1;
                    }
                    ans1.answer_text = ((TextBox)textBoxes[i]).Text.ToString();
                    answers.Add(ans1);
                }
                Question myQue = new Question(txt_1.Text.ToString(), answers, grad_q, checked_c > 1 ? 2 : 1);
                all_graduate += grad_q;
                all_question++;
                questions2test.Add(myQue);
            }
            else if (comboBox1.SelectedItem.ToString() == "Соответствие")
            {
                ArrayList answers = new ArrayList();
                for (int i = 0; i < textBoxes.Count; i += 2)
                {
                    Answer_type_2 ans1 = new Answer_type_2();
                    ans1.answer_text       = ((TextBox)textBoxes[i]).Text.ToString();
                    ans1.answer_equal_text = ((TextBox)textBoxes[i + 1]).Text.ToString();
                    answers.Add(ans1);
                }
                Question myQue = new Question(txt_1.Text.ToString(), answers, grad_q, 3);
                all_graduate += grad_q;
                all_question++;
                questions2test.Add(myQue);
            }
            ques_graduate[grad_q - 1]++;
        }
Exemplo n.º 3
0
        public override String ToString()
        {
            String ques_str = "";

            ques_str += type.ToString() + "&" + question_text + "|";
            foreach (object l in answer_vector)
            {
                if (type == 1 || type == 2)
                {
                    Answer_type_1 ans = (Answer_type_1)l;
                    ques_str += ans.isChecked + "-" + ans.answer_text + "$";
                }
                else if (type == 3)
                {
                    Answer_type_2 ans = (Answer_type_2)l;
                    ques_str += ans.answer_text + "-" + ans.answer_equal_text + "$";
                }
            }
            ques_str += "|" + grade.ToString() + "";

            return(ques_str);
        }