From 8a0834ccd13e85db922714d49735f8502d267e33 Mon Sep 17 00:00:00 2001 From: Nicolas Dunand Date: Wed, 27 Nov 2024 12:04:47 +0100 Subject: [PATCH] Fox for #73 --- backup/moodle2/restore_qtype_matrix_plugin.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backup/moodle2/restore_qtype_matrix_plugin.class.php b/backup/moodle2/restore_qtype_matrix_plugin.class.php index a77f835..808eb4e 100644 --- a/backup/moodle2/restore_qtype_matrix_plugin.class.php +++ b/backup/moodle2/restore_qtype_matrix_plugin.class.php @@ -51,7 +51,7 @@ public function process_matrix($data): void { // Todo: check import of version moodle1 data. - if ($this->is_question_created() || !$this->get_mappingid('qtype_matrix_matrix', $oldid)) { + if ($this->is_question_created()) { $data->questionid = $this->get_new_parentid('question'); $newitemid = $DB->insert_record('qtype_matrix', $data); $this->set_mapping('matrix', $oldid, $newitemid); @@ -80,6 +80,10 @@ public function process_col($data): void { $oldid = $data->id; $newmatrixid = $this->get_new_parentid('matrix'); + if (!$newmatrixid) { + return; + } + if ($this->is_question_created()) { $data->matrixid = $newmatrixid; $newitemid = $DB->insert_record('qtype_matrix_cols', $data); @@ -111,6 +115,9 @@ public function process_row($data): void { $oldid = $data->id; $newmatrixid = $this->get_new_parentid('matrix'); + if (!$newmatrixid) { + return; + } if ($this->is_question_created()) { $data->matrixid = $newmatrixid;