Commit 14c31001 by Zia Fazal

minimum score percentage rounded

round before converting a decimal into integer
parent ee0cd9e8
...@@ -316,6 +316,28 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase): ...@@ -316,6 +316,28 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase):
self.assertEqual(resp.status_code, 200) self.assertEqual(resp.status_code, 200)
self.assertIn('To access course materials, you must score', resp.content) 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): def test_entrance_exam_requirement_message_hidden(self):
""" """
Unit Test: entrance exam message should not be present outside the context of entrance exam subsection. Unit Test: entrance exam message should not be present outside the context of entrance exam subsection.
......
...@@ -202,14 +202,14 @@ ${fragment.foot_html()} ...@@ -202,14 +202,14 @@ ${fragment.foot_html()}
<p class="sequential-status-message"> <p class="sequential-status-message">
${_('To access course materials, you must score {required_score}% or higher on this \ ${_('To access course materials, you must score {required_score}% or higher on this \
exam. Your current score is {current_score}%.').format( exam. Your current score is {current_score}%.').format(
required_score=int(course.entrance_exam_minimum_score_pct * 100), required_score=int(round(course.entrance_exam_minimum_score_pct * 100)),
current_score=int(entrance_exam_current_score * 100) current_score=int(round(entrance_exam_current_score * 100))
)} )}
</p> </p>
% else: % else:
<p class="sequential-status-message"> <p class="sequential-status-message">
${_('Your score is {current_score}%. You have passed the entrance exam.').format( ${_('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))
)} )}
</p> </p>
% endif % endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment