コード例 #1
0
ファイル: Testing.cs プロジェクト: semdelion/dissertation
        void Form_FQ(Question Q, Questions_Form FQ, int ind) // заполнение объектов.
        {
            FQ.Question = new Label
            {
                BackColor   = System.Drawing.Color.Transparent,
                ForeColor   = Design.Font_color,
                Font        = Design.Font_heading,
                Text        = $"{Convert.ToString(ind + 1)}) {Q._Question}",
                AutoSize    = true,
                MaximumSize = new Size(this.Width - 60, this.Height - 60)
            };

            for (int i = 0; i < Q._Answer.Count; i++)
            {
                FQ.Answer.Add(new CheckBox
                {
                    Text       = Q._Answer[i],
                    Appearance = Appearance.Button,

                    AutoSize = true,
                    BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch,
                    BackColor             = System.Drawing.Color.Transparent,
                    FlatStyle             = System.Windows.Forms.FlatStyle.Flat,
                    ForeColor             = Design.Font_color,
                    Font        = Design.Font_text,
                    MaximumSize = new Size(this.Width - 60, this.Height - 60),
                    MinimumSize = new Size(100, 20),
                });
                FQ.Answer[FQ.Answer.Count - 1].FlatAppearance.BorderSize         = 0;
                FQ.Answer[FQ.Answer.Count - 1].FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(30, 1, 253, 179);
                FQ.Answer[FQ.Answer.Count - 1].FlatAppearance.CheckedBackColor   = System.Drawing.Color.FromArgb(200, 1, 253, 179);
                FQ.Answer[FQ.Answer.Count - 1].FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(100, 1, 253, 179);
            }
        }
コード例 #2
0
ファイル: Testing.cs プロジェクト: semdelion/dissertation
 public Questions_Form(Questions_Form q)
 {
     Question = q.Question;
     Answer   = new List <CheckBox>();
     foreach (var i in q.Answer)
     {
         Answer.Add(i);
     }
 }
コード例 #3
0
ファイル: Testing.cs プロジェクト: semdelion/dissertation
        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();
                }
            }
        }