minimum score percentage rounded
round before converting a decimal into integer
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -202,14 +202,14 @@ ${fragment.foot_html()}
|
||||
<p class="sequential-status-message">
|
||||
${_('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))
|
||||
)}
|
||||
</p>
|
||||
% else:
|
||||
<p class="sequential-status-message">
|
||||
${_('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>
|
||||
% endif
|
||||
|
||||
Reference in New Issue
Block a user