Refactor and add tests for new grade report.

* Handle grading errors
This commit is contained in:
Daniel Friedman
2015-05-05 17:55:55 +00:00
committed by Diana Huang
parent 84f3c33df7
commit 3acd7a008c
19 changed files with 425 additions and 286 deletions

View File

@@ -229,7 +229,13 @@ def _grade(student, request, course, keep_raw_scores):
graded = False
scores.append(
Score(correct, total, graded, module_descriptor.display_name_with_default, module_descriptor.location)
Score(
correct,
total,
graded,
module_descriptor.display_name_with_default,
module_descriptor.location
)
)
_, graded_total = graders.aggregate_scores(scores, section_name)

View File

@@ -68,7 +68,7 @@ class TestGradeIteration(ModuleStoreTestCase):
def test_all_empty_grades(self):
"""No students have grade entries"""
all_gradesets, all_errors = self._gradesets_and_errors_for(self.course.id, self.students, keep_raw_scores=True)
all_gradesets, all_errors = self._gradesets_and_errors_for(self.course.id, self.students)
self.assertEqual(len(all_errors), 0)
for gradeset in all_gradesets.values():
self.assertIsNone(gradeset['grade'])
@@ -107,7 +107,7 @@ class TestGradeIteration(ModuleStoreTestCase):
self.assertTrue(all_gradesets[student5])
################################# Helpers #################################
def _gradesets_and_errors_for(self, course_id, students, keep_raw_scores=False):
def _gradesets_and_errors_for(self, course_id, students):
"""Simple helper method to iterate through student grades and give us
two dictionaries -- one that has all students and their respective
gradesets, and one that has only students that could not be graded and
@@ -115,7 +115,7 @@ class TestGradeIteration(ModuleStoreTestCase):
students_to_gradesets = {}
students_to_errors = {}
for student, gradeset, err_msg in iterate_grades_for(course_id, students, keep_raw_scores):
for student, gradeset, err_msg in iterate_grades_for(course_id, students):
students_to_gradesets[student] = gradeset
if err_msg:
students_to_errors[student] = err_msg