Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Course class. More...
Public Member Functions | |
__construct ($mode, $updatemode, $rawdata, $defaults=array(), $importoptions=array()) | |
Constructor. More... | |
can_create () | |
Does the mode allow for course creation? More... | |
can_delete () | |
Does the mode allow for course deletion? More... | |
can_only_create () | |
Does the mode only allow for course creation? More... | |
can_rename () | |
Does the mode allow for course rename? More... | |
can_reset () | |
Does the mode allow for course reset? More... | |
can_update () | |
Does the mode allow for course update? More... | |
can_use_defaults () | |
Can we use default values? More... | |
get_data () | |
Return the data that will be used upon saving. More... | |
get_errors () | |
Return the errors found during preparation. More... | |
get_id () | |
Return the ID of the processed course. More... | |
get_statuses () | |
Return the errors found during preparation. More... | |
has_errors () | |
Return whether there were errors with this course. More... | |
prepare () | |
Validates and prepares the data. More... | |
proceed () | |
Proceed with the import of the course. More... | |
Protected Member Functions | |
delete () | |
Delete the current course. More... | |
error ($code, lang_string $message) | |
Log an error. More... | |
exists ($shortname=null) | |
Return whether the course exists or not. More... | |
get_final_create_data ($data) | |
Assemble the course data based on defaults. More... | |
get_final_update_data ($data, $usedefaults=false, $missingonly=false) | |
Assemble the course data based on defaults. More... | |
get_restore_content_dir () | |
Get the directory of the object to restore. More... | |
get_valid_fields () | |
Return array of valid fields for default values. More... | |
process_enrolment_data ($course) | |
Add the enrolment data for the course. More... | |
reset ($course) | |
Reset the current course. More... | |
status ($code, lang_string $message) | |
Log a status. More... | |
Protected Attributes | |
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. More... | |
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. More... | |
Static Protected Attributes | |
static array | $importoptionsdefaults |
options determining what can or cannot be done at an import level. More... | |
static array | $mandatoryfields = array('fullname', 'category') |
fields required on course creation. | |
static array | $optionfields |
fields which are considered as options. More... | |
static array | $validfields |
fields allowed as course data. More... | |
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 |
|
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.