Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

File containing the course class.

Copyright: 2013 Frédéric Massart
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1226 lines (49 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

tool_uploadcourse_course:: (28 methods):
  __construct()
  can_create()
  can_delete()
  can_only_create()
  can_rename()
  can_reset()
  can_update()
  can_use_defaults()
  delete()
  error()
  exists()
  get_data()
  get_errors()
  get_valid_fields()
  get_final_create_data()
  get_final_update_data()
  get_id()
  get_restore_content_dir()
  get_statuses()
  has_errors()
  prepare()
  proceed()
  validate_enrolment_data()
  process_enrolment_data()
  validate_role_context()
  validate_role_context_level()
  reset()
  status()


Class: tool_uploadcourse_course  - X-Ref

Course class.

__construct($mode, $updatemode, $rawdata, $defaults = array()   X-Ref
Constructor

param: int $mode import mode, constant matching tool_uploadcourse_processor::MODE_*
param: int $updatemode update mode, constant matching tool_uploadcourse_processor::UPDATE_*
param: array $rawdata raw course data.
param: array $defaults default course data.
param: array $importoptions import options.

can_create()   X-Ref
Does the mode allow for course creation?

return: bool

can_delete()   X-Ref
Does the mode allow for course deletion?

return: bool

can_only_create()   X-Ref
Does the mode only allow for course creation?

return: bool

can_rename()   X-Ref
Does the mode allow for course rename?

return: bool

can_reset()   X-Ref
Does the mode allow for course reset?

return: bool

can_update()   X-Ref
Does the mode allow for course update?

return: bool

can_use_defaults()   X-Ref
Can we use default values?

return: bool

delete()   X-Ref
Delete the current course.

return: bool

error($code, lang_string $message)   X-Ref
Log an error

return: void
param: string $code error code.
param: lang_string $message error message.

exists($shortname = null)   X-Ref
Return whether the course exists or not.

return: bool
param: string $shortname the shortname to use to check if the course exists. Falls back on $this->shortname if empty.

get_data()   X-Ref
Return the data that will be used upon saving.

return: null|array

get_errors()   X-Ref
Return the errors found during preparation.

return: array

get_valid_fields()   X-Ref
Return array of valid fields for default values

return: array

get_final_create_data($data)   X-Ref
Assemble the course data based on defaults.

This returns the final data to be passed to create_course().

return: array
param: array $data current data.

get_final_update_data($data, $usedefaults = false, $missingonly = false)   X-Ref
Assemble the course data based on defaults.

This returns the final data to be passed to update_course().

return: array
param: array $data current data.
param: bool $usedefaults are defaults allowed?
param: bool $missingonly ignore fields which are already set.

get_id()   X-Ref
Return the ID of the processed course.

return: int|null

get_restore_content_dir()   X-Ref
Get the directory of the object to restore.

return: string|false|null subdirectory in $CFG->backuptempdir/..., false when an error occured

get_statuses()   X-Ref
Return the errors found during preparation.

return: array

has_errors()   X-Ref
Return whether there were errors with this course.

return: boolean

prepare()   X-Ref
Validates and prepares the data.

return: bool false is any error occured.

proceed()   X-Ref
Proceed with the import of the course.

return: void

validate_enrolment_data(int $courseid, array $enrolmentdata)   X-Ref
Validate passed enrolment data against an existing course

return: lang_string[] Errors keyed on error code
param: int $courseid
param: array[] $enrolmentdata

process_enrolment_data($course)   X-Ref
Add the enrolment data for the course.

return: void
param: object $course course record.

validate_role_context(int $courseid, string $role)   X-Ref
Check if role is allowed in course context

return: bool
param: int $courseid course context.
param: string $role Role.

validate_role_context_level(int $roleid)   X-Ref
Check if role is allowed at this context level.

return: bool
param: int $roleid Role ID.

reset($course)   X-Ref
Reset the current course.

This does not reset any of the content of the activities.

return: array status array of array component, item, error.
param: stdClass $course the course object of the course to reset.

status($code, lang_string $message)   X-Ref
Log a status

return: void
param: string $code status code.
param: lang_string $message status message.