public ActionResult StudentPerformance(string courseTermShortName, string siteShortName, Guid id /*ProfileID*/) { Profile profile = dataRepository.GetProfileByID(id); double totalWeight = 0; if (profile == null) return View("ProfileNotFound"); if (!AuthHelper.IsCurrentStudentOrUserIsAdmin(courseTerm, id)) { return View("NotAuthorized"); } List<GradeSection> sections = new List<GradeSection>(); foreach (AssessmentType type in dataRepository.GetNonTestBankAssessmentTypes(courseTerm)) { GradeSection section = new GradeSection(type, profile,dataRepository,true); totalWeight += section.Weight; sections.Add(section); } PerformanceReportModel model = new PerformanceReportModel(sections, profile); model.TotalWeight = totalWeight; CourseTermMember member = dataRepository.GetCourseTermMemberByMembershipID(courseTerm, id); model.FinalGrade = member.GetFinalGrade(); model.FinalLetterGrade = member.GetFinalLetterGrade(); //student performance report DateTime now = DateTime.Now; DateTime snapshot = courseTerm.Term.StartDate.AddDays(21); Double grade; StudentGradeDistribution gd = new StudentGradeDistribution(); while (snapshot.CompareTo(now) < 0) { grade = member.GetGradeByDate(true, snapshot); gd.AddGrade(grade, snapshot); snapshot = snapshot.AddDays(7); } if (gd != null) { model.chartUrl = GetChartUrl(gd); } List<CourseTermMember> students = dataRepository.GetStudentsInCourseTerm(courseTerm); int currentStudentIndex = students.IndexOf(member); if (currentStudentIndex > 0) { model.PreviousStudent = students[currentStudentIndex - 1].Profile; } else if (currentStudentIndex == 0) { model.PreviousStudent = students[students.Count - 1].Profile; } if (currentStudentIndex < students.Count - 1) { model.NextStudent = students[currentStudentIndex + 1].Profile; } else if (currentStudentIndex == students.Count - 1) { model.NextStudent = students[0].Profile; } return View(model); }
public ActionResult StudentPerformance(string courseTermShortName, string siteShortName, Guid id /*ProfileID*/) { Profile profile = dataRepository.GetProfileByID(id); double totalWeight = 0; if (profile == null) return View("ProfileNotFound"); if (!AuthHelper.IsCurrentStudentOrUserIsAdmin(courseTerm, id)) { return View("NotAuthorized"); } List<GradeSection> sections = new List<GradeSection>(); foreach (AssessmentType type in dataRepository.GetNonTestBankAssessmentTypes(courseTerm)) { GradeSection section = new GradeSection(type, profile,dataRepository,true); totalWeight += section.Weight; sections.Add(section); } PerformanceReportModel model = new PerformanceReportModel(sections, profile); model.TotalWeight = totalWeight; CourseTermMember member = dataRepository.GetCourseTermMemberByMembershipID(courseTerm, id); model.FinalGrade = member.GetFinalGrade(); model.FinalLetterGrade = member.GetFinalLetterGrade(); List<CourseTermMember> students = dataRepository.GetStudentsInCourseTerm(courseTerm); int currentStudentIndex = students.IndexOf(member); if (currentStudentIndex > 0) { model.PreviousStudent = students[currentStudentIndex - 1].Profile; } else if (currentStudentIndex == 0) { model.PreviousStudent = students[students.Count - 1].Profile; } if (currentStudentIndex < students.Count - 1) { model.NextStudent = students[currentStudentIndex + 1].Profile; } else if (currentStudentIndex == students.Count - 1) { model.NextStudent = students[0].Profile; } return View(model); }