示例#1
0
        private void Create_Scale(Test TEST)
        {
            Scale_label.Text = $"{Convert.ToString(Scale_number + 1)} / {Convert.ToString(TEST._Scales.Count)}";

            Design.Design_for_textbox(name_Scale_textBox);
            Design.Design_for_textbox(description_textBox);

            if_textBox.Text          = TEST._Scales[Scale_number].If_scale;
            name_Scale_textBox.Text  = TEST._Scales[Scale_number].Name_scale;
            description_textBox.Text = TEST._Scales[Scale_number].Manifestation;

            Resize();
            Show_Scale();
        }
示例#2
0
        void ShowTest(List <string> Tests, int Test_number, string FileName)
        {
            Test TEST = new Test();

            if (!TEST.Creat_test(Tests[Test_number]))
            {
                MessageBox.Show($"Ошибка: Файл - \"{Tests[Test_number]}\" содержит ошибку.");
                this.Close();
                throw new Exception($"Ошибка: Файл - \"{Tests[Test_number]}\" содержит ошибку.");
            }
            TESTS.Add(TEST);                                                                   // add test in list
            this.Text                   = TEST._Header.Name;
            LABEL_TEST_NAME.Text        = TEST._Header.Name;                                   // test name
            LABEL_TEST_DESCRIPTION.Text = TEST._Header.Description;                            // test description
            List <Questions_Form> LIST_OF_LABELS_TEST_QUESTIONS = new List <Questions_Form>(); // список вопросов

            for (int i = 0; i < TEST._Questions.Count; i++)
            {
                Questions_Form temp = new Questions_Form();
                Form_FQ(TEST._Questions[i], temp, i);
                LIST_OF_LABELS_TEST_QUESTIONS.Add(temp);
            }
            Button BUTTON_TEST_FINISH = new Button
            {
                Size = new System.Drawing.Size(200, 45),
                Text = "Завершить тестирование",
                UseVisualStyleBackColor = true
            };

            Design.Design_for_button(BUTTON_TEST_FINISH);

            BUTTON_TEST_FINISH.Click += new System.EventHandler(BUTTON_TEST_FINISH_Click);

            Auto_Size(LABEL_TEST_NAME, LABEL_TEST_DESCRIPTION, LIST_OF_LABELS_TEST_QUESTIONS, BUTTON_TEST_FINISH);

            void BUTTON_TEST_FINISH_Click(object sender, EventArgs e) // Кновка закончить тест.
            {
                Answers_to_Test answers_to_the_Test = new Answers_to_Test();

                Create_Answer_list(LIST_OF_LABELS_TEST_QUESTIONS, answers_to_the_Test);//формируем список вопросов и ответов на эти вопросы.

                if (TEST._Header.Verifier == VerificationDescriptors._ONLY_ONE)
                {
                    for (int i = 0; i < answers_to_the_Test.Count; i++)
                    {
                        if (answers_to_the_Test[i].Count != 1)
                        {
                            string Err = "Ошибка: на вопрос: ";
                            for (; i < answers_to_the_Test.Count; i++)
                            {
                                if (answers_to_the_Test[i].Count != 1)
                                {
                                    Err += $" {Convert.ToString(i + 1)}";
                                }
                            }
                            MessageBox.Show($"{Err} должен быть один.");
                            return;
                        }
                    }
                }

                if (TEST._Header.Verifier == VerificationDescriptors._AT_LEAST_ONE)
                {
                    for (int i = 0; i < answers_to_the_Test.Count; i++)
                    {
                        if (answers_to_the_Test[i].Count == 0)
                        {
                            string Err = "Ошибка: вы не ответили на вопрос: ";
                            for (; i < answers_to_the_Test.Count; i++)
                            {
                                if (answers_to_the_Test[i].Count == 0)
                                {
                                    Err += $" {Convert.ToString(i + 1)}";
                                }
                            }
                            MessageBox.Show(Err);
                            return;
                        }
                    }
                }

                Answer_to_all_tests.Add(answers_to_the_Test);
                if (Test_number < Tests.Count - 1)
                {
                    this.Controls.Clear();
                    ShowTest(Tests, Test_number + 1, FileName);
                }
                else
                {
                    Test_parser.Create_an_automatic_resume(TESTS, Answer_to_all_tests, FileName);
                    this.Close();
                }
            }
        }