public void BuildCompiledQuestionsResult(TblQuestions q, int userId) { var compiledQuestion = ServerModel.DB.Load <TblCompiledQuestions>((int)q.CompiledQuestionRef); var answersForCurrentUser = StudentRecordFinder.GetUserAnswersForQuestion(q, userId); SetHeader(q.TestName, compiledQuestion); SetTableHeader(); if (answersForCurrentUser != null && answersForCurrentUser.Count != 0) { var lastUserAnswer = FindLatestUserAnswer(answersForCurrentUser); var compileAnswer = StudentRecordFinder.GetCompiledAnswersForAnswer(lastUserAnswer); if (compileAnswer != null && compileAnswer.Count != 0) { SetResults(compileAnswer); } else { SetNoResultStatus(q); } } else { SetNoResultStatus(q); } }
private static ResultStatus GetCompiledStatus(TblUserAnswers answer) { var userCompiledAnswers = StudentRecordFinder.GetCompiledAnswersForAnswer(answer); bool allAcepted = true; if (userCompiledAnswers.Count != 0) { foreach (var compiledAnswer in userCompiledAnswers) { if (compiledAnswer.StatusRef == (int)Status.Enqueued) { return(ResultStatus.Enqueued); } allAcepted &= (compiledAnswer.StatusRef == (int)Status.Accepted); } return(allAcepted ? ResultStatus.Pass : ResultStatus.Fail); } else { return(ResultStatus.Fail); } }
private void SetResults(IList <TblUserAnswers> userAnswers) { var compileAnswer = StudentRecordFinder.GetCompiledAnswersForAnswer(FindLatestUserAnswer(userAnswers)); foreach (var ca in compileAnswer) { SetTestCaseResult(StudentRecordFinder.GetCompiledQuestionDataForCompiledAnswer(ca), ca); } }