Course class.
More...
|
| __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.
|
|
|
const | DO_CREATE = 1 |
| Outcome of the process: creating the course.
|
|
const | DO_DELETE = 3 |
| Outcome of the process: deleting the course.
|
|
const | DO_UPDATE = 2 |
| Outcome of the process: updating the course.
|
|
|
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 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.
- Copyright
- 2013 Frédéric Massart
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
tool_uploadcourse_course::__construct |
( |
| $mode, |
|
|
| $updatemode, |
|
|
| $rawdata, |
|
|
| $defaults = array(), |
|
|
| $importoptions = array() ) |
Constructor.
- Parameters
-
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. |
◆ can_create()
tool_uploadcourse_course::can_create |
( |
| ) |
|
Does the mode allow for course creation?
- Return values
-
◆ can_delete()
tool_uploadcourse_course::can_delete |
( |
| ) |
|
Does the mode allow for course deletion?
- Return values
-
◆ can_only_create()
tool_uploadcourse_course::can_only_create |
( |
| ) |
|
Does the mode only allow for course creation?
- Return values
-
◆ can_rename()
tool_uploadcourse_course::can_rename |
( |
| ) |
|
Does the mode allow for course rename?
- Return values
-
◆ can_reset()
tool_uploadcourse_course::can_reset |
( |
| ) |
|
Does the mode allow for course reset?
- Return values
-
◆ can_update()
tool_uploadcourse_course::can_update |
( |
| ) |
|
Does the mode allow for course update?
- Return values
-
◆ can_use_defaults()
tool_uploadcourse_course::can_use_defaults |
( |
| ) |
|
Can we use default values?
- Return values
-
◆ delete()
tool_uploadcourse_course::delete |
( |
| ) |
|
|
protected |
Delete the current course.
- Return values
-
◆ error()
tool_uploadcourse_course::error |
( |
| $code, |
|
|
lang_string | $message ) |
|
protected |
Log an error.
- Parameters
-
string | $code | error code. |
lang_string | $message | error message. |
- Return values
-
◆ exists()
tool_uploadcourse_course::exists |
( |
| $shortname = null | ) |
|
|
protected |
Return whether the course exists or not.
- Parameters
-
string | $shortname | the shortname to use to check if the course exists. Falls back on $this->shortname if empty. |
- Return values
-
◆ get_data()
tool_uploadcourse_course::get_data |
( |
| ) |
|
Return the data that will be used upon saving.
- Return values
-
◆ get_errors()
tool_uploadcourse_course::get_errors |
( |
| ) |
|
Return the errors found during preparation.
- Return values
-
◆ get_final_create_data()
tool_uploadcourse_course::get_final_create_data |
( |
| $data | ) |
|
|
protected |
Assemble the course data based on defaults.
This returns the final data to be passed to create_course().
- Parameters
-
- Return values
-
◆ get_final_update_data()
tool_uploadcourse_course::get_final_update_data |
( |
| $data, |
|
|
| $usedefaults = false, |
|
|
| $missingonly = false ) |
|
protected |
Assemble the course data based on defaults.
This returns the final data to be passed to update_course().
- Parameters
-
array | $data | current data. |
bool | $usedefaults | are defaults allowed? |
bool | $missingonly | ignore fields which are already set. |
- Return values
-
◆ get_id()
tool_uploadcourse_course::get_id |
( |
| ) |
|
Return the ID of the processed course.
- Return values
-
◆ get_restore_content_dir()
tool_uploadcourse_course::get_restore_content_dir |
( |
| ) |
|
|
protected |
Get the directory of the object to restore.
- Return values
-
string|false|null | subdirectory in $CFG->backuptempdir/..., false when an error occured and null when there is simply nothing. |
◆ get_statuses()
tool_uploadcourse_course::get_statuses |
( |
| ) |
|
Return the errors found during preparation.
- Return values
-
◆ get_valid_fields()
tool_uploadcourse_course::get_valid_fields |
( |
| ) |
|
|
protected |
Return array of valid fields for default values.
- Return values
-
◆ has_errors()
tool_uploadcourse_course::has_errors |
( |
| ) |
|
Return whether there were errors with this course.
- Return values
-
◆ prepare()
tool_uploadcourse_course::prepare |
( |
| ) |
|
Validates and prepares the data.
- Return values
-
bool | false is any error occured. |
◆ proceed()
tool_uploadcourse_course::proceed |
( |
| ) |
|
Proceed with the import of the course.
- Return values
-
◆ process_enrolment_data()
tool_uploadcourse_course::process_enrolment_data |
( |
| $course | ) |
|
|
protected |
Add the enrolment data for the course.
- Parameters
-
object | $course | course record. |
- Return values
-
◆ reset()
tool_uploadcourse_course::reset |
( |
| $course | ) |
|
|
protected |
Reset the current course.
This does not reset any of the content of the activities.
- Parameters
-
stdClass | $course | the course object of the course to reset. |
- Return values
-
array | status array of array component, item, error. |
◆ status()
tool_uploadcourse_course::status |
( |
| $code, |
|
|
lang_string | $message ) |
|
protected |
Log a status.
- Parameters
-
string | $code | status code. |
lang_string | $message | status message. |
- Return values
-
◆ validate_enrolment_data()
tool_uploadcourse_course::validate_enrolment_data |
( |
int | $courseid, |
|
|
array | $enrolmentdata ) |
|
protected |
Validate passed enrolment data against an existing course.
- Parameters
-
int | $courseid | |
array[] | $enrolmentdata | |
- Return values
-
lang_string[] | Errors keyed on error code |
◆ validate_role_context()
tool_uploadcourse_course::validate_role_context |
( |
int | $courseid, |
|
|
string | $role ) |
|
protected |
Check if role is allowed in course context.
- Parameters
-
int | $courseid | course context. |
string | $role | Role. |
- Return values
-
◆ validate_role_context_level()
tool_uploadcourse_course::validate_role_context_level |
( |
int | $roleid | ) |
|
|
protected |
Check if role is allowed at this context level.
- Parameters
-
- Return values
-
◆ $importoptionsdefaults
array tool_uploadcourse_course::$importoptionsdefaults |
|
staticprotected |
Initial value:=
array(
'canrename' =>
false,
'candelete' =>
false,
'canreset' =>
false,
'reset' => false, 'restoredir' => null, 'shortnametemplate' => null)
options determining what can or cannot be done at an import level.
◆ $mode
int tool_uploadcourse_course::$mode |
|
protected |
import mode.
Matches tool_uploadcourse_processor\MODE_*
◆ $optionfields
array tool_uploadcourse_course::$optionfields |
|
staticprotected |
Initial value:=
array(
'delete' =>
false,
'rename' =>
null,
'backupfile' =>
null,
'templatecourse' => null, 'reset' => false)
fields which are considered as options.
◆ $updatemode
int tool_uploadcourse_course::$updatemode |
|
protected |
update mode.
Matches tool_uploadcourse_processor\UPDATE_*
◆ $validfields
array tool_uploadcourse_course::$validfields |
|
staticprotected |
Initial value:=
array(
'fullname',
'shortname',
'idnumber',
'category',
'visible',
'startdate',
'enddate',
'summary', 'format', 'theme', 'lang', 'newsitems', 'showgrades', 'showreports', 'legacyfiles', 'maxbytes',
'groupmode', 'groupmodeforce', 'enablecompletion', 'downloadcontent', 'showactivitydates')
fields allowed as course data.
The documentation for this class was generated from the following file:
- admin/tool/uploadcourse/classes/course.php