See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
File containing the helper class.
Copyright: | 2013 Frédéric Massart |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 598 lines (21 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
tool_uploadcourse_helper:: (17 methods):
generate_shortname()
generate_shortname_callback()
get_course_formats()
get_enrolment_data()
get_enrolment_plugins()
get_restore_content_dir()
get_role_ids()
get_coursesection_count()
get_role_names()
get_custom_course_fields()
get_custom_course_field_names()
get_custom_course_field_data()
increment_idnumber()
increment_shortname()
resolve_category()
resolve_category_by_idnumber()
resolve_category_by_path()
Class: tool_uploadcourse_helper - X-Ref
Class containing a set of helpers.generate_shortname($data, $templateshortname) X-Ref |
Generate a shortname based on a template. param: array|object $data course data. param: string $templateshortname template of shortname. return: null|string shortname based on the template, or null when an error occured. |
generate_shortname_callback($fullname, $idnumber, $block) X-Ref |
Callback used when generating a shortname based on a template. param: string $fullname full name. param: string $idnumber ID number. param: array $block result from preg_replace_callback. return: string |
get_course_formats() X-Ref |
Return the available course formats. return: array |
get_enrolment_data($data) X-Ref |
Extract enrolment data from passed data. Constructs an array of methods, and their options: array( 'method1' => array( 'option1' => value, 'option2' => value ), 'method2' => array( 'option1' => value, 'option2' => value ) ) param: array $data data to extract the enrolment data from. return: array |
get_enrolment_plugins() X-Ref |
Return the enrolment plugins. The result is cached for faster execution. return: enrol_plugin[] |
get_restore_content_dir($backupfile = null, $shortname = null, &$errors = array() X-Ref |
Get the restore content tempdir. The tempdir is the sub directory in which the backup has been extracted. This caches the result for better performance, but $CFG->keeptempdirectoriesonbackup needs to be enabled, otherwise the cache is ignored. param: string $backupfile path to a backup file. param: string $shortname shortname of a course. param: array $errors will be populated with errors found. return: string|false false when the backup couldn't retrieved. |
get_role_ids() X-Ref |
Return the role IDs. The result is cached for faster execution. return: array |
get_coursesection_count($shortname) X-Ref |
Helper to detect how many sections a course with a given shortname has. param: string $shortname shortname of a course to count sections from. return: integer count of sections. |
get_role_names($data, &$errors = array() X-Ref |
Get the role renaming data from the passed data. param: array $data data to extract the names from. param: array $errors will be populated with errors found. return: array where the key is the role_<id>, the value is the new name. |
get_custom_course_fields() X-Ref |
Return array of all custom course fields indexed by their shortname return: \core_customfield\field_controller[] |
get_custom_course_field_names() X-Ref |
Return array of custom field element names return: string[] |
get_custom_course_field_data(array $data, array $defaults, context $context,array &$errors = []) X-Ref |
Return any elements from passed $data whose key matches one of the custom course fields defined for the site param: array $data param: array $defaults param: context $context param: array $errors Will be populated with any errors return: array |
increment_idnumber($idnumber) X-Ref |
Helper to increment an ID number. This first checks if the ID number is in use. param: string $idnumber ID number to increment. return: string new ID number. |
increment_shortname($shortname) X-Ref |
Helper to increment a shortname. This considers that the shortname passed has to be incremented. param: string $shortname shortname to increment. return: string new shortname. |
resolve_category($data, &$errors = array() X-Ref |
Resolve a category based on the data passed. Key accepted are: - category, which is supposed to be a category ID. - category_idnumber - category_path, array of categories from parent to child. param: array $data to resolve the category from. param: array $errors will be populated with errors found. return: int category ID. |
resolve_category_by_idnumber($idnumber) X-Ref |
Resolve a category by ID number. param: string $idnumber category ID number. return: int category ID. |
resolve_category_by_path(array $path) X-Ref |
Resolve a category by path. param: array $path category names indexed from parent to children. return: int category ID. |