public static List <double> _SUM_counting(List <Key> keys, Answers_to_Test Answers_to_the_test) { try { List <double> Key_value_all = new List <double>(); for (int scale_number = 0; scale_number < keys.Count; scale_number++) { double Point = 0; for (int i = 0; i < keys[scale_number].Count; i++) { for (int j = 0; j < Answers_to_the_test[(keys[scale_number][i].Question - 1)].Count; j++) { if (Answers_to_the_test[(keys[scale_number][i].Question - 1)][j] == (keys[scale_number][i].Answer - 1)) { Point += keys[scale_number][i].Point; } } } Key_value_all.Add(Point); } return(Key_value_all); } catch { Stored_Exceptions.Add(new Exception("Error: internal format is not correct")); return(null); } }
void Create_Answer_list(List <Questions_Form> T_F, Answers_to_Test answers_to_the_test) // Формируем вектор ответов на тест. { for (int i = 0; i < T_F.Count; i++) { Answers_to_question A = new Answers_to_question(); for (int j = 0; j < T_F[i].Answer.Count; j++) { if (T_F[i].Answer[j].Checked) { A.Add(j); } } answers_to_the_test.Add(A); } }
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(); } } }