Commit 28e6b62c by Braden MacDonald

Fix: Image not shown to the user for MRQ feedback tip on question level, MCQ feedback not shown

parent b542f0c5
......@@ -99,7 +99,7 @@ class MCQBlock(SubmittingXBlockMixin, QuestionnaireAbstractBlock):
return {
'submission': submission,
'message': self.message,
'message': self.message_formatted,
'status': 'correct' if correct else 'incorrect',
'tips': formatted_tips,
'weight': self.weight,
......
......@@ -148,7 +148,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
'submissions': submissions,
'status': status,
'choices': results,
'message': self.message,
'message': self.message_formatted,
'weight': self.weight,
'score': (float(score) / len(results)) if results else 0,
}
......
......@@ -122,7 +122,12 @@ function MCQBlock(runtime, element) {
var mentoring = this.mentoring;
var messageView = MessageView(element, mentoring);
messageView.clearResult();
if (result.message) {
var msg = '<div class="message-content">' + result.message + '</div>' +
'<div class="close icon-remove-sign fa-times-circle"></div>';
messageView.showMessage(msg);
} else { messageView.clearResult(); }
display_message(result.message, messageView, options.checkmark);
......
......@@ -221,3 +221,14 @@ class QuestionnaireAbstractBlock(
child = self.runtime.get_block(child_id)
if child.type == "on-assessment-review-question":
return child.content
@property
def message_formatted(self):
""" Get the feedback message HTML, if any, formatted by the runtime """
if self.message:
# For any HTML that we aren't 'rendering' through an XBlock view such as
# student_view the runtime may need to rewrite URLs
# e.g. converting '/static/x.png' to '/c4x/.../x.png'
format_html = getattr(self.runtime, 'replace_urls', lambda html: html)
return format_html(self.message)
return ""
......@@ -100,6 +100,16 @@ class StepBuilderTest(MentoringAssessmentBaseTest, MultipleSliderBlocksTestMixin
runtime_patcher.start()
self.addCleanup(runtime_patcher.stop)
# Mock replace_urls so that we can check that message HTML gets processed with any
# transforms that the runtime needs.
runtime_patcher2 = patch(
'workbench.runtime.WorkbenchRuntime.replace_urls',
lambda _runtime, html: html.replace('REPLACE-ME', ''),
create=True
)
runtime_patcher2.start()
self.addCleanup(runtime_patcher2.stop)
def freeform_answer(
self, number, step_builder, controls, text_input, result, saved_value="", hold=False, last=False
):
......
......@@ -41,7 +41,7 @@
</sb-step>
<sb-step display_name="Last step">
<pb-mrq name="mrq_1_1" question="What do you like in this MRQ?" required_choices='["gracefulness","elegance","beauty"]' message="Question Feedback Message">
<pb-mrq name="mrq_1_1" question="What do you like in this MRQ?" required_choices='["gracefulness","elegance","beauty"]' message="Question Feedback Message REPLACE-ME">
<pb-choice value="elegance">Its elegance</pb-choice>
<pb-choice value="beauty">Its beauty</pb-choice>
<pb-choice value="gracefulness">Its gracefulness</pb-choice>
......
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