From 2107531f3c8d3873caaaf1fb6f8a98fbe40ed617 Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Sun, 8 Feb 2015 16:04:55 +0100 Subject: [PATCH] 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. --- mod/lesson/locallib.php | 64 +++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 693bab58f61..2dfd017cf7f 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -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 .= '
' - . get_string("youranswer", "lesson").' : ' . $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 .= '
'; + $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 .= '
' + . get_string("youranswer", "lesson").' : ' . $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 .= '
'; } }