Commit e8e2b48c by Braden MacDonald

Combine hard-coded assessment review message with the customizable one.

parent d5a7579a
......@@ -424,7 +424,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
Get the message to display to a student following a submission in assessment mode.
"""
if not self.max_attempts_reached:
return self.get_message_content('on-assessment-review')
return self.get_message_content('on-assessment-review', or_default=True)
else:
return None
......@@ -712,12 +712,16 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
def max_attempts_reached(self):
return self.max_attempts > 0 and self.num_attempts >= self.max_attempts
def get_message_content(self, message_type):
def get_message_content(self, message_type, or_default=False):
for child_id in self.children:
if child_isinstance(self, child_id, MentoringMessageBlock):
child = self.runtime.get_block(child_id)
if child.type == message_type:
return child.content
if or_default:
# Return the default value since no custom message is set.
# Note the WYSIWYG editor usually wraps the .content HTML in a <p> tag so we do the same here.
return '<p>{}</p>'.format(MentoringMessageBlock.MESSAGE_TYPES[message_type]['default'])
def validate(self):
"""
......
......@@ -75,7 +75,8 @@ class MentoringMessageBlock(XBlock, StudioEditableXBlockMixin):
"display_name": _(u"Review with attempts left"),
"long_display_name": _(u"Message shown during review when attempts remain"),
"default": _(
u"You may try this assessment again, and only the latest score will be used."
u"Note: if you retake this assessment, only your final score counts. "
"If you would like to keep this score, please continue to the next unit."
),
"description": _(
u"In assessment mode, this message will be shown when the student is reviewing "
......
......@@ -2,13 +2,11 @@
margin: 1em 0em;
}
.mentoring .messages,
.mentoring .assessment-messages {
.mentoring .messages {
display: none;
}
.mentoring .messages .title1,
.mentoring .assessment-messages .title1 {
.mentoring .messages .title1 {
color: #333333;
text-transform: uppercase;
font-weight: bold;
......
......@@ -2,7 +2,7 @@ function MentoringAssessmentView(runtime, element, mentoring) {
var gradeTemplate = _.template($('#xblock-grade-template').html());
var reviewQuestionsTemplate = _.template($('#xblock-review-questions-template').html()); // Detailed list of which questions the user got wrong
var reviewTipsTemplate = _.template($('#xblock-review-tips-template').html()); // Tips about specific questions the user got wrong
var submitDOM, nextDOM, reviewDOM, tryAgainDOM, messagesDOM, reviewLinkDOM, reviewTipsDOM;
var submitDOM, nextDOM, reviewDOM, tryAgainDOM, assessmentMessageDOM, reviewLinkDOM, reviewTipsDOM;
var submitXHR;
var checkmark;
var active_child;
......@@ -23,7 +23,6 @@ function MentoringAssessmentView(runtime, element, mentoring) {
$('.grade').html('');
$('.attempts').html('');
messagesDOM.empty().hide();
reviewTipsDOM.empty().hide();
}
......@@ -68,16 +67,18 @@ function MentoringAssessmentView(runtime, element, mentoring) {
if (data.max_attempts === 0 || data.num_attempts < data.max_attempts) {
if (data.assessment_message) {
// Overall on-assessment-review message:
mentoring.setContent(messagesDOM, data.assessment_message);
messagesDOM.show();
assessmentMessageDOM.html(data.assessment_message);
}
if (data.assessment_review_tips.length > 0) {
// on-assessment-review-question messages specific to questions the student got wrong:
mentoring.setContent(reviewTipsDOM, reviewTipsTemplate({
reviewTipsDOM.html(reviewTipsTemplate({
tips: data.assessment_review_tips
}));
reviewTipsDOM.show();
}
} else {
var msg = gettext("Note: you have used all attempts. Continue to the next unit.");
assessmentMessageDOM.html('').append($('<p></p>').html(msg));
}
$('a.question-link', element).click(reviewJump);
}
......@@ -112,7 +113,7 @@ function MentoringAssessmentView(runtime, element, mentoring) {
tryAgainDOM = $(element).find('.submit .input-try-again');
reviewLinkDOM = $(element).find('.review-link');
checkmark = $('.assessment-checkmark', element);
messagesDOM = $('.assessment-messages', element);
assessmentMessageDOM = $('.assessment-message', element);
reviewTipsDOM = $('.assessment-review-tips', element);
submitDOM.show();
......
......@@ -16,6 +16,8 @@
{% endif %}
<div class="{{self.mode}}-question-block">
<div class="assessment-message"></div>
{{child_content|safe}}
{% if self.display_submit %}
......@@ -34,8 +36,6 @@
data-partial="{{ self.partial_json }}">
</div>
<div class="assessment-messages"></div>
<div class="submit">
{% if self.mode == 'assessment' %}
<span class="assessment-checkmark fa icon-2x"></span>
......
<script type="text/template" id="xblock-grade-template">
<% if (_.isNumber(max_attempts) && max_attempts > 0 && num_attempts >= max_attempts) {{ %>
<p><%= gettext("Note: you have used all attempts. Continue to the next unit.") %></p>
<% }} else {{ %>
<p><%= gettext("Note: if you retake this assessment, only your final score counts.") %></p>
<% }} %>
<div class="grade-result">
<h2>
<%= _.template(gettext("You scored {percent}% on this assessment."), {percent: score}, {interpolate: /\{(.+?)\}/g}) %>
......
......@@ -243,7 +243,6 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
self.wait_until_text_in("You scored {percentage}% on this assessment.".format(**expected), mentoring)
self.assert_persistent_elements_present(mentoring)
if expected["max_attempts"] > 0 and expected["num_attempts"] < expected["max_attempts"]:
self.assertIn("Note: if you retake this assessment, only your final score counts.", mentoring.text)
self.assertFalse(mentoring.find_elements_by_css_selector('.review-list'))
elif extended_feedback:
for q_type in ['correct', 'incorrect', 'partial']:
......@@ -277,16 +276,10 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
self.assert_hidden(controls.review)
self.assert_hidden(controls.review_link)
def assert_messages_text(self, mentoring, text):
messages = mentoring.find_element_by_css_selector('.assessment-messages')
self.assertEqual(messages.text, text)
self.assertTrue(messages.is_displayed())
def assert_messages_empty(self, mentoring):
messages = mentoring.find_element_by_css_selector('.assessment-messages')
self.assertEqual(messages.text, '')
self.assertFalse(messages.find_elements_by_xpath('./*'))
self.assertFalse(messages.is_displayed())
def assert_message_text(self, mentoring, text):
message_wrapper = mentoring.find_element_by_css_selector('.assessment-message')
self.assertEqual(message_wrapper.text, text)
self.assertTrue(message_wrapper.is_displayed())
def extended_feedback_checks(self, mentoring, controls, expected_results):
# Multiple choice is third correctly answered question
......@@ -345,12 +338,12 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
self.peek_at_review(mentoring, controls, expected_results, extended_feedback=extended_feedback)
if max_attempts == 1:
self.assert_messages_empty(mentoring)
self.assert_message_text(mentoring, "Note: you have used all attempts. Continue to the next unit.")
self.assert_disabled(controls.try_again)
return
# The on-assessment-review message is shown if attempts remain:
self.assert_messages_text(mentoring, "Assessment additional feedback message text")
self.assert_message_text(mentoring, "Assessment additional feedback message text")
self.assert_clickable(controls.try_again)
controls.try_again.click()
......@@ -373,9 +366,9 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
else:
self.assert_clickable(controls.try_again)
if 1 <= max_attempts <= 2:
self.assert_messages_empty(mentoring) # The on-assessment-review message is not shown if no attempts remain
self.assert_message_text(mentoring, "Note: you have used all attempts. Continue to the next unit.")
else:
self.assert_messages_text(mentoring, "Assessment additional feedback message text")
self.assert_message_text(mentoring, "Assessment additional feedback message text")
if extended_feedback:
self.extended_feedback_checks(mentoring, controls, expected_results)
......@@ -402,7 +395,7 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
self.assertNotIn('Lesson 2', review_tips.text) # This MCQ was correct
self.assertIn('Lesson 3', review_tips.text)
# The on-assessment-review message is also shown if attempts remain:
self.assert_messages_text(mentoring, "Assessment additional feedback message text")
self.assert_message_text(mentoring, "Assessment additional feedback message text")
self.assert_clickable(controls.try_again)
controls.try_again.click()
......@@ -414,7 +407,7 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
user_selection = ("Its elegance", "Its beauty", "Its gracefulness")
self.multiple_response_question(4, mentoring, controls, user_selection, CORRECT, last=True)
self.assert_messages_text(mentoring, "Assessment additional feedback message text")
self.assert_message_text(mentoring, "Assessment additional feedback message text")
self.assertFalse(review_tips.is_displayed())
self.assert_clickable(controls.try_again)
......@@ -442,7 +435,11 @@ class MentoringAssessmentTest(MentoringAssessmentBaseTest):
}
self.peek_at_review(mentoring, controls, expected_results)
self.assert_messages_empty(mentoring)
self.assert_message_text(
mentoring,
"Note: if you retake this assessment, only your final score counts. "
"If you would like to keep this score, please continue to the next unit."
)
self.wait_until_clickable(controls.try_again)
controls.try_again.click()
......
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