MDL-34102 mod_lesson: display feedback

Feedback for incorrect answer was not diplayed when
Provide option to try a question again was set to Yes.
This commit is contained in:
Jean-Michel Vedrine 2015-02-08 16:04:55 +01:00
parent 24a2babdd3
commit 2107531f3c

View File

@ -2520,38 +2520,40 @@ abstract class lesson_page extends lesson_base {
$result->feedback = $OUTPUT->box(get_string("secondpluswrong", "lesson"), 'feedback');
}
} else {
$class = 'response';
if ($result->correctanswer) {
$class .= ' correct'; //CSS over-ride this if they exist (!important)
} else if (!$result->isessayquestion) {
$class .= ' incorrect'; //CSS over-ride this if they exist (!important)
}
$options = new stdClass;
$options->noclean = true;
$options->para = true;
$options->overflowdiv = true;
$options->context = $context;
$result->feedback = $OUTPUT->box(format_text($this->get_contents(), $this->properties->contentsformat, $options), 'generalbox boxaligncenter');
if (isset($result->studentanswerformat)) {
// This is the student's answer so it should be cleaned.
$studentanswer = format_text($result->studentanswer, $result->studentanswerformat,
array('context' => $context, 'para' => true));
} else {
$studentanswer = format_string($result->studentanswer);
}
$result->feedback .= '<div class="correctanswer generalbox"><em>'
. get_string("youranswer", "lesson").'</em> : ' . $studentanswer;
if (isset($result->responseformat)) {
$result->response = file_rewrite_pluginfile_urls($result->response, 'pluginfile.php', $context->id,
'mod_lesson', 'page_responses', $result->answerid);
$result->feedback .= $OUTPUT->box(format_text($result->response, $result->responseformat, $options)
, $class);
} else {
$result->feedback .= $OUTPUT->box($result->response, $class);
}
$result->feedback .= '</div>';
$result->feedback = '';
}
$class = 'response';
if ($result->correctanswer) {
$class .= ' correct'; // CSS over-ride this if they exist (!important).
} else if (!$result->isessayquestion) {
$class .= ' incorrect'; // CSS over-ride this if they exist (!important).
}
$options = new stdClass;
$options->noclean = true;
$options->para = true;
$options->overflowdiv = true;
$options->context = $context;
$result->feedback .= $OUTPUT->box(format_text($this->get_contents(), $this->properties->contentsformat, $options),
'generalbox boxaligncenter');
if (isset($result->studentanswerformat)) {
// This is the student's answer so it should be cleaned.
$studentanswer = format_text($result->studentanswer, $result->studentanswerformat,
array('context' => $context, 'para' => true));
} else {
$studentanswer = format_string($result->studentanswer);
}
$result->feedback .= '<div class="correctanswer generalbox"><em>'
. get_string("youranswer", "lesson").'</em> : ' . $studentanswer;
if (isset($result->responseformat)) {
$result->response = file_rewrite_pluginfile_urls($result->response, 'pluginfile.php', $context->id,
'mod_lesson', 'page_responses', $result->answerid);
$result->feedback .= $OUTPUT->box(format_text($result->response, $result->responseformat, $options)
, $class);
} else {
$result->feedback .= $OUTPUT->box($result->response, $class);
}
$result->feedback .= '</div>';
}
}