Commit 0be5bd6f by Matjaz Gregoric

Enable freeform answer submit when feedback is hidden.

When problem builder is configured to hide feedback upon revisiting a question
(pb_hide_feedback_if_attempts_remain option is enabled), when the user returns
to a problem builder block which contains only a freeform question,
the user is not able to click "Submit" without changing the answer text first.

This patch fixes that by keeping submit button enabled if
pb_hide_feedback_if_attempts_remain is turned on.

MCKIN-3890
parent aa9fa671
......@@ -478,6 +478,10 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
"""
return '/jump_to_id/{}'.format(self.next_step)
@property
def hide_feedback(self):
return self.get_option("pb_hide_feedback_if_attempts_remain") and not self.max_attempts_reached
def get_message(self, completed):
"""
Get the message to display to a student following a submission in normal mode.
......@@ -564,8 +568,7 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
"""
results = []
completed = True
hide_feedback = self.get_option("pb_hide_feedback_if_attempts_remain") and not self.max_attempts_reached
show_message = (not hide_feedback) and bool(self.student_results)
show_message = (not self.hide_feedback) and bool(self.student_results)
# In standard mode, all children are visible simultaneously, so need to collect results for all of them
for child in self.steps:
......
......@@ -6,6 +6,7 @@ function AnswerBlock(runtime, element) {
$(':input', element).on('keyup', options.onChange);
this.mode = options.mode;
this.validateXBlock = options.validateXBlock;
// In the LMS, the HTML of multiple units can be loaded at once,
// and the user can flip among them. If that happens, the answer in
......@@ -72,6 +73,7 @@ function AnswerBlock(runtime, element) {
},
refreshAnswer: function() {
var self = this;
$.ajax({
type: 'POST',
url: runtime.handlerUrl(element, 'answer_value'),
......@@ -86,6 +88,9 @@ function AnswerBlock(runtime, element) {
if (currentAnswer == origAnswer && currentAnswer != newAnswer) {
$textarea.val(newAnswer);
}
if (self.validateXBlock) {
self.validateXBlock();
}
},
});
}
......
......@@ -35,10 +35,13 @@ function MentoringStandardView(runtime, element, mentoring) {
}
}
// Data may have changed, we have to re-validate.
validateXBlock();
// Disable the submit button if we have just submitted new answers,
// or if we have just [re]loaded the page and are showing a complete set
// of old answers.
if (disable_submit || all_have_results) {
if (disable_submit || (all_have_results && mentoring.data.hide_feedback !== 'True')) {
submitDOM.attr('disabled', 'disabled');
}
}
......@@ -110,7 +113,8 @@ function MentoringStandardView(runtime, element, mentoring) {
submitDOM.show();
var options = {
onChange: onChange
onChange: onChange,
validateXBlock: validateXBlock
};
mentoring.initChildren(options);
......
......@@ -303,7 +303,7 @@ function MentoringWithStepsBlock(runtime, element) {
var mentoring = {
setContent: setContent,
publish_event: publishEvent,
step_builder: true
is_step_builder: true
};
options.mentoring = mentoring;
step.initChildren(options);
......
......@@ -211,7 +211,7 @@ function MRQBlock(runtime, element) {
var questionnaireDOM = $('fieldset.questionnaire', element);
var data = questionnaireDOM.data();
var hide_results = (data.hide_results === 'True' ||
(data.hide_prev_answer === 'True' && !mentoring.step_builder));
(data.hide_prev_answer === 'True' && !mentoring.is_step_builder));
// hide_prev_answer should only take effect when we initially render (previous) results,
// so set hide_prev_answer to False after initial render.
questionnaireDOM.data('hide_prev_answer', 'False');
......
{% load i18n %}
<div class="mentoring themed-xblock" data-mode="{{ self.mode }}" data-step="{{ self.step }}" data-feedback_label="{{ self.feedback_label}}">
<div class="mentoring themed-xblock" data-mode="{{ self.mode }}" data-step="{{ self.step }}" data-feedback_label="{{ self.feedback_label }}" data-hide_feedback="{{ self.hide_feedback }}">
<div class="missing-dependency warning" data-missing="{{ self.has_missing_dependency }}">
{% with url=missing_dependency_url|safe %}
{% blocktrans with link_start="<a href='"|add:url|add:"'>" link_end="</a>" %}
......
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