public void PublishGrades(int examId) { var selectedExam = _examRepository.GetById(examId); if (selectedExam == null) { throw new ArgumentOutOfRangeException(); } if (!selectedExam.Started) { throw new ArgumentOutOfRangeException(); } if (!selectedExam.Finished) { throw new ArgumentOutOfRangeException(); } selectedExam.GradesPublished = true; foreach (var student in _studentRepository.GetAll()) { foreach (var course in _courseRepository.GetAll()) { if (student.StudyYear != course.StudyYear) { continue; } foreach (var exam in _examRepository.GetAll()) { if (exam.CourseId != course.Id || exam.Id != examId) { continue; } foreach (var grade in _gradeRepostory.GetAll()) { if (grade.ExamId != exam.Id || grade.StudentId != student.Id) { continue; } _mailService.SendEmail(student.Email, $"Your grade on {course.Title}", $"Your paper has been graded with {grade.GradeValue} points!"); } } } } }
public List <ExamModel> GetAllExamsByTeacherId(int teacherId) { var allExamsOfTeacher = _examRepo.GetAll().Where(e => e.UserId == teacherId).ToList(); var examModel = new List <ExamModel>(); if (allExamsOfTeacher != null) { for (int i = 0; i < allExamsOfTeacher.Count; i++) { examModel.Add(new ExamModel { ExamId = allExamsOfTeacher[i].Id, WiredTypingTitle = allExamsOfTeacher[i].WiredTypingTitle.ToString(), WiredTypingContent = allExamsOfTeacher[i].WiredTypingContent.ToString(), UserId = Convert.ToInt32(allExamsOfTeacher[i].UserId), Questions = new List <QuestionModel>(), CreateDate = allExamsOfTeacher[i].CreateDate }); } for (int j = 0; j < examModel.Count; j++) { for (int k = 0; k < allExamsOfTeacher[j].Questions.Count; k++) { examModel[j].Questions.Add(new QuestionModel { QuestionId = allExamsOfTeacher[j].Questions[k].Id, QuestionText = allExamsOfTeacher[j].Questions[k].QuestionText, Choice_A = allExamsOfTeacher[j].Questions[k].Choice_A, Choice_B = allExamsOfTeacher[j].Questions[k].Choice_B, Choice_C = allExamsOfTeacher[j].Questions[k].Choice_C, Choice_D = allExamsOfTeacher[j].Questions[k].Choice_D, CorrectChoice = allExamsOfTeacher[j].Questions[k].CorrectChoice }); } } return(examModel); } else { examModel = null; return(examModel); } }
public List <ExamModel> GetAllExam() { try { return(examRepository.GetAll()); } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <ExamResult> > GetAll() { if (answerRepository.IsUserLocked(User.Identity.Name)) { return(Enumerable.Empty <ExamResult>()); } string language = Request.GetLanguage(config.DefaultLocalization); var enabledExams = examRepository.GetAll(language).Visible().ToList(); var examResults = enabledExams.Select(exam => ExamResult.FromEntity(exam, language)).ToList(); foreach (var examResult in examResults) { var answers = await answerRepository.GetAll(User.Identity.Name, examResult.Id); examResult.SetScore(answers); if (examResult.IsNewlyCompleted) { statistics.LogExamCompleted(User.Identity.Name, User.Identity.Token(HttpContext), examResult.Id, examResult.Score ?? 0m); } } return(examResults); }
public IActionResult Index() { var exams = examRepository.GetAll().Where(p => p.RecordStatus == Entities.RecordStatus.A).ToList(); return(View(exams)); }
public IEnumerable <dynamic> GetAll() { return(_examRepository.GetAll()); }
public IEnumerable <Exam> GetExams() { var exams = examRepository.GetAll(); return(exams); }
public ICollection <Exam> GetAllExams() { return(_repository.GetAll()); }
public IEnumerable <Exam> GetAll() { return(examRepository.GetAll()); }
public List <Exam> GetAll() { return(_examRepository.GetAll()); }