/// <summary> /// Gets header. /// </summary> /// <returns></returns> public List <string> GetHeader() { var exams = examDao.ReadAll(); sessionsCount = exams.Max(x => x.NumberOfSession); List <string> header = new List <string> { "Предмет" }; for (int i = 1; i <= sessionsCount; i++) { header.Add("Сессия " + i); } return(header); }
/// <summary> /// Method for obtaining the necessary data. /// </summary> /// <param name="numberOfSession"></param> /// <returns></returns> public IEnumerable <SessionResultRow> GetResult(int numberOfSession) { var groups = groupDao.ReadAll(); var subjects = subjectDao.ReadAll(); var students = studentDao.ReadAll(); var exams = examDao.ReadAll(); var results = resultDao.ReadAll(); List <SessionResultRow> sessionResults = new List <SessionResultRow>(); foreach (Group cgroup in groups) { var summaryResults = from result in results join exam in exams on result.IdExam equals exam.Id where exam.NumberOfSession == numberOfSession & exam.IdGroup == cgroup.Id select result; var averageMark = summaryResults.Average(r => r.Mark); var minMark = summaryResults.Min(r => r.Mark); var maxMark = summaryResults.Max(r => r.Mark); sessionResults.Add(new SessionResultRow { GroupName = cgroup.Name, AverageMark = averageMark, MinMark = minMark, MaxMark = maxMark }); } return(sessionResults); }
/// <summary> /// Gets data. /// </summary> /// <param name="numberOfSession"></param> /// <returns></returns> public List <AverageExaminator> GetData(int numberOfSession) { var exams = examDao.ReadAll(); var results = resultDao.ReadAll(); var examinators = examinatorDao.ReadAll(); List <AverageExaminator> averageExaminatorList = new List <AverageExaminator>(); foreach (var val in examinators) { var marks = from result in results join exam in exams on result.IdExam equals exam.Id join examinator in examinators on exam.IdExaminator equals examinator.Id where exam.NumberOfSession == numberOfSession where examinator.Id == val.Id select result; var averageResult = marks.Count() != 0 ? marks.Average(x => x.Mark) : 0; averageExaminatorList.Add(new AverageExaminator { ExaminatorName = val.Name, AverageMark = averageResult }); } return(averageExaminatorList); }
/// <summary> /// Gets data. /// </summary> /// <param name="numberOfSession"></param> /// <returns></returns> public List <AverageSpecialty> GetData(int numberOfSession) { var exams = examDao.ReadAll(); var results = resultDao.ReadAll(); var groups = groupDao.ReadAll(); var specialtyL = specialtyDao.ReadAll(); List <AverageSpecialty> averageSpecialtyList = new List <AverageSpecialty>(); foreach (var val in specialtyL) { var marks = from specialty in specialtyL join grp in groups on specialty.Id equals grp.IdSpecialty join exam in exams on grp.Id equals exam.IdGroup join result in results on exam.Id equals result.IdExam where val.Id == specialty.Id where exam.NumberOfSession == numberOfSession select result; var averageResult = marks.Average(x => x.Mark); averageSpecialtyList.Add(new AverageSpecialty { SpecialtyName = val.Name, AverageMark = averageResult }); } return(averageSpecialtyList); }
/// <summary> /// Method for obtaining the necessary data. /// </summary> /// <param name="groupName"></param> /// <param name="numberOfSession"></param> /// <returns></returns> public IEnumerable <StudentResult> GetResult(string groupName, int numberOfSession) { var groups = groupDao.ReadAll(); var subjects = subjectDao.ReadAll(); var students = studentDao.ReadAll(); var exams = examDao.ReadAll(); var results = resultDao.ReadAll(); var groupWithId = groups.FirstOrDefault(x => x.Name == groupName); var sessionResults = from student in students join result in results on student.Id equals result.IdStudent join exam in exams on result.IdExam equals exam.Id join subject in subjects on exam.IdSubject equals subject.Id where student.IdGroup == groupWithId.Id & exam.NumberOfSession == numberOfSession select new StudentResult { FirstName = student.FirstName, MiddleName = student.MiddleName, LastName = student.LastName, DateOfBirth = student.DateOfBirth, Gender = student.Gender, Date = exam.Date, SubjectName = subject.Name, ExamType = exam.Type, Mark = result.Mark }; return(sessionResults); }