public double GetFinalGrade(bool includeExtraCredit) { if (this.AccessLevel != 1) { throw new Exception("Only Students have Final Grades."); } double finalgrade = 0.0; double coursTermPoints = 0.0; double courseTermMaxPoints = 0.0; AssessTrackDataRepository repo = new AssessTrackDataRepository(); foreach (AssessmentType asmtType in this.CourseTerm.AssessmentTypes.Where(type => !type.QuestionBank)) { GradeSection section = new GradeSection(asmtType, this.Profile,repo,includeExtraCredit); if (section.Weight > 0) { coursTermPoints += ((section.TotalPoints / section.MaxPoints) * asmtType.Weight); courseTermMaxPoints += section.Weight; } } finalgrade = ((coursTermPoints / courseTermMaxPoints) * 100); if (finalgrade >= 0) { return finalgrade; } return 0.0; }
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); }