Skip to content

Commit 7e5a8fb

Browse files
committed
try to fix missing import
1 parent cf861b6 commit 7e5a8fb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

backup/moodle2/backup_moodleoverflow_stepslib.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ protected function define_structure() {
130130
$read->annotate_ids('user', 'userid');
131131
$rating->annotate_ids('user', 'userid');
132132
$track->annotate_ids('user', 'userid');
133+
$moodleoverflow->annotate_ids('grade_category', 'gradecat');
133134

134135
// Define file annotations (we do not use itemid in this example).
135136
$moodleoverflow->annotate_files('mod_moodleoverflow', 'intro', null);

backup/moodle2/restore_moodleoverflow_stepslib.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ protected function process_moodleoverflow($data) {
8989
$data = (object) $data;
9090
$data->course = $this->get_courseid();
9191

92+
// Map grade category to the restored category id (if present).
93+
if (!empty($data->gradecat)) {
94+
$mapped = $this->get_mappingid('grade_category', $data->gradecat);
95+
if ($mapped !== null) {
96+
$data->gradecat = $mapped;
97+
} else {
98+
// If mapping not found, clear or handle as appropriate (keeping null avoids pointing to wrong category).
99+
$data->gradecat = null;
100+
}
101+
}
92102
if (empty($data->timecreated)) {
93103
$data->timecreated = time();
94104
}

0 commit comments

Comments
 (0)