From b306ee6523d7ecbf39d8c9de08cba1e695318d1b Mon Sep 17 00:00:00 2001 From: Stephan Robotta Date: Thu, 5 Dec 2024 14:50:11 +0100 Subject: [PATCH] Fix typeid in backup and restore. --- .../moodle2/backup_verbalfeedback_stepslib.php | 16 ++++++++-------- .../moodle2/restore_verbalfeedback_stepslib.php | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/backup/moodle2/backup_verbalfeedback_stepslib.php b/backup/moodle2/backup_verbalfeedback_stepslib.php index 6a1a865..c4bbb66 100644 --- a/backup/moodle2/backup_verbalfeedback_stepslib.php +++ b/backup/moodle2/backup_verbalfeedback_stepslib.php @@ -58,35 +58,35 @@ protected function define_structure() { $category = new backup_nested_element('category', ['id'], ['instanceid', 'paramtemplatecategoryid', 'position', 'weight']); $categoryheaders = new backup_nested_element('categoryheaders'); - $categoryheader = new backup_nested_element('categoryheader', ['id'], ['foreignkey', 'type', 'languageid', 'string']); + $categoryheader = new backup_nested_element('categoryheader', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $criteria = new backup_nested_element('criteria'); $criterion = new backup_nested_element('criterion', ['id'], ['paramtemplatecriterionid', 'categoryid', 'position', 'weight']); $criteriontexts = new backup_nested_element('criteriontexts'); - $criteriontext = new backup_nested_element('criteriontext', ['id'], ['foreignkey', 'type', 'languageid', 'string']); + $criteriontext = new backup_nested_element('criteriontext', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $subratings = new backup_nested_element('subratings'); $subrating = new backup_nested_element('subrating', ['id'], ['criterionid']); $subratingtitles = new backup_nested_element('titles'); - $subratingtitle = new backup_nested_element('title', ['id'], ['foreignkey', 'type', 'languageid', 'string']); + $subratingtitle = new backup_nested_element('title', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $subratingdescriptions = new backup_nested_element('descriptions'); - $subratingdescription = new backup_nested_element('description', ['id'], ['foreignkey', 'type', 'languageid', 'string']); + $subratingdescription = new backup_nested_element('description', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $subratingverynegatives = new backup_nested_element('verynegatives'); - $subratingverynegative = new backup_nested_element('verynegative', ['id'], ['foreignkey', 'type', 'languageid', 'string']); + $subratingverynegative = new backup_nested_element('verynegative', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $subratingnegatives = new backup_nested_element('negatives'); - $subratingnegative = new backup_nested_element('negative', ['id'], ['foreignkey', 'type', 'languageid', 'string']); + $subratingnegative = new backup_nested_element('negative', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $subratingpositives = new backup_nested_element('positives'); - $subratingpositive = new backup_nested_element('positive', ['id'], ['foreignkey', 'type', 'languageid', 'string']); + $subratingpositive = new backup_nested_element('positive', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $subratingverypositives = new backup_nested_element('verypositives'); - $subratingverypositive = new backup_nested_element('verypositive', ['id'], ['foreignkey', 'type', 'languageid', 'string']); + $subratingverypositive = new backup_nested_element('verypositive', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $submissions = new backup_nested_element('submissions'); $submission = new backup_nested_element('submission', ['id'], ['instanceid', 'fromuserid', 'touserid', 'status', diff --git a/backup/moodle2/restore_verbalfeedback_stepslib.php b/backup/moodle2/restore_verbalfeedback_stepslib.php index 8a09fd5..2023fe6 100644 --- a/backup/moodle2/restore_verbalfeedback_stepslib.php +++ b/backup/moodle2/restore_verbalfeedback_stepslib.php @@ -335,8 +335,7 @@ private function process_localized_string($foreigenkeymapping, $data) { $data = (object) $data; $data->foreignkey = $this->get_mappingid($foreigenkeymapping, $data->foreignkey); $data->languageid = $this->get_mappingid('language', $data->languageid); - $data->typeid = localized_string_type::str2id($data->type); - unset($data->type); + $data->typeid = $this->get_mappingid('typeid', $data->typeid); $data->instanceid = $this->instanceid; $DB->insert_record('verbalfeedback_local_string', $data); }