/// <summary> /// filter tests by subject /// </summary> /// <param name="candidateID">to set take orders for each test</param> /// <param name="subject">subject for filtering</param> /// <returns> /// arraylist of tests /// </returns> public static ArrayList getAllTestsBySubject(int candidateID, int subject) { CTVIATBankDataSet.TestsDataTable testTable = testsAdapter.GetAllTestsBySubject(subject); ArrayList tests = new ArrayList(); foreach (DataRow row in testTable.Rows) { int testId = Convert.ToByte(row["testID"]); CTVIATBankDataSet.QuestionsTestsDataTable questionsTable = questionsTestsAdapter.GetQuestionsOfTest(testId); Queue <Question> queue = new Queue <Question>(); foreach (DataRow r in questionsTable.Rows) { queue.Enqueue(getQuestionById(Convert.ToInt32(r["questionID"]))); } CTVIATBankDataSet.TestsTakeOrderDataTable table = testsTakeOrderAdapter.GetTakeOrder(candidateID, testId); int takeOrder = 0; if (table.Rows.Count > 0) { takeOrder = Convert.ToInt32(table.Rows[0]["takeOrder"]); } tests.Add(new Test(testId, queue.ToArray(), subject, takeOrder, 0, true, 0, DateTime.Now)); } return(tests); }
/// <summary> /// used to get all tests that are solved by candidate (complete + incomplete) /// </summary> /// <param name="candidateID">for which candidate</param> /// <returns> /// arraylist of tests /// </returns> public static ArrayList getAllTestsOfCandidate(int candidateID) { CTVIATBankDataSet.TestsTakeOrderDataTable table = testsTakeOrderAdapter .GetAllTestAndTakeOrderOfCandidate(candidateID); ArrayList tests = new ArrayList(); foreach (DataRow row in table) { int testID = Convert.ToInt32(row["testID"]); int maxTakeOrder = Convert.ToInt32(row["takeOrder"]); int subject = Convert.ToInt32(testsAdapter.GetTestByID(testID)[0]["testSubject"]); for (int i = 1; i <= maxTakeOrder; i++) { CTVIATBankDataSet.IncompleteTestsCandidatesDataTable incompleteTable = incompleteTestsAdapter.GetStartQuestionNo(candidateID, testID, i); bool isNew = true; int startQuestionNo = 0; if (incompleteTable.Rows.Count > 0) { isNew = false; startQuestionNo = Convert.ToInt32(incompleteTable.Rows[0]["questionID"]); } int time = Convert.ToInt32(testsTimeAdapter .GetTime(candidateID, testID, i)[0]["time"]); DateTime date = Convert.ToDateTime(testsTimeAdapter .GetTime(candidateID, testID, i)[0]["date"]); Test test = new Test(testID, getQuestionsOfTest(testID), subject, i, time, isNew, startQuestionNo, date); getAnswersOfTest(candidateID, test); tests.Add(test); } } return(tests); }