From 1b93dd122e667049835c2860a662e8ba200d35ad Mon Sep 17 00:00:00 2001 From: cahrens Date: Fri, 24 Jul 2015 12:52:56 -0400 Subject: [PATCH] Sort the grade cutoffs. TNL-2848 --- .../tests/views/test_instructor_dashboard.py | 11 ++++++++++- .../instructor/views/instructor_dashboard.py | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py index 3694308b45..1b4af21ef8 100644 --- a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py +++ b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py @@ -33,7 +33,9 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase): Set up tests """ super(TestInstructorDashboard, self).setUp() - self.course = CourseFactory.create() + self.course = CourseFactory.create( + grading_policy={"GRADE_CUTOFFS": {"A": 0.75, "B": 0.63, "C": 0.57, "D": 0.5}} + ) self.course_mode = CourseMode(course_id=self.course.id, mode_slug="honor", @@ -234,3 +236,10 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase): expected_result, 'CCX Coaches are able to create their own Custom Courses based on this course' in response.content ) + + def test_grade_cutoffs(self): + """ + Verify that grade cutoffs are displayed in the correct order. + """ + response = self.client.get(self.url) + self.assertIn('D: 0.5, C: 0.57, B: 0.63, A: 0.75', response.content) diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 1e454a6652..9363f98406 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -349,8 +349,9 @@ def _section_course_info(course, access): section_data['detailed_gitlogs_url'] = reverse('gitlogs_detail', kwargs={'course_id': unicode(course_key)}) try: + sorted_cutoffs = sorted(course.grade_cutoffs.items(), key=lambda i: i[1], reverse=True) advance = lambda memo, (letter, score): "{}: {}, ".format(letter, score) + memo - section_data['grade_cutoffs'] = reduce(advance, course.grade_cutoffs.items(), "")[:-2] + section_data['grade_cutoffs'] = reduce(advance, sorted_cutoffs, "")[:-2] except Exception: # pylint: disable=broad-except section_data['grade_cutoffs'] = "Not Available" # section_data['offline_grades'] = offline_grades_available(course_key)