public void GetSingleStudentGradeOverview() { // Arrange: string studentSSN = "2233882299"; int courseInstanceID = 1; // Act: StudentGradeOverviewDTO overview = _service.GetSingleStudentGradeOverview(courseInstanceID, studentSSN); // Assert: Assert.IsNotNull(overview); Assert.AreEqual("2233882299", overview.Student.SSN); Assert.AreEqual(2, overview.Grades.Count); }
/// <summary> /// Returns grade overview for every student signed up in course /// </summary> /// <param name="courseInstanceID"></param> /// <returns></returns> public StudentGradeOverviewDTO GetSingleStudentGradeOverview(int courseInstanceID, string studentSSN) { // Fetching the course CourseInstance course = _courseInstances.GetCourseInstanceByID(courseInstanceID); // Fetching the student Person student = _persons.GetStudentBySSN(studentSSN); // Fetching the student course registration StudentRegistration registration = _studentRegistrations.GetCourseStudentByKeys(courseInstanceID, studentSSN); // Preparing the overview StudentGradeOverviewDTO overview = new StudentGradeOverviewDTO(); // Fetching the assignment groups in the course List <AssignmentGroupDTO> courseAssignmentGroups = GetAssignmentGroups(courseInstanceID); // Setting the student in the overview overview.Student = student.GetStudentDTO(); overview.Grades = new List <GradeDTO>(); // For every group, we check if the student has a part in it foreach (AssignmentGroupDTO group in courseAssignmentGroups) { StudentGradeDTO grades = GetStudentGradesInGroup(studentSSN, group.ID); // Adding the grades overview.Grades.AddRange(grades.StudentGrades); // Adding the weight to the final grade if applicable if (group.Weight > 0) { overview.EarnedGrade += Math.Round(CalculateEarnedGroupPercentage(group, grades.StudentGrades), 2); if (grades.StudentGrades.Count > 0) { overview.WeightGraded += group.Weight; } else { overview.WeightUngraded += group.Weight; } } } overview.WeightGraded *= 0.1; overview.WeightUngraded *= 0.1; return(overview); }