Skip to content

Commit

Permalink
Merge branch 'MDL-43042-34' of git://github.com/mihailges/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_34_STABLE
  • Loading branch information
andrewnicols committed Jan 8, 2018
2 parents 31a9ee8 + 144c240 commit 8ec36b0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
41 changes: 28 additions & 13 deletions mod/lesson/locallib.php
Expand Up @@ -4123,23 +4123,38 @@ final public function record_attempt($context) {
$options->context = $context;

$result->feedback .= $OUTPUT->box(format_text($this->get_contents(), $this->properties->contentsformat, $options),
'generalbox boxaligncenter');
$studentanswer = format_text($result->studentanswer, $result->studentanswerformat,
array('context' => $context, 'para' => true));
'generalbox boxaligncenter p-y-1');
$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);
. get_string("youranswer", "lesson").'</em> : <div class="studentanswer m-t-2 m-b-2">';

$studentanswerarray = explode('<br />', $result->studentanswer);
$responsearr = explode('<br />', $result->response);
$studentanswerresponse = array_combine($studentanswerarray, $responsearr);
// Create a table containing the answers and responses.
$table = new html_table();
foreach ($studentanswerresponse as $answer => $response) {
// Add a table row containing the answer.
$studentanswer = format_text($answer, $result->studentanswerformat,
array('context' => $context, 'para' => true));
$table->data[] = array($studentanswer);
// If the response exists, add a table row containing the response. If not, add en empty row.
if (!empty(trim($response))) {
if (isset($result->responseformat)) {
$convertstudentresponse = file_rewrite_pluginfile_urls($response, 'pluginfile.php',
$context->id, 'mod_lesson', 'page_responses', $result->answerid);
$studentresponse = format_text($convertstudentresponse, $result->responseformat, $options);
} else {
$studentresponse = $response;
}
$table->data[] = array('<em>'.get_string("response", "lesson").
'</em>: <br/>'.$studentresponse);
} else {
$table->data[] = array('');
}
}
$result->feedback .= '</div>';
$result->feedback .= html_writer::table($table).'</div></div>';
}
}

return $result;
}

Expand Down
7 changes: 3 additions & 4 deletions mod/lesson/pagetypes/multichoice.php
Expand Up @@ -169,13 +169,12 @@ public function check_answer() {
foreach ($answers as $answer) {
foreach ($studentanswers as $answerid) {
if ($answerid == $answer->id) {
$result->studentanswer .= '<br />'.format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
if (trim(strip_tags($answer->response))) {
$responses[$answerid] = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
}
$studentanswerarray[] = format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
$responses[$answerid] = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
}
}
}
$result->studentanswer = implode('<br />', $studentanswerarray);
$correctpageid = null;
$wrongpageid = null;

Expand Down

0 comments on commit 8ec36b0

Please sign in to comment.