/// <summary> /// to add objective question /// </summary> /// <param name="question">objective question object to be added</param> public static void addObjectiveQuestion(ObjectiveQuestion question) { questionsAdapter.InsertQuestion(1, question.QuestionText, question.Choices[0], question.Choices[1], question.Choices[2], question.Choices[3], question.Answer.Answer, null, question.QuestionSubject, null, null, null); }
/// <summary> /// To get all questions by filtering with type (objective, descriptive or action-based) /// </summary> /// <param name="type">question type</param> /// <returns> /// arraylist of questions with specified type /// </returns> public static ArrayList getAllQuestionsByType(byte type) { CTVIATBankDataSet.QuestionsDataTable allQuestionsTable = questionsAdapter.GetAllQuestionsByType(type); ArrayList questions = new ArrayList(); if (type == 1) { foreach (DataRow row in allQuestionsTable) { String[] choices = new String[4]; choices[0] = Convert.ToString(row["objectiveChoiceOne"]); choices[1] = Convert.ToString(row["objectiveChoiceTwo"]); choices[2] = Convert.ToString(row["objectiveChoiceThree"]); choices[3] = Convert.ToString(row["objectiveChoiceFour"]); ObjectiveQuestion temp = new ObjectiveQuestion(Convert.ToString(row["question"]), choices, new ObjectiveAnswer(Convert.ToByte(row["objectiveAnswer"])), Convert.ToInt32(row["questionID"]), Convert.ToInt32(row["questionSubject"])); questions.Add(temp); } } else if (type == 2) { foreach (DataRow row in allQuestionsTable) { DescriptiveQuestion temp = new DescriptiveQuestion(Convert.ToString(row["question"]), new DescriptiveAnswer(Convert.ToString(row["descriptiveAnswer"])), Convert.ToInt32(row["questionID"]), Convert.ToInt32(row["questionSubject"])); questions.Add(temp); } } else { foreach (DataRow row in allQuestionsTable) { ActionBasedQuestion temp = new ActionBasedQuestion(Convert.ToString(row["question"]), Convert.ToInt32(row["actionType"]), Convert.ToString(row["actionParameterOne"]), Convert.ToString(row["actionParameterTwo"]), Convert.ToInt32(row["questionID"]), Convert.ToInt32(row["questionSubject"])); questions.Add(temp); } } return(questions); }
/// <summary> /// show the objective question by setting window controls and their visibility /// </summary> /// <param name="q">question to be shown</param> private void showObjectiveQuestion(ObjectiveQuestion q) { questionLabel.Text = q.QuestionText; option0Text.Text = q.Choices[0]; option1Text.Text = q.Choices[1]; option2Text.Text = q.Choices[2]; option3Text.Text = q.Choices[3]; if (q.Submitted != null) { if (q.Submitted.Answer == 1) { option0.IsChecked = true; } else if (q.Submitted.Answer == 2) { option1.IsChecked = true; } else if (q.Submitted.Answer == 3) { option2.IsChecked = true; } else if (q.Submitted.Answer == 4) { option3.IsChecked = true; } } else { option0.IsChecked = false; option1.IsChecked = false; option2.IsChecked = false; option3.IsChecked = false; } objectiveAnswerGrid.Visibility = Visibility.Visible; descriptiveAnswerGrid.Visibility = Visibility.Hidden; Speech.speakPurge("Objective Question"); Speech.speakNormal(q.QuestionText); Speech.speakNormal("option one"); Speech.speakNormal(q.Choices[0]); Speech.speakNormal("option two"); Speech.speakNormal(q.Choices[1]); Speech.speakNormal("option three"); Speech.speakNormal(q.Choices[2]); Speech.speakNormal("option four"); Speech.speakNormal(q.Choices[3]); }
/// <summary> /// shows objective question, correct and submitted answer, adjust visibility /// </summary> /// <param name="q">objective question to be shown</param> private void showObjectiveQuestionAndAnswer(ObjectiveQuestion q) { questionLabel.Text = q.QuestionText; correctAnswerLabel.Text = q.Choices[q.Answer.Answer - 1]; Speech.speakPurge("Objective Question"); Speech.speakNormal(q.QuestionText); Speech.speakNormal("Correct Answer"); Speech.speakNormal(q.Choices[q.Answer.Answer - 1]); if (q.Submitted != null) { submittedAnswerLabel.Text = q.Choices[q.Submitted.Answer - 1]; Speech.speakNormal("Your answer"); Speech.speakNormal(q.Choices[q.Submitted.Answer - 1]); } else { submittedAnswerLabel.Text = ""; Speech.speakNormal("You didn't answer"); } }
private void Window_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.N && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge(null); nextButton_Click(null, null); } else if (e.Key == Key.B && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge(null); backButton_Click(null, null); } else if (e.Key == Key.T && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge(null); speakTime(); } else if (e.Key == Key.D && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge(null); discontinueButton_Click(null, null); } else if (e.Key == Key.F && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge(null); finishButton_Click(null, null); } else if (e.Key == Key.H && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge("Press N to go next question"); Speech.speakNormal("Press B to return previous question"); Speech.speakNormal("Press T to learn how much time passed"); Speech.speakNormal("Press D to leave and continue later"); Speech.speakNormal("Press F to finish solving"); } else if (e.Key == Key.R && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { if (solver.getCurrentQuestion() is ObjectiveQuestion) { ObjectiveQuestion q = (ObjectiveQuestion)solver.getCurrentQuestion(); Speech.speakPurge("Objective Question"); Speech.speakNormal(q.QuestionText); Speech.speakNormal("option one"); Speech.speakNormal(q.Choices[0]); Speech.speakNormal("option two"); Speech.speakNormal(q.Choices[1]); Speech.speakNormal("option three"); Speech.speakNormal(q.Choices[2]); Speech.speakNormal("option four"); Speech.speakNormal(q.Choices[3]); } else if (solver.getCurrentQuestion() is DescriptiveQuestion) { DescriptiveQuestion q = (DescriptiveQuestion)solver.getCurrentQuestion(); Speech.speakPurge("Descriptive Question"); Speech.speakNormal(q.QuestionText); } else { ActionBasedQuestion q = (ActionBasedQuestion)solver.getCurrentQuestion(); Speech.speakPurge("Action Based Question"); Speech.speakNormal(q.QuestionText); } } else if (e.Key == Key.D1 || e.Key == Key.NumPad1) { Speech.speakPurge(null); option0.IsChecked = true; } else if (e.Key == Key.D2 || e.Key == Key.NumPad2) { Speech.speakPurge(null); option1.IsChecked = true; } else if (e.Key == Key.D3 || e.Key == Key.NumPad3) { Speech.speakPurge(null); option2.IsChecked = true; } else if (e.Key == Key.D4 || e.Key == Key.NumPad4) { Speech.speakPurge(null); option3.IsChecked = true; } else if (e.Key == Key.D5 || e.Key == Key.NumPad5) { Speech.speakPurge(null); option0.IsChecked = false; option1.IsChecked = false; option2.IsChecked = false; option3.IsChecked = false; } else if (e.Key == Key.C && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.changeVoice(); } }
private void createButton_Click(object sender, RoutedEventArgs e) { try { Candidate c = (Candidate)usersListView.SelectedItem; System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Document doc = new Document(PageSize.A4, 72, 72, 72, 72); PdfWriter.GetInstance(doc, new FileStream(System.IO.Path.Combine(fbd.SelectedPath, c.UserName + "_CTVIAT_Report.pdf"), FileMode.Create)); doc.Open(); Paragraph p1 = new Paragraph(c.UserName); p1.Font.Size = 24; p1.Font.SetStyle(Font.ITALIC); doc.Add(p1); ArrayList tests = SQLManager.getAllTestsOfCandidate(c.UserID); if (tests.Count == 0) { doc.Add(new Paragraph("Candidate didn't solve any tests")); } else { int i = 1; foreach (Test t in tests) { String testInfo = "TEST " + i + "\nTEST ID: " + t.TestID + "\nTEST SUBJECT: " + t.Subject + "\nTEST DATE: " + t.Date + "\nTEST TAKE ORDER: " + t.TakeOrder + "\nTEST TIME: "; int time = t.Time; if (time / 3600 > 0) { if (time / 3600 == 1) { testInfo = testInfo + time / 3600 + " hour"; } else { testInfo = testInfo + time / 3600 + " hours"; } } if (time % 3600 / 60 > 0) { if (time % 3600 / 60 == 1) { testInfo = testInfo + time % 3600 / 60 + " minute"; } else { testInfo = testInfo + time % 3600 / 60 + " minutes"; } } if (time % 60 == 1) { testInfo = testInfo + time % 60 + " second\n"; } else { testInfo = testInfo + time % 60 + " seconds\n"; } if (t.IsNew) { testInfo = testInfo + "TEST COMPLETENESS: COMPLETED\n"; } else { testInfo = testInfo + "TEST COMPLETENESS: INCOMPLETED\nTEST START QUESTION NO: " + t.StartQuestionNo + "\n"; } Paragraph p = new Paragraph(testInfo); p.Font.SetStyle(Font.BOLD); doc.Add(p); foreach (Question q in t.Questions) { String questionInfo = "QUESTION\n" + q.QuestionText + "\nCANDIDATE ANSWER\n"; if (q is ObjectiveQuestion) { ObjectiveQuestion oq = (ObjectiveQuestion)q; if (oq.Submitted != null) { questionInfo = questionInfo + oq.Choices[oq.Submitted.Answer - 1] + "\n"; } else { questionInfo = questionInfo + "Candidate didn't answer the question\n"; } } else if (q is DescriptiveQuestion) { DescriptiveQuestion dq = (DescriptiveQuestion)q; if (dq.Submitted != null) { questionInfo = questionInfo + dq.Submitted.Answer; } else { questionInfo = questionInfo + "Candidate didn't answer the question\n"; } } else { ActionBasedQuestion aq = (ActionBasedQuestion)q; if (aq.Submitted != null) { questionInfo = questionInfo + "Candidate answered the question correctly"; } else { questionInfo = questionInfo + "Candidate didn't answer the question\n"; } } Paragraph questionParagraph = new Paragraph(questionInfo); doc.Add(questionParagraph); } i++; } } doc.Close(); MessageBox.Show("Report Creation is successful\n", "Report Creation", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { MessageBox.Show("Report Creation is failed\n" + ex.Message, "Report Creation", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Window_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.N && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge(null); nextButton_Click(null, null); } else if (e.Key == Key.B && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge(null); backButton_Click(null, null); } else if (e.Key == Key.R && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { if (solver.getCurrentQuestion() is ObjectiveQuestion) { ObjectiveQuestion q = (ObjectiveQuestion)solver.getCurrentQuestion(); Speech.speakPurge("Objective Question"); Speech.speakNormal(q.QuestionText); Speech.speakNormal("Correct Answer"); Speech.speakNormal(q.Choices[q.Answer.Answer - 1]); if (q.Submitted != null) { Speech.speakNormal("Your Answer"); Speech.speakNormal(q.Choices[q.Submitted.Answer - 1]); } else { Speech.speakNormal("You didn't answer"); } } else if (solver.getCurrentQuestion() is DescriptiveQuestion) { DescriptiveQuestion q = (DescriptiveQuestion)solver.getCurrentQuestion(); Speech.speakPurge("Descriptive Question"); Speech.speakNormal(q.QuestionText); Speech.speakNormal("Correct Answer"); Speech.speakNormal(q.QuestionText); if (q.Submitted != null) { Speech.speakNormal("Your Answer"); Speech.speakNormal(q.Submitted.Answer); } else { Speech.speakNormal("You didn't answer"); } } else { ///action-based here } } else if (e.Key == Key.F && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.speakPurge(null); finishButton_Click(null, null); } else if (e.Key == Key.C && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Speech.changeVoice(); } }