Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401]

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: 170 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

copy:: (1 method):
  __construct()

instead:: (4 methods):
  get_enrollment_roles()
  get_copy_data()
  create_copy()
  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.

Class: instead  - X-Ref

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.

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.