Function: restoreCourse()
function restoreCourse(
context,
siteUrl,
file,
__namedParameters
): Promise<{
activityIds?: number[];
changed: string;
course: CourseRef;
sectionIds?: number[];
warnings?: RestoreWarning[];
}>;
Defined in: areas/backup/backup.ts:573
Restores a backup file (.mbz) through Moodle's restore wizard: into a new course in a category
(into: "new", with categoryId, which needs moodle/course:create there), or into an existing
course (into: <course id>), its content added to the course's (mode: "merge", the default) or
replacing it ("replace": the course's content is deleted first). A new course takes the backup's
names unless fullName and shortName are given. Users' data is restored when withUsers and the
backup has it. An asynchronous restore is waited for up to timeoutMs (ten minutes). Needs
moodle/restore:restorecourse where it restores.
Before the wizard, the backup is read: one made on a newer Moodle than the site's, or holding activities of a type the site doesn't offer the person in that course, is refused (Moodle would warn only, or skip those activities without a word).
Merged into an existing course, Moodle puts each of the backup's sections into the course's section
of the same number (creating it when there's none) and each activity at the end of it; sectionId
puts every restored activity at the end of that section instead, and afterSectionId makes each
of the backup's sections a new section, in order, after that one (the driver restores, then moves
what Moodle made: one move per section). With either, a section of the course that Moodle changed
on the way (named, described, hidden or restricted as the backup's, when it had none) is put back.
Returns the sections and activities the course has new, in the course's order.
Parameters
| Parameter | Type | Description |
|---|---|---|
context | BrowserContext | - |
siteUrl | string | - |
file | string | - |
__namedParameters | { afterSectionId?: number; categoryId?: number; fullName?: string; into: number | "new"; mode?: "replace" | "merge"; sectionId?: number; shortName?: string; timeoutMs?: number; withUsers?: boolean; } | - |
__namedParameters.afterSectionId? | number | Merged into an existing course: the backup's sections as new sections after this one. |
__namedParameters.categoryId? | number | - |
__namedParameters.fullName? | string | - |
__namedParameters.into | number | "new" | - |
__namedParameters.mode? | "replace" | "merge" | - |
__namedParameters.sectionId? | number | Merged into an existing course: every restored activity at the end of this section. |
__namedParameters.shortName? | string | - |
__namedParameters.timeoutMs? | number | - |
__namedParameters.withUsers? | boolean | - |
Returns
Promise<{
activityIds?: number[];
changed: string;
course: CourseRef;
sectionIds?: number[];
warnings?: RestoreWarning[];
}>