Commit 5a5f3f0c by UmanShahzad

Rename max_score to maximum_score; match max_attempts with it.

Resolves https://openedx.atlassian.net/browse/EDUCATOR-338 where
this XBlock was overriding the `max_score()` which edX grading
infrastructure expects as a method on the block.

We rename `max_attempts` to `maximum_attempts` to keep style consistent.
parent 1786a2c8
......@@ -74,14 +74,14 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
scope=Scope.content,
default=1.0,
)
max_score = Float(
maximum_score = Float(
display_name='Maximum score',
help='The number of points students will be awarded when solving all fields correctly. '
'For partially correct attempts, the score will be pro-rated.',
scope=Scope.settings,
default=1.0,
)
max_attempts = Integer(
maximum_attempts = Integer(
display_name='Maximum attempts',
help='Defines the number of times a student can try to answer this problem. If the value '
'is not set, infinite attempts are allowed.',
......@@ -95,8 +95,8 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
'column_widths',
'row_heights',
'default_tolerance',
'max_score',
'max_attempts',
'maximum_score',
'maximum_attempts',
]
# Dictionary mapping cell ids to the student answers.
......@@ -171,9 +171,9 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
num_correct_answers=self.num_correct_answers,
num_total_answers=self.num_total_answers,
score=self.score,
max_score=self.max_score,
maximum_score=self.maximum_score,
attempts=self.attempts,
max_attempts=self.max_attempts,
maximum_attempts=self.maximum_attempts,
)
def student_view(self, context=None):
......@@ -188,7 +188,7 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
head_height=self._row_heights[0] if self._row_heights else None,
thead=self.thead,
tbody=self.tbody,
max_attempts=self.max_attempts,
maximum_attempts=self.maximum_attempts,
)
html = loader.render_template('templates/html/activetable.html', context)
......@@ -207,7 +207,7 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
def check_and_save_answers(self, data):
"""Common implementation for the check and save handlers."""
if self.max_attempts and self.attempts >= self.max_attempts:
if self.maximum_attempts and self.attempts >= self.maximum_attempts:
# The "Check" button is hidden when the maximum number of attempts has been reached, so
# we can only get here by manually crafted requests. We simply return the current
# status without rechecking or storing the answers in that case.
......@@ -231,8 +231,8 @@ class ActiveTableXBlock(StudioEditableXBlockMixin, XBlock):
"""
self.answers_correct = self.check_and_save_answers(data)
self.attempts += 1
self.score = self.num_correct_answers * self.max_score / len(self.answers_correct)
self.runtime.publish(self, 'grade', dict(value=self.score, max_value=self.max_score))
self.score = self.num_correct_answers * self.maximum_score / len(self.answers_correct)
self.runtime.publish(self, 'grade', dict(value=self.score, max_value=self.maximum_score))
return self.get_status()
@XBlock.json_handler
......
......@@ -47,17 +47,17 @@ function ActiveTableXBlock(runtime, element, init_args) {
function updateFeedback(data) {
var feedback_msg;
if (data.score === null) {
feedback_msg = '(' + data.max_score + ' points possible)';
feedback_msg = '(' + data.maximum_score + ' points possible)';
} else {
feedback_msg = '(' + data.score + '/' + data.max_score + ' points)';
feedback_msg = '(' + data.score + '/' + data.maximum_score + ' points)';
}
if (data.max_attempts) {
feedback_msg = 'You have used ' + data.attempts + ' of ' + data.max_attempts +
if (data.maximum_attempts) {
feedback_msg = 'You have used ' + data.attempts + ' of ' + data.maximum_attempts +
' submissions ' + feedback_msg;
if (data.attempts == data.max_attempts - 1) {
if (data.attempts == data.maximum_attempts - 1) {
$('.action .check .check-label', element).text('Final check');
}
else if (data.attempts >= data.max_attempts) {
else if (data.attempts >= data.maximum_attempts) {
$('.action .check, .action .save', element).hide();
}
}
......
......@@ -41,7 +41,7 @@
<div class="status-message" aria-live="polite"></div>
<div class="action">
<button class="check"><span class="check-label">Check</span><span class="sr"> your answer</span></button>
{% if max_attempts %}
{% if maximum_attempts %}
<button class="save">Save<span class="sr"> your answer</span></button>
<div class="submission-feedback" aria-live="polite"></div>
{% endif %}
......
......@@ -81,7 +81,7 @@ class TestActiveTable(StudioEditableBaseTest):
def test_save_and_reload(self):
answers = dict(cell_1_1='1', cell_2_1='2', cell_3_1='3')
self.load_scenario('xml/max_attempts.xml')
self.load_scenario('xml/maximum_attempts.xml')
self.enter_answers(answers)
self.element.find_element_by_css_selector('.action button.save').click()
vertical = self.load_root_xblock()
......
<vertical_demo>
<activetable url_name="max_attempts" max_attempts="2">
<activetable url_name="maximum_attempts" maximum_attempts="2">
[
['Event', 'Year'],
['French Revolution', Numeric(answer=1789)],
......
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