From 6c6a0e47aff61d2ca3f93ad40117e579ca41a856 Mon Sep 17 00:00:00 2001 From: atesker Date: Thu, 26 Sep 2019 11:05:13 -0400 Subject: [PATCH] fixed for production - add get_history EDUCATOR-4696 - put back get_history and update UI add pylint --- lms/djangoapps/grades/models.py | 3 +++ lms/djangoapps/grades/tests/test_models.py | 4 +++- lms/templates/courseware/progress.html | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/grades/models.py b/lms/djangoapps/grades/models.py index 9411712c29..6fed1d8abf 100644 --- a/lms/djangoapps/grades/models.py +++ b/lms/djangoapps/grades/models.py @@ -689,6 +689,9 @@ class PersistentSubsectionGradeOverride(models.Model): u"possible_graded_override: {}".format(self.possible_graded_override), ]) + def get_history(self): + return self.history.all() # pylint: disable=no-member + @classmethod def prefetch(cls, user_id, course_key): get_cache(cls._CACHE_NAMESPACE)[(user_id, str(course_key))] = { diff --git a/lms/djangoapps/grades/tests/test_models.py b/lms/djangoapps/grades/tests/test_models.py index 0537b7fab9..7282fbe4a8 100644 --- a/lms/djangoapps/grades/tests/test_models.py +++ b/lms/djangoapps/grades/tests/test_models.py @@ -319,7 +319,9 @@ class PersistentSubsectionGradeTest(GradesModelTestCase): grade = PersistentSubsectionGrade.update_or_create_grade(**self.params) self.assertEqual(self.params['earned_all'], grade.earned_all) self.assertEqual(self.params['earned_graded'], grade.earned_graded) - + history = override.get_history() + self.assertEqual(1, len(list(history))) + self.assertEqual('+', list(history)[0].history_type) # Any score values that aren't specified should use the values from grade as defaults self.assertEqual(0, override.earned_all_override) self.assertEqual(0, override.earned_graded_override) diff --git a/lms/templates/courseware/progress.html b/lms/templates/courseware/progress.html index 4a75cf9df4..fb8c9e9e78 100644 --- a/lms/templates/courseware/progress.html +++ b/lms/templates/courseware/progress.html @@ -198,7 +198,7 @@ username = get_enterprise_learner_generic_name(request) or student.username

%if section.override is not None: <%last_override_history = section.override.get_history().order_by('created').last()%> - %if (not last_override_history or last_override_history.feature == grades_constants.GradeOverrideFeatureEnum.proctoring) and section.format == "Exam" and earned == 0: + %if (not last_override_history or last_override_history.system == grades_constants.GradeOverrideFeatureEnum.proctoring) and section.format == "Exam" and earned == 0: ${_("Suspicious activity detected during proctored exam review. Exam score 0.")} %else: ${_("Section grade has been overridden.")}