Table Of Contents

Getting Started

How to use ExamEase

Change Log

Requirement

Setup & Configuration

Technical Information

Code Editing

FAQ

Credits

FAQ > Error when student didn’t click the Exit Exam button

Solution will be included in next update, for now, you can solve the bug by follow the steps below:


Bug description: Null exception error occurred when student didn’t click the Exit Exam button.

  1. Open ResultController in Visual Studio

  2. Go to GetResultViewModel method, replace the code with the following:

    [Authorize(Roles = "System Admin, Teacher, Student")]
    public ResultViewModel GetResultViewModel(string eId, string sId, StudentExam studentExam, int? totalQuestion = 0)
    {
        ResultViewModel model = new ResultViewModel();
        model.ExamId = eId;
        model.StudentId = sId;
        var exam = db.Exams.Where(a => a.Id == eId).Select(a => new { MarkToPass = a.MarksToPass, ExamName = a.Name, ReleaseAnswer = a.ReleaseAnswer, StartDate = a.StartDate, Duration = a.Duration }).FirstOrDefault();
        decimal? scoreToPass = exam?.MarkToPass;
        model.ExamName = exam?.ExamName;
        model.ReleaseAnswer = exam?.ReleaseAnswer ?? false;
        model.TotalQuestions = (totalQuestion == null || totalQuestion == 0) ? db.ExamQuestions.Where(a => a.ExamId == eId).Count() : totalQuestion;
        model.StudentName = db.UserProfiles.Where(a => a.AspNetUserId == sId).Select(a => a.FullName).FirstOrDefault();
        model.TotalScore = (from t1 in db.ExamQuestions
                            where t1.ExamId == eId
                            select t1.Mark).Sum();
        model.AnsweredCorrect = db.StudentAnswerCloneds.Where(a => a.StudentId == sId && a.ExamId == eId && a.MarksObtained > 0).Count();
        model.ScoreToPass = scoreToPass;
        if (studentExam == null)
        {
            studentExam = new StudentExam();
        }
        model.YourScore = studentExam.Result ?? db.StudentAnswerCloneds.Where(a => a.StudentId == sId && a.ExamId == eId && a.MarksObtained > 0).Select(a => a.MarksObtained).Sum();
        model.Passed = studentExam.Passed ?? (model.YourScore >= model.ScoreToPass) ? true : false;
        model.StartDateTime = studentExam.IsoUtcStartedOn ?? "";
        model.EndDateTime = studentExam.IsoUtcEndedOn ?? "";
        studentExam.StartedOn = (studentExam.StartedOn == null) ? exam.StartDate : studentExam.StartedOn;
        if (studentExam.EndedOn != null && studentExam.StartedOn != null)
        {
            model.TimeTaken = Math.Round((studentExam.EndedOn - studentExam.StartedOn).Value.TotalMinutes, 2).ToString();
        }
        else
        {
            model.TimeTaken = exam.Duration.ToString();
        }
        return model;
    }