Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

Course copy class. Handles procesing data submitted by UI copy form and sets up the course copy process.

Author: Matt Porritt <mattp@catalyst-au.net>
Copyright: 2020 onward The Moodle Users Association <https://moodleassociation.org/>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 309 lines (12 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class

copy:: (6 methods):
  __construct()
  get_enrollment_roles()
  get_copy_data()
  create_copy()
  filter_copies_course()
  get_copies()


Class: copy  - X-Ref

Course copy class.

Handles procesing data submitted by UI copy form
and sets up the course copy process.

__construct(\stdClass $formdata)   X-Ref
Constructor for the class.

param: \stdClass $formdata Data from the validated course copy form.

get_enrollment_roles(\stdClass $formdata)   X-Ref
Extract the enrolment roles to keep in the copied course
from the raw submitted form data.

param: \stdClass $formdata Data from the validated course copy form.
return: array $keptroles The roles to keep.

get_copy_data(\stdClass $formdata)   X-Ref
Take the validated form data and extract the required information for copy operations.

param: \stdClass $formdata Data from the validated course copy form.
return: \stdClass $copydata Data required for course copy operations.

create_copy()   X-Ref
Creates a course copy.
Sets up relevant controllers and adhoc task.

return: array $copyids THe backup and restore controller ids.

filter_copies_course(array $copyrecords, int $courseid)   X-Ref
Filters an array of copy records by course ID.

param: array $copyrecords
param: int $courseid
return: array $copies Filtered array of records.

get_copies(int $userid, int $courseid=0)   X-Ref
Get the in progress course copy operations for a user.

param: int $userid User id to get the course copies for.
param: int $courseid The optional source course id to get copies for.
return: array $copies Details of the inprogress copies.