1 This files describes API changes in /mod/* - activity modules,
2 information provided here is intended especially for developers.
5 * The mod_assignment plugin has been completely removed from core.
6 It has been moved to github repository https://github.com/moodlehq/moodle-mod_assignment.
7 It should only be used/re-installed to restore backups older than 1.9.
11 * The callback get_shortcuts() is now removed. Please use get_course_content_items and get_all_content_items instead.
14 * A new API function introduced to handle custom completion logic. Refer to completion/upgrade.txt for additional information.
15 * Modules that extend the settings navigation via '_extend_settings_navigation()' should use the get_page() method from
16 the settings_navigation class in order to obtain the correct moodle_page information associated to the given settings
17 navigation. After the recent changes to the navigation in single activity courses, using the global $PAGE may result
18 in returning inaccurate data in this course format, therefore it is advisable to use $settingsnavigation->get_page().
19 * A new style of icons has been created for activities. When creating an icon in the new style it should be named
20 'monologo' and can site alongside the legacy icon if desired. Only the new logo types will be used.
21 * There is a new callback ..._calculate_question_stats which needs to be implemented by components which want
22 to contribute statistics to the display in the question bank. There is an example implementation in mod_quiz.
23 (Added in 4.0.4 / 4.1.)
27 * The callback get_shortcuts() is now deprecated. Please use get_course_content_items and get_all_content_items instead.
28 See source code examples in get_course_content_items() and get_all_content_items() in mod/lti/lib.php for details.
29 * When creating the calendar events and setting the event description to match the module intro description, the filters
30 must not be applied on the passed description text. Doing so leads to loosing some expected text filters features and
31 causes unnecessarily early theme and output initialisation in unit tests. If your activity creates calendar events,
32 you probably have code like:
34 $event->description = format_module_intro('quiz', $quiz, $cmid);
36 You need to change it to:
38 $event->description = format_module_intro('quiz', $quiz, $cmid, false);
39 $event->format = FORMAT_HTML;
41 Even this is still technically wrong. Content should normally only be formatted just before it is output. Ideally, we
42 should pass the raw description text, format and have a way to copy the embedded files; or provide another way for the
43 calendar to call the right format_text() later. The calendar API does not allow us to do these things easily at the
44 moment. Therefore, this compromise approach is used. The false parameter added ensures that text filters are not run
45 at this time which is important. And the format must be set to HTML, because otherwise it would use the current user's
46 preferred editor default format.
47 * Related to the above and to help with detecting the problematic places in contributed 3rd party modules, the
48 testing_module_generator::create_instance() now throws coding_exception if creating a module instance initialised the
49 theme and output as a side effect.
53 * The final deprecation of xxx_print_overview() callback means that this function will no longer be called.
54 * Activities which define multiple grade items must now describe the mapping of the gradeitem's itemnumber to a
55 meaningful name in a class implementing \core_grades\local\gradeitem\itemnumber_mapping located in
56 \mod_name\grades\gradeitems (located in mod/[mod_name]/classes/grades/gradeitems.php).
60 * The final deprecation of xxx_get_types() callback means that this function will no longer be called.
61 Please use get_shortcuts() instead.
62 * lti_get_shortcuts has been deprecated. Please use get_shortcuts() instead to add items to the activity chooser.
63 * Now, when mod_<modname>_core_calendar_is_event_visible or mod_<modname>_core_calendar_provide_event_action callback functions
64 are called, the userid of the requesting user is also passed to them.
65 * The following functions have been finally deprecated and can not be used anymore:
66 - update_module_button()
67 * The final deprecation of xxx_delete_course callback means that this function will no longer be called.
68 Please use the observer for event \core\event\course_content_deleted instead.
72 * There is a new privacy API that every subsystem and plugin has to implement so that the site can become GDPR
73 compliant. Activity modules use this API to report what information they store or process regarding users, and provide
74 ability to export and delete personal data. See https://docs.moodle.org/dev/Privacy_API for guidelines on how to
75 implement the privacy API in your activity module.
76 * Backup directory now can be outside of temp directory. Use make_backup_temp_directory($name) instead of
77 make_temp_directory('/backup/'.$name)
78 * Modules that provide their own interactive content and call cm_info::set_content() from [MODULENAME]_cm_info_view()
79 callback should format all user input and call set_content() with parameter $isformatted=true . Otherwise
80 scripts will be cleaned on the course page in case of $CFG->forceclean=1. See example in mod_folder.
84 * Navigation between activities via a previous and next link was added to Boost, Clean and Bootstrapbase. This
85 was made possible by a new function core_renderer->activity_navigation(). However, there was an issue when linking
86 to the mod_resource and mod_url view.php pages where it would automatically download the file, or redirect to
87 the URL. It was noticed that this was not the case when editing the module and clicking 'Save and display' which would
88 take you to the pages without downloading the file or redirecting to a link. The reason this worked was because of the
89 hard-coded check 'if (strpos(get_local_referer(false), 'modedit.php') === false) {' in the view.php files. This check
90 has been removed in favour of an optional_param('forceview'). If you are using the above hard-coded check in your
91 plugin it is recommended to remove it and use the optional param as it will prevent the navigation from working as
96 * External functions that were returning file information now return the following additional file fields:
97 - mimetype (the file mime type)
98 - isexternalfile (if is a file reference to a external repository)
99 - repositorytype (the repository name in case is a external file)
100 Those fields are VALUE_OPTIONAL for backwards compatibility.
101 * The block_course_overview has been removed and the related core module
102 *_print_overview functions have been deprecated.
103 * The block_myoverview has replaced block_course_overview to provide better information to students. To support this,
104 actions can now be attached to calendar events. Documentation for the following new API callbacks introduced in
105 MDL-55611 can be found at https://docs.moodle.org/dev/Calendar_API. The 3 new callbacks are:
106 - mod_<modname>_core_calendar_is_event_visible
107 - mod_<modname>_core_calendar_provide_event_action
108 - mod_<modname>_core_calendar_event_action_shows_item_count
109 * Changes to the moodleform_mod class and its usage (MDL-58138):
110 - the get_data() method has been overriden. The implementation calls parent::get_data() and a new data_postprocessing() method
111 - new data_postprocessing() method added. Mods can override this in their mod_form subclass to modify the submit data. Previously
112 mods could only modify submitted data by overriding get_data() in the mod_form subclass. data_postprocessing() is now the way to
114 - completion: \core_completion\manager calls the overriden mod_x_mod_form->data_postprocessing() to allow mods to modify their
115 completion data before saving the bulk completion form. If you've overriden get_data() to modify submit data for completion in
116 the past, you should now override the data_postprocessing() method in your mod_form and move your code there, so bulk completion
117 editing will be properly supported for your plugin.
120 * Callback delete_course is deprecated and should be replaced with observer for event \core\event\course_content_deleted
121 * update_module_button() and core_renderer::update_module_button() have been deprecated and should not be used anymore.
122 Activity modules should not add the edit module button, the link is already available in the Administration block.
123 Themes can choose to display the link in the buttons row consistently for all module types.
124 * New callback check_updates_since available. Check if the module has any update that affects the current user since the given time.
125 Please refer to mod/assign/lib.php, mod/forum/lib.php or mod/quiz/lib.php for sample code.
129 * Old /mod/MODULENAME/pix/icon.gif and enrol/paypal/pix/icon.gif GIF icons have been removed. Please use pix_icon
131 * Callback get_types() is deprecated, instead activity modules can define callback get_shortcuts().
132 See source code for get_module_metadata().
136 * Dropped support for the $module in mod/xxx/version.php files (deprecated
137 since 2.7). All activity modules must use the $plugin syntax now. See
138 https://docs.moodle.org/dev/version.php for details (MDL-43896).
139 * Modules using rating component must implement a callback mod_x_rating_can_see_item_ratings(). Refer
140 to mod_forum_rating_can_see_item_ratings() for example.
144 * Added Grade to pass field to mod_form for activities that support grading.
145 * The method moodleform_mod::add_intro_editor() used in mod_form.php form
146 definitions has been deprecated. Replace it with the new
147 moodleform_mod::standard_intro_elements() method that takes the new site
148 configuration requiremodintro into account (MDL-49101).
152 * Constant FEATURE_GROUPMEMBERSONLY is deprecated. Modules should remove this
153 constant from their module_supports() API function.
154 * $CFG->enablegroupmembersonly no longer exists.
158 * modgrade form element has been redesigned and allows setting the maximum grade point higher than 100.
159 * The usage of $module in mod/xxx/version.php files is now deprecated. Please use
160 $plugin instead. The support for the legacy notation will be dropped in Moodle 2.10.
161 * xxx_get_view_actions() and xxx_get_post_actions() will be ignored by new logging system for
162 participation report. view_action and post_action will be detected by event's crud and edulevel.
163 * The functions xxx_user_outline() and xxx_user_complete() have been removed from the majority of core modules (see MDL-41286),
164 except for those that require unique functionality. These functions are used by the outline report, but now if they no longer
165 exist, the default behaviour is chosen, which supports the legacy and standard log storages introduced in 2.7 (see MDL-41266).
166 It is highly recommended you remove these functions from your module if they are simply performing the default behaviour.
170 * Modules using the question bank MUST now declare their use of it with the xxx_supports()
171 flag FEATURE_USES_QUESTIONS.
172 * xxx_get_types() module callback can now return subtypes that have
173 a custom help text set. Also instead of array it can now return
174 MOD_SUBTYPE_NO_CHILDREN. This is optional and still defaults to prior
175 behavior. See get_module_metadata() in course/lib.php for details.
176 * shift_course_mod_dates() has been modified to accept optional mod instance id. If mod instance id is passed then
177 dates changed will happen only on specific module instance and not on all instances of that module in course.
181 * support for 'mod/*' filters was removed
187 * mod/xxx/adminlib.php may now include 'plugininfo_yoursubplugintype' class definition
188 used by plugin_manager; it is recommended to store extra admin settings classes in this file
190 optional - no changes needed:
192 * mod_lesson_renderer::header() now accepts an additional parameter $extrapagetitle
194 * mod/data/lib.php data_get_all_recordids() now has two new optional variables: $selectdata and $params.
198 required changes in code:
200 * define the capability mod/xxx:addinstance (and the corresponding lang string)
201 (unless your mod is a MOD_ARCHETYPE_SYSTEM).
202 * xxx_pluginfile() is now given the 7th parameter (hopefully the last one) that
203 contains additional options for the file serving. The array should be re-passed
204 to send_stored_file().
206 * most resourcelib_embed_* functions are replaced with core_media_renderer;
207 for an example, see mod/resource/locallib.php, resource_display_embed()
209 optional - no changes needed:
211 * add support for handling course drag and drop types - functions
212 xxx_dndupload_register() and xxx_dndupload_handle($uploadinfo) see:
213 http://docs.moodle.org/dev/Implementing_Course_drag_and_drop_upload_support_in_a_module
217 required changes in code:
218 * fix missing parameter types in optional_param() and required_param()
219 * use new optional_param_array(), required_param_array() or clean_param_array() when dealing with array parameters
220 * core_text::asort() replaced by specialized core_collator::asort()
221 * use new make_temp_directory() and make_cache_directory()
226 required changes in code:
227 * add new support for basic restore from 1.9
232 required changes in code:
233 * use new DML syntax everywhere
234 (http://docs.moodle.org/dev/DML_functions)
235 * use new DDL syntax in db/upgrade.php
236 (http://docs.moodle.org/dev/DDL_functions)
237 * replace defaults.php by settings.php and db/install.php
238 * replace STATEMENTS section in db/install.xml with PHP code db/install.php or db/log.php
239 * move post installation code from lib.php into db/install.php
240 * move uninstallation code from lib.php to db/uninstall.php
241 * new mandatory naming of intro and introformat table fields in module tables,
242 the presence of these fields is indicated in xxx_plugin_supports()
243 * completely rewrite file handling
244 (http://docs.moodle.org/dev/File_API)
245 * rewrite backup/restore
247 * rewrite trusttext support - new db table columns needed
248 * migrate all module features from mod_edit.php form to lib.php/modulename_supports() function
249 * implement new gradebook support (legacy 1.8.x grading not supported anymore)
250 * migrate custom resource module subtypes into separate modules,
251 necessary only for custom plugins in mod/resource/
252 * use new $PAGE and $OUTPUT instead of old weblib functions
253 * theme changes: move plugin styles into mod/xxx/styles.css and use new css markers for images,
254 move all images into new mod/xxx/pix/ directory and use new outputlib api
255 move module icon to mod/xxx/pix/icon.gif
256 old global $THEME is fully replaced by $OUTPUT
257 create plugin renderers
258 (http://docs.moodle.org/dev/Theme_changes_in_2.0)
259 * migrate all javascript new coding style using YUI3+YUI2
260 (http://docs.moodle.org/dev/JavaScript_usage_guide)
261 * remove '_utf8' from lang pack names, use new {a} syntax
262 * replace helps with new 'xxx_hlp' strings
263 * please note the $plugin->requires in version.php has to be bigger than 2010000000,
264 otherwise the plugin is marked as outdated and upgrade is interrupted
266 optional - no changes needed in older code:
267 * settingstree.php replaced by settings.php - just unset the $settings if you want to make custom part of settings admin tree
268 * support for new mforms editor element and embedded files
271 (http://docs.moodle.org/dev/Portfolio_API)
272 * course completion tracking support
273 * new navigation features
275 (http://docs.moodle.org/dev/Comments_2.0)
277 (http://docs.moodle.org/dev/Ratings_2.0)