private void Proceed(object sender, EventArgs e) { _settings = new Settings { CandidateName = txt_candidate_name.Text }; if (chk_enable_timer.Checked) { _settings.TimeLimit = (int)num_time_limit.Value; } else { _settings.TimeLimit = _exam.Properties.TimeLimit; } // if (rdb_selected_sections.Checked) { _settings.Sections = clb_section_options.CheckedItems.Cast <Section>().ToList(); foreach (var section in _settings.Sections) { _settings.Questions.AddRange(section.Questions.ToArray()); } } // if (rdb_fixed_number_questions.Checked) { var numOfQuestions = (int)num_questions.Value; var sum = 0; foreach (var section in _exam.Sections) { if (sum + section.Questions.Count < numOfQuestions) { _settings.Sections.Add(section); _settings.Questions.AddRange(section.Questions.ToArray()); sum += section.Questions.Count; } else if (sum + section.Questions.Count == numOfQuestions) { _settings.Sections.Add(section); _settings.Questions.AddRange(section.Questions.ToArray()); break; } else { var difference = numOfQuestions - sum; _settings.Sections.Add(section); _settings.Questions.AddRange(section.Questions.GetRange(0, difference).ToArray()); break; } } } // var ui = new AssessmentUi(_exam, _settings); Hide(); ui.ShowDialog(); Close(); }
private void Proceed(object sender, EventArgs e) { _settings = new Settings { CandidateName = txt_candidate_name.Text }; if (chk_enable_timer.Checked) { _settings.TimeLimit = (int)num_time_limit.Value; } else { _settings.TimeLimit = _exam.Properties.TimeLimit; } if (rdb_selected_sections.Checked) { _settings.Sections = clb_section_options.CheckedItems.Cast <Section>().ToList(); foreach (var section in _settings.Sections) { _settings.Questions.AddRange(section.Questions.ToArray()); } } if (rdb_fixed_number_questions.Checked) { var numOfQuestions = (int)num_questions.Value; var sum = 0; foreach (var section in _exam.Sections) { if (sum + section.Questions.Count < numOfQuestions) { _settings.Sections.Add(section); _settings.Questions.AddRange(section.Questions.ToArray()); sum += section.Questions.Count; } else if (sum + section.Questions.Count == numOfQuestions) { _settings.Sections.Add(section); _settings.Questions.AddRange(section.Questions.ToArray()); break; } else { var difference = numOfQuestions - sum; _settings.Sections.Add(section); _settings.Questions.AddRange(section.Questions.GetRange(0, difference).ToArray()); break; } } } if (rdbTakeAllMarkedQuestions.Checked) { _settings.Sections.AddRange(_exam.Sections); _settings.Questions.AddRange(_exam.AllQuestions); _settings.MarkedForReviewQuestionsOnly = true; } if (_settings.Questions.Count == 0) { MessageBox.Show( "There are no questions to be displayed based on your selection. Please make a different selection.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var ui = new AssessmentUi(_exam, _settings, _filePath); Hide(); ui.ShowDialog(); Close(); }