mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-42449' of git://github.com/andrewhancox/moodle
This commit is contained in:
commit
1f619e8d60
@ -3051,11 +3051,6 @@ class restore_activity_grades_structure_step extends restore_structure_step {
|
||||
$oldparentid = $data->categoryid;
|
||||
$courseid = $this->get_courseid();
|
||||
|
||||
// make sure top course category exists, all grade items will be associated
|
||||
// to it. Later, if restoring the whole gradebook, categories will be introduced
|
||||
$coursecat = grade_category::fetch_course_category($courseid);
|
||||
$coursecatid = $coursecat->id; // Get the categoryid to be used
|
||||
|
||||
$idnumber = null;
|
||||
if (!empty($data->idnumber)) {
|
||||
// Don't get any idnumber from course module. Keep them as they are in grade_item->idnumber
|
||||
@ -3080,8 +3075,18 @@ class restore_activity_grades_structure_step extends restore_structure_step {
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data->categoryid)) {
|
||||
// If the grade category id of the grade item being restored belongs to this course
|
||||
// then it is a fair assumption that this is the correct grade category for the activity
|
||||
// and we should leave it in place, if not then unset it.
|
||||
// TODO MDL-34790 Gradebook does not import if target course has gradebook categories.
|
||||
$conditions = array('id' => $data->categoryid, 'courseid' => $courseid);
|
||||
if (!$this->task->is_samesite() || !$DB->record_exists('grade_categories', $conditions)) {
|
||||
unset($data->categoryid);
|
||||
}
|
||||
}
|
||||
|
||||
unset($data->id);
|
||||
$data->categoryid = $coursecatid;
|
||||
$data->courseid = $this->get_courseid();
|
||||
$data->iteminstance = $this->task->get_activityid();
|
||||
$data->idnumber = $idnumber;
|
||||
|
Loading…
x
Reference in New Issue
Block a user