diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py index 0529a27bef..b1ce6d43e2 100644 --- a/lms/djangoapps/courseware/grades.py +++ b/lms/djangoapps/courseware/grades.py @@ -839,7 +839,7 @@ def _calculate_score_for_modules(user_id, course, modules): # Iterate over all of the exam modules to get score percentage of user for each of them module_percentages = [] - ignore_categories = ['course', 'chapter', 'sequential', 'vertical', 'randomize'] + ignore_categories = ['course', 'chapter', 'sequential', 'vertical', 'randomize', 'library_content'] for index, module in enumerate(modules): if module.category not in ignore_categories and (module.graded or module.has_score): module_score = scores_client.get(locations[index]) diff --git a/lms/djangoapps/courseware/tests/test_grades.py b/lms/djangoapps/courseware/tests/test_grades.py index 5fce957284..c62657347e 100644 --- a/lms/djangoapps/courseware/tests/test_grades.py +++ b/lms/djangoapps/courseware/tests/test_grades.py @@ -366,13 +366,19 @@ class TestGetModuleScore(LoginEnrollmentTestCase, SharedModuleStoreTestCase): cls.seq1 = ItemFactory.create( parent=cls.chapter, category='sequential', - display_name="Test Sequential", + display_name="Test Sequential 1", graded=True ) cls.seq2 = ItemFactory.create( parent=cls.chapter, category='sequential', - display_name="Test Sequential", + display_name="Test Sequential 2", + graded=True + ) + cls.seq3 = ItemFactory.create( + parent=cls.chapter, + category='sequential', + display_name="Test Sequential 3", graded=True ) cls.vert1 = ItemFactory.create( @@ -385,11 +391,21 @@ class TestGetModuleScore(LoginEnrollmentTestCase, SharedModuleStoreTestCase): category='vertical', display_name='Test Vertical 2' ) + cls.vert3 = ItemFactory.create( + parent=cls.seq3, + category='vertical', + display_name='Test Vertical 3' + ) cls.randomize = ItemFactory.create( parent=cls.vert2, category='randomize', display_name='Test Randomize' ) + cls.library_content = ItemFactory.create( + parent=cls.vert3, + category='library_content', + display_name='Test Library Content' + ) problem_xml = MultipleChoiceResponseXMLFactory().build_xml( question_text='The correct answer is Choice 3', choices=[False, False, True, False], @@ -420,6 +436,19 @@ class TestGetModuleScore(LoginEnrollmentTestCase, SharedModuleStoreTestCase): data=problem_xml ) + cls.problem5 = ItemFactory.create( + parent=cls.library_content, + category="problem", + display_name="Test Problem 5", + data=problem_xml + ) + cls.problem6 = ItemFactory.create( + parent=cls.library_content, + category="problem", + display_name="Test Problem 6", + data=problem_xml + ) + def setUp(self): """ Set up test course @@ -485,6 +514,16 @@ class TestGetModuleScore(LoginEnrollmentTestCase, SharedModuleStoreTestCase): score = get_module_score(self.request.user, self.course, self.seq2) self.assertEqual(score, 1.0) + def test_get_module_score_with_library_content(self): + """ + Test test_get_module_score_with_library_content + """ + answer_problem(self.course, self.request, self.problem5) + answer_problem(self.course, self.request, self.problem6) + + score = get_module_score(self.request.user, self.course, self.seq3) + self.assertEqual(score, 1.0) + def answer_problem(course, request, problem, score=1): """