Ejemplo n.º 1
0
        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!");
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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;
     }
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public IActionResult Index()
        {
            var exams = examRepository.GetAll().Where(p => p.RecordStatus == Entities.RecordStatus.A).ToList();

            return(View(exams));
        }
Ejemplo n.º 6
0
 public IEnumerable <dynamic> GetAll()
 {
     return(_examRepository.GetAll());
 }
Ejemplo n.º 7
0
        public IEnumerable <Exam> GetExams()
        {
            var exams = examRepository.GetAll();

            return(exams);
        }
Ejemplo n.º 8
0
 public ICollection <Exam> GetAllExams()
 {
     return(_repository.GetAll());
 }
Ejemplo n.º 9
0
 public IEnumerable <Exam> GetAll()
 {
     return(examRepository.GetAll());
 }
Ejemplo n.º 10
0
 public List <Exam> GetAll()
 {
     return(_examRepository.GetAll());
 }