|
Moodle APIs 4.1
Moodle 4.1.9+ (Build: 20240402)
|
Course class. More...
Public Member Functions | |
| __construct ($mode, $updatemode, $rawdata, $defaults=array(), $importoptions=array()) | |
| Constructor. | |
| can_create () | |
| Does the mode allow for course creation? | |
| can_delete () | |
| Does the mode allow for course deletion? | |
| can_only_create () | |
| Does the mode only allow for course creation? | |
| can_rename () | |
| Does the mode allow for course rename? | |
| can_reset () | |
| Does the mode allow for course reset? | |
| can_update () | |
| Does the mode allow for course update? | |
| can_use_defaults () | |
| Can we use default values? | |
| get_data () | |
| Return the data that will be used upon saving. | |
| get_errors () | |
| Return the errors found during preparation. | |
| get_id () | |
| Return the ID of the processed course. | |
| get_statuses () | |
| Return the errors found during preparation. | |
| has_errors () | |
| Return whether there were errors with this course. | |
| prepare () | |
| Validates and prepares the data. | |
| proceed () | |
| Proceed with the import of the course. | |
Protected Member Functions | |
| delete () | |
| Delete the current course. | |
| error ($code, lang_string $message) | |
| Log an error. | |
| exists ($shortname=null) | |
| Return whether the course exists or not. | |
| get_final_create_data ($data) | |
| Assemble the course data based on defaults. | |
| get_final_update_data ($data, $usedefaults=false, $missingonly=false) | |
| Assemble the course data based on defaults. | |
| get_restore_content_dir () | |
| Get the directory of the object to restore. | |
| get_valid_fields () | |
| Return array of valid fields for default values. | |
| process_enrolment_data ($course) | |
| Add the enrolment data for the course. | |
| reset ($course) | |
| Reset the current course. | |
| status ($code, lang_string $message) | |
| Log a status. | |
| validate_enrolment_data (int $courseid, array $enrolmentdata) | |
| Validate passed enrolment data against an existing course. | |
| validate_role_context (int $courseid, string $role) | |
| Check if role is allowed in course context. | |
| validate_role_context_level (int $roleid) | |
| Check if role is allowed at this context level. | |
Protected Attributes | |
| array | $assignableroles = [] |
| assignable roles. | |
| array | $contextlevels = [] |
| Roles context levels. | |
| array | $data = array() |
| final import data. | |
| array | $defaults = array() |
| default values. | |
| int | $do |
| constant value of self::DO_*, what to do with that course | |
| array | $enrolmentdata |
| enrolment data. | |
| array | $errors = array() |
| errors. | |
| int | $id |
| the ID of the course that had been processed. | |
| array | $importoptions = array() |
| containing options passed from the processor. | |
| int | $mode |
| import mode. | |
| array | $options = array() |
| course import options. | |
| bool | $prepared = false |
| set to true once we have prepared the course | |
| bool | $processstarted = false |
| set to true once we have started the process of the course | |
| array | $rawdata = array() |
| course import data. | |
| array | $restoredata |
| restore directory. | |
| string | $shortname |
| course shortname. | |
| array | $statuses = array() |
| errors. | |
| int | $updatemode |
| update mode. | |
Static Protected Attributes | |
| static array | $importoptionsdefaults |
| options determining what can or cannot be done at an import level. | |
| static array | $mandatoryfields = array('fullname', 'category') |
| fields required on course creation. | |
| static array | $optionfields |
| fields which are considered as options. | |
| static array | $validfields |
| fields allowed as course data. | |
Course class.
| tool_uploadcourse_course::__construct | ( | $mode, | |
| $updatemode, | |||
| $rawdata, | |||
$defaults = array(), |
|||
$importoptions = array() |
|||
| ) |
Constructor.
| int | $mode | import mode, constant matching tool_uploadcourse_processor::MODE_* |
| int | $updatemode | update mode, constant matching tool_uploadcourse_processor::UPDATE_* |
| array | $rawdata | raw course data. |
| array | $defaults | default course data. |
| array | $importoptions | import options. |
| tool_uploadcourse_course::can_create | ( | ) |
Does the mode allow for course creation?
| bool |
| tool_uploadcourse_course::can_delete | ( | ) |
Does the mode allow for course deletion?
| bool |
| tool_uploadcourse_course::can_only_create | ( | ) |
Does the mode only allow for course creation?
| bool |
| tool_uploadcourse_course::can_rename | ( | ) |
Does the mode allow for course rename?
| bool |
| tool_uploadcourse_course::can_reset | ( | ) |
Does the mode allow for course reset?
| bool |
| tool_uploadcourse_course::can_update | ( | ) |
Does the mode allow for course update?
| bool |
| tool_uploadcourse_course::can_use_defaults | ( | ) |
Can we use default values?
| bool |
|
protected |
Delete the current course.
| bool |
|
protected |
Log an error.
| string | $code | error code. |
| lang_string | $message | error message. |
| void |
|
protected |
Return whether the course exists or not.
| string | $shortname | the shortname to use to check if the course exists. Falls back on $this->shortname if empty. |
| bool |
| tool_uploadcourse_course::get_data | ( | ) |
Return the data that will be used upon saving.
| null|array |
| tool_uploadcourse_course::get_errors | ( | ) |
Return the errors found during preparation.
| array |
|
protected |
Assemble the course data based on defaults.
This returns the final data to be passed to create_course().
| array | $data | current data. |
| array |
|
protected |
Assemble the course data based on defaults.
This returns the final data to be passed to update_course().
| array | $data | current data. |
| bool | $usedefaults | are defaults allowed? |
| bool | $missingonly | ignore fields which are already set. |
| array |
| tool_uploadcourse_course::get_id | ( | ) |
Return the ID of the processed course.
| int|null |
|
protected |
Get the directory of the object to restore.
| string|false|null | subdirectory in $CFG->backuptempdir/..., false when an error occured and null when there is simply nothing. |
| tool_uploadcourse_course::get_statuses | ( | ) |
Return the errors found during preparation.
| array |
|
protected |
Return array of valid fields for default values.
| array |
| tool_uploadcourse_course::has_errors | ( | ) |
Return whether there were errors with this course.
| boolean |
| tool_uploadcourse_course::prepare | ( | ) |
Validates and prepares the data.
| bool | false is any error occured. |
| tool_uploadcourse_course::proceed | ( | ) |
Proceed with the import of the course.
| void |
|
protected |
Add the enrolment data for the course.
| object | $course | course record. |
| void |
|
protected |
Reset the current course.
This does not reset any of the content of the activities.
| stdClass | $course | the course object of the course to reset. |
| array | status array of array component, item, error. |
|
protected |
Log a status.
| string | $code | status code. |
| lang_string | $message | status message. |
| void |
|
protected |
Validate passed enrolment data against an existing course.
| int | $courseid | |
| array[] | $enrolmentdata |
| lang_string[] | Errors keyed on error code |
|
protected |
Check if role is allowed in course context.
| int | $courseid | course context. |
| string | $role | Role. |
| bool |
|
protected |
Check if role is allowed at this context level.
| int | $roleid | Role ID. |
| bool |
|
staticprotected |
options determining what can or cannot be done at an import level.
|
protected |
import mode.
Matches tool_uploadcourse_processor::MODE_*
|
staticprotected |
fields which are considered as options.
|
protected |
update mode.
Matches tool_uploadcourse_processor::UPDATE_*
|
staticprotected |
fields allowed as course data.