diff --git a/lms/djangoapps/courseware/tests/test_submitting_problems.py b/lms/djangoapps/courseware/tests/test_submitting_problems.py index ae1ceec014..2532e67d55 100644 --- a/lms/djangoapps/courseware/tests/test_submitting_problems.py +++ b/lms/djangoapps/courseware/tests/test_submitting_problems.py @@ -313,7 +313,7 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl Returns list of scores for the given homework: [, , ..., ] """ - return [s.earned for s in self.hw_grade(hw_url_name).scores] + return [s.earned for s in self.hw_grade(hw_url_name).problem_scores.values()] class TestCourseGrades(TestSubmittingProblems): @@ -337,7 +337,7 @@ class TestCourseGrades(TestSubmittingProblems): Verifies the problem score and the homework grade are as expected. """ hw_grade = self.hw_grade('homework') - problem_score = hw_grade.scores[0] + problem_score = hw_grade.problem_scores.values()[0] self.assertEquals((problem_score.earned, problem_score.possible), expected_problem_score) self.assertEquals((hw_grade.graded_total.earned, hw_grade.graded_total.possible), expected_hw_grade) diff --git a/lms/djangoapps/gating/tests/test_integration.py b/lms/djangoapps/gating/tests/test_integration.py index 5f8aba1108..8c00bb7565 100644 --- a/lms/djangoapps/gating/tests/test_integration.py +++ b/lms/djangoapps/gating/tests/test_integration.py @@ -151,7 +151,7 @@ class TestGatedContent(MilestonesTestCaseMixin, SharedModuleStoreTestCase): """ course_grade = CourseGradeFactory().create(user, self.course) for prob in [self.gating_prob1, self.gated_prob2, self.prob3]: - self.assertIn(prob.location, course_grade.locations_to_scores) + self.assertIn(prob.location, course_grade.problem_scores) self.assertEquals(course_grade.percent, expected_percent) diff --git a/lms/djangoapps/grades/new/course_grade.py b/lms/djangoapps/grades/new/course_grade.py index a79f435a95..60aed821c6 100644 --- a/lms/djangoapps/grades/new/course_grade.py +++ b/lms/djangoapps/grades/new/course_grade.py @@ -80,15 +80,15 @@ class CourseGradeBase(object): return subsection_grades @lazy - def locations_to_scores(self): + def problem_scores(self): """ Returns a dict of problem scores keyed by their locations. """ - locations_to_scores = {} + problem_scores = {} for chapter in self.chapter_grades.itervalues(): for subsection_grade in chapter['sections']: - locations_to_scores.update(subsection_grade.locations_to_scores) - return locations_to_scores + problem_scores.update(subsection_grade.problem_scores) + return problem_scores def score_for_chapter(self, chapter_key): """ @@ -112,8 +112,8 @@ class CourseGradeBase(object): composite module (a vertical or section ) the scores will be the sums of all scored problems that are children of the chosen location. """ - if location in self.locations_to_scores: - score = self.locations_to_scores[location] + if location in self.problem_scores: + score = self.problem_scores[location] return score.earned, score.possible children = self.course_data.structure.get_children(location) earned, possible = 0.0, 0.0 diff --git a/lms/djangoapps/grades/new/subsection_grade.py b/lms/djangoapps/grades/new/subsection_grade.py index e5a29e7b6b..1d397d7bac 100644 --- a/lms/djangoapps/grades/new/subsection_grade.py +++ b/lms/djangoapps/grades/new/subsection_grade.py @@ -35,11 +35,17 @@ class SubsectionGradeBase(object): self.all_total = None # aggregated grade for all problems, regardless of whether they are graded @property - def scores(self): + def attempted(self): """ - List of all problem scores in the subsection. + Returns whether any problem in this subsection + was attempted by the student. """ - return self.locations_to_scores.values() + + assert self.all_total is not None, ( + "SubsectionGrade not fully populated yet. Call init_from_structure or init_from_model " + "before use." + ) + return self.all_total.attempted class ZeroSubsectionGrade(SubsectionGradeBase): @@ -54,9 +60,9 @@ class ZeroSubsectionGrade(SubsectionGradeBase): self.course_data = course_data @lazy - def locations_to_scores(self): + def problem_scores(self): """ - Overrides the locations_to_scores member variable in order + Overrides the problem_scores member variable in order to return empty scores for all scorable problems in the course. """ @@ -79,7 +85,7 @@ class SubsectionGrade(SubsectionGradeBase): """ def __init__(self, subsection): super(SubsectionGrade, self).__init__(subsection) - self.locations_to_scores = OrderedDict() # dict of problem locations to ProblemScore + self.problem_scores = OrderedDict() # dict of problem locations to ProblemScore def init_from_structure(self, student, course_structure, submissions_scores, csm_scores): """ @@ -91,7 +97,7 @@ class SubsectionGrade(SubsectionGradeBase): ): self._compute_block_score(descendant_key, course_structure, submissions_scores, csm_scores) - self.all_total, self.graded_total = graders.aggregate_scores(self.scores) + self.all_total, self.graded_total = graders.aggregate_scores(self.problem_scores.values()) self._log_event(log.debug, u"init_from_structure", student) return self @@ -180,7 +186,7 @@ class SubsectionGrade(SubsectionGradeBase): block, ) if problem_score: - self.locations_to_scores[block_key] = problem_score + self.problem_scores[block_key] = problem_score def _persisted_model_params(self, student): """ @@ -208,7 +214,7 @@ class SubsectionGrade(SubsectionGradeBase): return [ BlockRecord(location, score.weight, score.raw_possible, score.graded) for location, score in - self.locations_to_scores.iteritems() + self.problem_scores.iteritems() ] def _log_event(self, log_func, log_statement, student): diff --git a/lms/djangoapps/grades/tests/test_grades.py b/lms/djangoapps/grades/tests/test_grades.py index 4b7438b196..a74b582331 100644 --- a/lms/djangoapps/grades/tests/test_grades.py +++ b/lms/djangoapps/grades/tests/test_grades.py @@ -203,7 +203,7 @@ class TestWeightedProblems(SharedModuleStoreTestCase): # verify all problem grades for problem in self.problems: - problem_score = subsection_grade.locations_to_scores[problem.location] + problem_score = subsection_grade.problem_scores[problem.location] self.assertEqual(type(expected_score.first_attempted), type(problem_score.first_attempted)) expected_score.first_attempted = problem_score.first_attempted self.assertEquals(problem_score, expected_score) diff --git a/lms/djangoapps/grades/tests/test_new.py b/lms/djangoapps/grades/tests/test_new.py index 73989db675..69cbaf22bf 100644 --- a/lms/djangoapps/grades/tests/test_new.py +++ b/lms/djangoapps/grades/tests/test_new.py @@ -358,7 +358,7 @@ class ZeroGradeTest(GradeTestBase): chapter_grades = ZeroCourseGrade(self.request.user, course_data).chapter_grades for chapter in chapter_grades: for section in chapter_grades[chapter]['sections']: - for score in section.locations_to_scores.itervalues(): + for score in section.problem_scores.itervalues(): self.assertEqual(score.earned, 0) self.assertEqual(score.first_attempted, None) self.assertEqual(section.all_total.earned, 0) diff --git a/lms/djangoapps/instructor_task/tasks_helper.py b/lms/djangoapps/instructor_task/tasks_helper.py index aebf5f6d77..fc3602e5c5 100644 --- a/lms/djangoapps/instructor_task/tasks_helper.py +++ b/lms/djangoapps/instructor_task/tasks_helper.py @@ -1027,7 +1027,7 @@ def upload_problem_grade_report(_xmodule_instance_args, _entry_id, course_id, _t earned_possible_values = [] for block_location in graded_scorable_blocks: try: - problem_score = course_grade.locations_to_scores[block_location] + problem_score = course_grade.problem_scores[block_location] except KeyError: earned_possible_values.append([u'Not Available', u'Not Available']) else: diff --git a/lms/templates/courseware/progress.html b/lms/templates/courseware/progress.html index ac1ce9343e..017463f81f 100644 --- a/lms/templates/courseware/progress.html +++ b/lms/templates/courseware/progress.html @@ -179,10 +179,10 @@ from django.utils.http import urlquote_plus %endif

- %if len(section.scores) > 0: + %if len(section.problem_scores.values()) > 0:
${ _("Problem Scores: ") if section.graded else _("Practice Scores: ")}
- %for score in section.scores: + %for score in section.problem_scores.values():
${"{0:.3n}/{1:.3n}".format(float(score.earned),float(score.possible))}
%endfor