mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 20:53:53 +01:00
MDL-55327 mod_lesson: Fix for copying essay and match.
Matching and essay questions would display errors when being duplicated.
This commit is contained in:
parent
6cc077e90f
commit
f4eef5fb25
@ -1721,10 +1721,10 @@ class lesson extends lesson_base {
|
||||
$this->copy_page_files('page_contents', $pageid, $newlessonpage->id, $context->id);
|
||||
$j = 0;
|
||||
foreach ($newanswers as $answer) {
|
||||
if (strpos($answer->answer, '@@PLUGINFILE@@') !== false) {
|
||||
if (isset($answer->answer) && strpos($answer->answer, '@@PLUGINFILE@@') !== false) {
|
||||
$this->copy_page_files('page_answers', $answerids[$j], $answer->id, $context->id);
|
||||
}
|
||||
if (strpos($answer->response, '@@PLUGINFILE@@') !== false) {
|
||||
if (isset($answer->response) && !is_array($answer->response) && strpos($answer->response, '@@PLUGINFILE@@') !== false) {
|
||||
$this->copy_page_files('page_responses', $answerids[$j], $answer->id, $context->id);
|
||||
}
|
||||
$j++;
|
||||
|
@ -118,6 +118,15 @@ class lesson_page_type_matching extends lesson_page {
|
||||
$cm = get_coursemodule_from_instance('lesson', $this->lesson->id, $this->lesson->course);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
// Check for duplicate response format.
|
||||
$duplicateresponse = array();
|
||||
if (is_array($properties->response_editor[0])) {
|
||||
foreach ($properties->response_editor as $response) {
|
||||
$duplicateresponse[] = $response['text'];
|
||||
}
|
||||
$properties->response_editor = $duplicateresponse;
|
||||
}
|
||||
|
||||
$answers = array();
|
||||
|
||||
// need to add two to offset correct response and wrong response
|
||||
|
Loading…
x
Reference in New Issue
Block a user