private void clearEnvironment(ActionBasedQuestion q) { try { if (q.Type == 1) { deleteDirectory(q.Parameter1); } else if (q.Type == 2) { deleteFile(q.Parameter1); } else if (q.Type == 3) { deleteDirectory(q.Parameter1); } else if (q.Type == 4) { deleteFile(q.Parameter1); } else if (q.Type == 5) { deleteDirectory(q.Parameter1); deleteDirectory(q.Parameter2); } else if (q.Type == 6) { deleteFile(q.Parameter1); deleteFile(q.Parameter2); } else if (q.Type == 7) { deleteFile("enlightenment_test.txt"); } else if (q.Type == 8) { deleteFile("enlightenment_test.txt"); } } catch { Speech.speakPurgeSync("An error occurred. You will begin from start."); Dispatcher.BeginInvoke((ThreadStart)delegate { new Candidate1(candidate, Subject.None, Freshness.None, Screen.getEmptySeen()).Show(); }, DispatcherPriority.Normal); Dispatcher.BeginInvoke((ThreadStart)delegate { this.Close(); }, DispatcherPriority.Normal); } }
/// <summary> /// show the action-based question by setting window controls and their visibility /// </summary> /// <param name="q">question to be shown</param> private void showActionBasedQuestion(ActionBasedQuestion q) { bool flag = false; questionLabel.Text = q.QuestionText; if (q.Submitted != null) { flag = true; } else { prepareEnvironment(q); } objectiveAnswerGrid.Visibility = Visibility.Hidden; descriptiveAnswerGrid.Visibility = Visibility.Hidden; Speech.speakPurge("Action based question"); if (flag) { Speech.speakNormal("You have already solved this question correctly"); } else { Speech.speakNormal(q.QuestionText); } }
/// <summary> /// To get all questions by filtering with subject and type /// </summary> /// <param name="subject">test subject</param> /// <param name="type">test type</param> /// <returns> /// arraylist of questions with specified subject and type /// </returns> public static ArrayList getAllQuestionsBySubjectAndType(int subject, byte type) { CTVIATBankDataSet.QuestionsDataTable allQuestionsTable = questionsAdapter.GetAllQuestionBySubjectAndType(subject, type); ArrayList questions = new ArrayList(); foreach (DataRow row in allQuestionsTable) { if (row["questionType"].ToString() == "1") { 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 (row["questionType"].ToString() == "2") { 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 { 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> /// to add actipn-based question /// </summary> /// <param name="question">action-based question object to be added</param> public static void addActionBasedQuestion(ActionBasedQuestion question) { questionsAdapter.InsertQuestion(3, question.QuestionText, null, null, null, null, null, null, question.QuestionSubject, question.Type, question.Parameter1, question.Parameter2); }
private void showActionBasedQuestionAndAnswer(ActionBasedQuestion q) { questionLabel.Text = q.QuestionText; correctAnswerLabel.Text = "Correct Answer isn't given for action based questions"; Speech.speakPurge("Action Based Question"); Speech.speakNormal(q.QuestionText); if (q.Submitted != null) { submittedAnswerLabel.Text = "You answered correctly"; Speech.speakNormal("You answered correctly"); } else { submittedAnswerLabel.Text = "You didn't answer or answered wrong"; Speech.speakNormal("You didn't answer or answered wrong"); } }