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] [Versions 39 and 310]

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

Defines 1 class

tool_uploadcourse_course:: (26 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()
  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

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