示例#1
0
        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());
            }
            }
        }
示例#2
0
        public string GetTestName(int testID)
        {
            var test = ApTestData.GetTestByID(testID);

            return(test.TestName);
        }
 public void OnGet(QuestionTypeID QuestionTypeID, int TestID)
 {
     Test = ApTestData.GetTestByID(TestID);
     this.QuestionTypeID    = QuestionTypeID;
     this.TestCategoryTitle = QuestionTypeID.GetTestCategoryTitle();
 }
示例#4
0
 public void OnGet(QuestionTypeID QuestionTypeID, int TestID)
 {
     Questions = ApTestData.GetQuestionListForTestByQuestionType(TestID, QuestionTypeID);
     Test      = ApTestData.GetTestByID(TestID);
     this.TestCategoryTitle = QuestionTypeID.GetTestCategoryTitle();
 }