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 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 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

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

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

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

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().

param: array $data current data.
return: array

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().

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

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

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

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

param: object $course course record.
return: void

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

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

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

param: int $roleid Role ID.
return: bool

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

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

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

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

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