Feel free to try the solution below:
Go to /Controllers/StudentExamController.cs
Go to this function: public IQueryable<ExamViewModel> ReadStudentExams(string status)
Edit the code inside else if (status == "past")
, change it to:
else if (status == "past")
{
list = (from t1 in db.Exams.AsNoTracking()
join t2 in db.StudentExams on t1.Id equals t2.ExamId
let totalQuestion = db.ExamQuestions.Where(a => a.ExamId == t1.Id).Count()
where (t1.StartDate <= now && t1.EndDate <= now)
&& t2.StartedOn != null && t2.StudentId == currentUserId
select new ExamViewModel
{
Id = t1.Id,
Name = t1.Name,
Duration = t1.Duration,
StartDate = t2.StartedOn,
StartDateIsoUtc = t2.IsoUtcStartedOn,
EndDate = t2.EndedOn,
EndDateIsoUtc = t2.IsoUtcEndedOn,
StudentExamStatus = "Past",
TotalQuestions = totalQuestion,
Result = t2.Result ?? 0
}).Distinct();
}
Done! Hope it helps. Thank you.