public IActionResult OnPost(List <Answer> answers, QuestionTypeID QuestionTypeID, int TestID) { Results = new List <double>(); Test = ApTestData.GetTestByID(TestID); AppUser appUser = new AppUser { Email = User.Identity.Name, }; ApTestData.SaveAnswerAttempt(answers, appUser, Test); if (answers.Count > 0) { ApTestData.Commit(); } switch (QuestionTypeID) { case QuestionTypeID.Written_and_Verbal_Reasoning: { TempData["Section1ResultString"] = ApTestData.CalculateCorrectAnswers(answers, appUser, QuestionTypeID, Questions.Count, Test).ToString(); return(RedirectToPage("./TestSectionHome/", new { TestID, QuestionTypeID = QuestionTypeID.Diagrammatic_Reasoning })); } case QuestionTypeID.Diagrammatic_Reasoning: { TempData["Section2ResultString"] = ApTestData.CalculateCorrectAnswers(answers, appUser, QuestionTypeID, Questions.Count, Test).ToString(); return(RedirectToPage("./TestSectionHome/", new { TestID, QuestionTypeID = QuestionTypeID.Symbolic_Manipulation })); } case QuestionTypeID.Symbolic_Manipulation: { TempData["Section3ResultString"] = ApTestData.CalculateCorrectAnswers(answers, appUser, QuestionTypeID, Questions.Count, Test).ToString(); Results.Add(Double.Parse(TempData["Section1ResultString"].ToString())); Results.Add(Double.Parse(TempData["Section2ResultString"].ToString())); Results.Add(Double.Parse(TempData["Section3ResultString"].ToString())); ApTestData.SaveTestResults(Results, TestID, appUser); ApTestData.Commit(); return(RedirectToPage("./TestComplete/")); } default: { return(Page()); } } }
public FileContentResult DownloadResultsDataToCSV() { TestAttempts = ApTestData.GetTestAttempts(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("AppUserID,TestName,WrittenAndVerbalReasoningScore,DiagrammaticReasoningScore,SymbolicManipulationScore,Pass\n"); foreach (var testAttempt in TestAttempts) { stringBuilder.Append(testAttempt.AppUserID + ","); stringBuilder.Append(GetTestName(testAttempt.TestID) + ","); stringBuilder.Append(testAttempt.Section1Result.ToString() + ","); stringBuilder.Append(testAttempt.Section2Result.ToString() + ","); stringBuilder.Append(testAttempt.Section3Result.ToString() + ","); stringBuilder.Append(testAttempt.IsPass.ToString() + "\n"); } return(File(Encoding.UTF8.GetBytes(stringBuilder.ToString()), "text/csv", "UserResults.csv")); }
public string GetTestName(int testID) { var test = ApTestData.GetTestByID(testID); return(test.TestName); }
public void OnGet() { AppUsers = ApTestData.GetAllAppUsers(); Tests = ApTestData.GetTests(); TestAttempts = ApTestData.GetTestAttempts(); }
public void OnGet(QuestionTypeID QuestionTypeID, int TestID) { Test = ApTestData.GetTestByID(TestID); this.QuestionTypeID = QuestionTypeID; this.TestCategoryTitle = QuestionTypeID.GetTestCategoryTitle(); }
public void OnGet() { Tests = ApTestData.GetTestIDForLoggedInApplicant(User.Identity.Name); Questions = ApTestData.GetQuestionsAndAnswers(); }
public void OnGet(QuestionTypeID QuestionTypeID, int TestID) { Questions = ApTestData.GetQuestionListForTestByQuestionType(TestID, QuestionTypeID); Test = ApTestData.GetTestByID(TestID); this.TestCategoryTitle = QuestionTypeID.GetTestCategoryTitle(); }