Skip to content

Commit

Permalink
Merge pull request #194 from Syxton/restore_gnumsections-fix
Browse files Browse the repository at this point in the history
Fix import error to courses not set to use grid, thanks @Syxton 👍🏻
  • Loading branch information
gjb2048 authored Oct 21, 2023
2 parents 3b9321e + 046fb65 commit fa18405
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backup/moodle2/restore_format_grid_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,15 @@ public function process_gridsection($data) {
Because the backup file / course being restored from has the correct 'sections', i.e. that will be in the
'course_sections' table. */
$courseid = $this->task->get_courseid();
static $gnumsections = 0;
$gnumsections++;

// We don't know how many more sections there is and also don't know if this is the last.
$courseformat = course_get_format($courseid);
$courseformat->restore_gnumsections($gnumsections);

if ($courseformat->get_format() == 'grid') {
static $gnumsections = 0;
$gnumsections++;
$courseformat->restore_gnumsections($gnumsections);
}
}
/* Allow this to process even if not in the grid format so that our event observer on 'course_restored'
can perform a clean up of restored grid image files after all the data is in place in the database
Expand Down

0 comments on commit fa18405

Please sign in to comment.