diff --git a/lms/djangoapps/courseware/tests/test_entrance_exam.py b/lms/djangoapps/courseware/tests/test_entrance_exam.py index ae1fd8622a..3d9dd1e810 100644 --- a/lms/djangoapps/courseware/tests/test_entrance_exam.py +++ b/lms/djangoapps/courseware/tests/test_entrance_exam.py @@ -316,6 +316,28 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase): self.assertEqual(resp.status_code, 200) self.assertIn('To access course materials, you must score', resp.content) + def test_entrance_exam_requirement_message_with_correct_percentage(self): + """ + Unit Test: entrance exam requirement message should be present in response + and percentage of required score should be rounded as expected + """ + minimum_score_pct = 29 + self.course.entrance_exam_minimum_score_pct = float(minimum_score_pct) / 100 + modulestore().update_item(self.course, self.request.user.id) # pylint: disable=no-member + url = reverse( + 'courseware_section', + kwargs={ + 'course_id': unicode(self.course.id), + 'chapter': self.entrance_exam.location.name, + 'section': self.exam_1.location.name + } + ) + resp = self.client.get(url) + self.assertEqual(resp.status_code, 200) + self.assertIn('To access course materials, you must score {required_score}% or higher'.format( + required_score=minimum_score_pct + ), resp.content) + def test_entrance_exam_requirement_message_hidden(self): """ Unit Test: entrance exam message should not be present outside the context of entrance exam subsection. diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index bb6f91885e..78d825dfdf 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -202,14 +202,14 @@ ${fragment.foot_html()}

${_('To access course materials, you must score {required_score}% or higher on this \ exam. Your current score is {current_score}%.').format( - required_score=int(course.entrance_exam_minimum_score_pct * 100), - current_score=int(entrance_exam_current_score * 100) + required_score=int(round(course.entrance_exam_minimum_score_pct * 100)), + current_score=int(round(entrance_exam_current_score * 100)) )}

% else:

${_('Your score is {current_score}%. You have passed the entrance exam.').format( - current_score=int(entrance_exam_current_score * 100) + current_score=int(round(entrance_exam_current_score * 100)) )}

% endif