Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Files | |
file | install.php |
This file is executed right after the install.xml. | |
file | upgrade.php |
This file keeps track of upgrades to Moodle. | |
file | upgradelib.php |
Upgrade helper functions. | |
Functions | |
make_competence_scale () | |
Create another default scale. More... | |
object | make_default_scale () |
This function creates a default separated/connected scale so there's something in the database. More... | |
upgrade_analytics_fix_contextids_defaults () | |
Fix the incorrect default values inserted into analytics contextids field. | |
upgrade_block_positions () | |
Delete orphaned records in block_positions. | |
upgrade_calculated_grade_items ($courseid=null) | |
Marks all courses that require calculated grade items be updated. More... | |
upgrade_convert_hub_config_site_param_names (stdClass $hubconfig, string $huburl) | |
Convert the site settings for the 'hub' component in the config_plugins table. More... | |
upgrade_course_letter_boundary ($courseid=null) | |
Marks all courses that require rounded grade items be updated. More... | |
upgrade_delete_orphaned_file_records () | |
Deletes file records which have their repository deleted. | |
upgrade_extra_credit_weightoverride ($onlycourseid=0) | |
Marks all courses with changes in extra credit weight calculation. More... | |
upgrade_fix_block_instance_configuration () | |
Fix configdata in block instances that are using the old object class that has been removed (deprecated). | |
upgrade_fix_serialized_objects ($serializeddata) | |
Provides a way to check and update a serialized string that uses the deprecated object class. More... | |
upgrade_group_members_only ($groupingid, $availability) | |
Using data for a single course-module that has groupmembersonly enabled, returns the new availability value that incorporates the correct groupmembersonly option. More... | |
upgrade_letter_boundary_needs_freeze ($context) | |
Checks the letter boundary of the provided context to see if it needs freezing. More... | |
upgrade_mysql_get_supported_tables () | |
Returns all non-view and non-temp tables with sane names. More... | |
upgrade_rename_prediction_actions_useful_incorrectly_flagged () | |
Updates the existing prediction actions in the database according to the new suggested actions. More... | |
upgrade_standardise_score ($rawgrade, $sourcemin, $sourcemax, $targetmin, $targetmax) | |
Given a float value situated between a source minimum and a source maximum, converts it to the corresponding value situated between a target minimum and a target maximum. More... | |
xmldb_main_install () | |
Main post-install tasks to be executed after the BD schema is available. More... | |
xmldb_main_upgrade ($oldversion) | |
Main upgrade tasks to be executed on Moodle version bump. More... | |
make_competence_scale | ( | ) |
Create another default scale.
int | $oldversion |
bool | always true |
object make_default_scale | ( | ) |
This function creates a default separated/connected scale so there's something in the database.
The locations of strings and files is a bit odd, but this is because we need to maintain backward compatibility with many different existing language translations and older sites.
void |
upgrade_calculated_grade_items | ( | $courseid = null | ) |
Marks all courses that require calculated grade items be updated.
Used during upgrade and in course restore process.
This upgrade script is needed because the calculated grade items were stuck with a maximum of 100 and could be changed. This flags the courses that are affected and the grade book is frozen to retain grade integrity.
int | $courseid | Specify a course ID to run this script on just one course. |
upgrade_convert_hub_config_site_param_names | ( | stdClass | $hubconfig, |
string | $huburl | ||
) |
Convert the site settings for the 'hub' component in the config_plugins table.
stdClass | $hubconfig | Settings loaded for the 'hub' component. |
string | $huburl | The URL of the hub to use as the valid one in case of conflict. |
stdClass | List of new settings to be applied (including null values to be unset). |
upgrade_course_letter_boundary | ( | $courseid = null | ) |
Marks all courses that require rounded grade items be updated.
Used during upgrade and in course restore process.
This upgrade script is needed because it has been decided that if a grade is rounded up, and it will changed a letter grade or satisfy a course completion grade criteria, then it should be set as so, and the letter will be awarded and or the course completion grade will be awarded.
int | $courseid | Specify a course ID to run this script on just one course. |
upgrade_extra_credit_weightoverride | ( | $onlycourseid = 0 | ) |
Marks all courses with changes in extra credit weight calculation.
Used during upgrade and in course restore process
This upgrade script is needed because we changed the algorithm for calculating the automatic weights of extra credit items and want to prevent changes in the existing student grades.
int | $onlycourseid |
upgrade_fix_serialized_objects | ( | $serializeddata | ) |
Provides a way to check and update a serialized string that uses the deprecated object class.
string | $serializeddata | Serialized string which may contain the now deprecated object. |
array | Returns an array where the first variable is a bool with a status of whether the initial data was changed or not. The second variable is the said data. |
upgrade_group_members_only | ( | $groupingid, | |
$availability | |||
) |
Using data for a single course-module that has groupmembersonly enabled, returns the new availability value that incorporates the correct groupmembersonly option.
Included as a function so that it can be shared between upgrade and restore, and unit-tested.
int | $groupingid | Grouping id for the course-module (0 if none) |
string | $availability | Availability JSON data for the module (null if none) |
string | New value for availability for the module |
upgrade_letter_boundary_needs_freeze | ( | $context | ) |
Checks the letter boundary of the provided context to see if it needs freezing.
Each letter boundary is tested to see if receiving that boundary number will result in achieving the cosponsoring letter.
object | $context | Context object |
bool | if the letter boundary for this context should be frozen. |
upgrade_mysql_get_supported_tables | ( | ) |
Returns all non-view and non-temp tables with sane names.
Prints list of non-supported tables using $OUTPUT->notification()
array |
upgrade_rename_prediction_actions_useful_incorrectly_flagged | ( | ) |
Updates the existing prediction actions in the database according to the new suggested actions.
null |
upgrade_standardise_score | ( | $rawgrade, | |
$sourcemin, | |||
$sourcemax, | |||
$targetmin, | |||
$targetmax | |||
) |
Given a float value situated between a source minimum and a source maximum, converts it to the corresponding value situated between a target minimum and a target maximum.
Thanks to Darlene for the formula :-)
float | $rawgrade | |
float | $sourcemin | |
float | $sourcemax | |
float | $targetmin | |
float | $targetmax |
float | Converted value |
xmldb_main_install | ( | ) |
Main post-install tasks to be executed after the BD schema is available.
This function is automatically executed after Moodle core DB has been created at initial install. It's in charge of perform the initial tasks not covered by the install.xml file, like create initial users, roles, templates, moving stuff from other plugins...
Note that the function is only invoked once, at install time, so if new tasks are needed in the future, they will need to be added both here (for new sites) and in the corresponding upgrade.php file (for existing sites).
All plugins within Moodle (modules, blocks, reports...) support the existence of their own install.php file, using the "Frankenstyle" component name as defined at * - @javalink xmldb_page_install(). (modules don't require the plugintype ("mod_") to be used.
Finally, note that it's also supported to have one uninstall.php file that is executed also once, each time one plugin is uninstalled (before the DB schema is deleted). Those uninstall files will contain one function, using the "Frankenstyle" naming conventions, like } or xmldb_workshop_uninstall().
xmldb_main_upgrade | ( | $oldversion | ) |
Main upgrade tasks to be executed on Moodle version bump.
This function is automatically executed after one bump in the Moodle core version is detected. It's in charge of performing the required tasks to raise core from the previous version to the next one.
It's a collection of ordered blocks of code, named "upgrade steps", each one performing one isolated (from the rest of steps) task. Usually tasks involve creating new DB objects or performing manipulation of the information for cleanup/fixup purposes.
Each upgrade step has a fixed structure, that can be summarised as follows:
if ($oldversion < XXXXXXXXXX.XX) { // Explanation of the update step, linking to issue in the Tracker if necessary upgrade_set_timeout(XX); // Optional for big tasks // Code to execute goes here, usually the XMLDB Editor will // help you here. See http://docs.moodle.org/dev/XMLDB_editor. upgrade_main_savepoint(true, XXXXXXXXXX.XX); }
All plugins within Moodle (modules, blocks, reports...) support the existence of their own upgrade.php file, using the "Frankenstyle" component name as defined at * - @javalink xmldb_page_upgrade($oldversion). (modules don't require the plugintype ("mod_") to be used.
In order to keep the contents of this file reduced, it's allowed to create some helper functions to be used here in the upgradelib.php file at the same directory. Note that such a file must be manually included from upgrade.php, and there are some restrictions about what can be used within it.
For more information, take a look to the documentation available:
int | $oldversion |
bool | always true |