Exemplo n.º 1
0
        public List <Exam> TeacherFindAllExam(Pagination pagination)
        {
            List <Exam> exams = null;

            try
            {
                exams = examDal.FindNeedUpdateExam();
                double qualifiedCount = 0;
                double examineeCounnt = 0;

                for (int i = 0; i < exams.Count; i++)
                {
                    qualifiedCount = examDal.GetQualifiedCountByExamId(exams[i].Id);
                    examineeCounnt = examDal.GetExamineeCountByExamId(exams[i].Id);
                    double passRate = Math.Round(qualifiedCount / examineeCounnt, 2) * 100;
                    examDal.UpdateAvgPassRate(exams[i].Id, exams[i].ExamAvgScore, passRate);
                }
                pagination.TotalCount = examDal.GetTeacherExamTotalCount(pagination);
                exams = examDal.TeacherFindAllExam(pagination);
            }
            catch (SqlException sqlException)
            {
                log.Error(sqlException.StackTrace);
                throw new FaultException <DBException>(new DBException(), Constants.ServerError);
            }
            return(exams);
        }