$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++;
$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