Search moodle.org's
Developer Documentation


/course/ -> modlib.php (summary)

Library of functions specific to course/modedit.php and course API functions. The course API function calling them are course/lib.php:create_module() and update_module(). This file has been created has an alternative solution to a full refactor of course/modedit.php in order to create the course API functions.

Copyright: 2013 Jerome Mouneyrac
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 561 lines (23 kb)
Included or required:0 times
Referenced: 4 times
Includes or requires: 0 files

Defines 7 functions


Functions that are not part of a class:

add_moduleinfo($moduleinfo, $course, $mform = null)   X-Ref
Add course module.

The function does not check user capabilities.
The function creates course module, module instance, add the module to the correct section.
It also trigger common action that need to be done after adding/updating a module.

param: object $moduleinfo the moudle data
param: object $course the course of the module
param: object $mform this is required by an existing hack to deal with files during MODULENAME_add_instance()
return: object the updated module info

edit_module_post_actions($moduleinfo, $course)   X-Ref
Common create/update module module actions that need to be processed as soon as a module is created/updaded.
For example:create grade parent category, add outcomes, rebuild caches, regrade, save plagiarism settings...
Please note this api does not trigger events as of MOODLE 2.6. Please trigger events before calling this api.

param: object $moduleinfo the module info
param: object $course the course of the module
return: object moduleinfo update with grading management info

set_moduleinfo_defaults($moduleinfo)   X-Ref
Set module info default values for the unset module attributs.

param: object $moduleinfo the current known data of the module
return: object the completed module info

can_add_moduleinfo($course, $modulename, $section)   X-Ref
Check that the user can add a module. Also returns some information like the module, context and course section info.
The fucntion create the course section if it doesn't exist.

param: object $course the course of the module
param: object $modulename the module name
param: object $section the section of the module
return: array list containing module, context, course section.

can_update_moduleinfo($cm)   X-Ref
Check if user is allowed to update module info and returns related item/data to the module.

param: object $cm course module
return: array - list of course module, context, module, moduleinfo, and course section.

update_moduleinfo($cm, $moduleinfo, $course, $mform = null)   X-Ref
Update the module info.
This function doesn't check the user capabilities. It updates the course module and the module instance.
Then execute common action to create/update module process (trigger event, rebuild cache, save plagiarism settings...).

param: object $cm course module
param: object $moduleinfo module info
param: object $course course of the module
param: object $mform - the mform is required by some specific module in the function MODULE_update_instance(). This is due to a hack in this function.
return: array list of course module and module info.

include_modulelib($modulename)   X-Ref
Include once the module lib file.

param: string $modulename module name of the lib to include

Search This Site: