Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Functions that are not part of a class:

h5pactivity_supports(string $feature)   X-Ref
Checks if H5P activity supports a specific feature.

param: string $feature FEATURE_xx constant for requested feature
return: mixed True if module supports feature, false if not, null if doesn't know or string for the module purpose.

h5pactivity_add_instance(stdClass $data, mod_h5pactivity_mod_form $mform = null)   X-Ref
Saves a new instance of the mod_h5pactivity into the database.

Given an object containing all the necessary data, (defined by the form
in mod_form.php) this function will create a new instance and return the id
number of the instance.

param: stdClass $data An object from the form.
param: mod_h5pactivity_mod_form $mform The form.
return: int The id of the newly inserted record.

h5pactivity_update_instance(stdClass $data, mod_h5pactivity_mod_form $mform = null)   X-Ref
Updates an instance of the mod_h5pactivity in the database.

Given an object containing all the necessary data (defined in mod_form.php),
this function will update an existing instance with new data.

param: stdClass $data An object from the form in mod_form.php.
param: mod_h5pactivity_mod_form $mform The form.
return: bool True if successful, false otherwise.

h5pactivity_delete_instance(int $id)   X-Ref
Removes an instance of the mod_h5pactivity from the database.

param: int $id Id of the module instance.
return: bool True if successful, false on failure.

h5pactivity_scale_used_anywhere(int $scaleid)   X-Ref
Checks if scale is being used by any instance of mod_h5pactivity.

This is used to find out if scale used anywhere.

param: int $scaleid ID of the scale.
return: bool True if the scale is used by any mod_h5pactivity instance.

h5pactivity_grade_item_update(stdClass $moduleinstance, $grades = null)   X-Ref
Creates or updates grade item for the given mod_h5pactivity instance.

Needed by {@link grade_update_mod_grades()}.

param: stdClass $moduleinstance Instance object with extra cmidnumber and modname property.
param: mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
return: int int 0 if ok, error code otherwise

h5pactivity_grade_item_delete(stdClass $moduleinstance)   X-Ref
Delete grade item for given mod_h5pactivity instance.

param: stdClass $moduleinstance Instance object.
return: int Returns GRADE_UPDATE_OK, GRADE_UPDATE_FAILED, GRADE_UPDATE_MULTIPLE or GRADE_UPDATE_ITEM_LOCKED

h5pactivity_update_grades(stdClass $moduleinstance, int $userid = 0)   X-Ref
Update mod_h5pactivity grades in the gradebook.

Needed by {@link grade_update_mod_grades()}.

param: stdClass $moduleinstance Instance object with extra cmidnumber and modname property.
param: int $userid Update grade of specific user only, 0 means all participants.

h5pactivity_rescale_activity_grades(stdClass $course, stdClass $cm, float $oldmin,float $oldmax, float $newmin, float $newmax)   X-Ref
Rescale all grades for this activity and push the new grades to the gradebook.

param: stdClass $course Course db record
param: stdClass $cm Course module db record
param: float $oldmin
param: float $oldmax
param: float $newmin
param: float $newmax
return: bool true if reescale is successful

h5pactivity_reset_course_form_definition(&$mform)   X-Ref
Implementation of the function for printing the form elements that control
whether the course reset functionality affects the H5P activity.

param: MoodleQuickForm $mform form passed by reference

h5pactivity_reset_course_form_defaults(stdClass $course)   X-Ref
Course reset form defaults.

param: stdClass $course the course object
return: array

h5pactivity_reset_userdata(stdClass $data)   X-Ref
This function is used by the reset_course_userdata function in moodlelib.

This function will remove all H5P attempts in the database
and clean up any related data.

param: stdClass $data the data submitted from the reset course.
return: array of reseting status

h5pactivity_reset_gradebook(int $courseid, string $type='')   X-Ref
Removes all grades from gradebook

param: int $courseid Coude ID
param: string $type optional type (default '')

h5pactivity_page_type_list(string $pagetype, ?stdClass $parentcontext, stdClass $currentcontext)   X-Ref
Return a list of page types

param: string $pagetype current page type
param: stdClass|null $parentcontext Block's parent context
param: stdClass $currentcontext Current context of block
return: array array of page types and it's names

h5pactivity_check_updates_since(cm_info $cm, int $from, array $filter = [])   X-Ref
Check if the module has any update that affects the current user since a given time.

param: cm_info $cm course module data
param: int $from the time to check updates from
param: array $filter  if we need to check only specific updates
return: stdClass an object with the different type of areas indicating if they were updated or not

h5pactivity_get_file_areas(stdClass $course, stdClass $cm, stdClass $context)   X-Ref
Returns the lists of all browsable file areas within the given module context.

The file area 'intro' for the activity introduction field is added automatically
by {@link file_browser::get_file_info_context_module()}.

param: stdClass $course course object
param: stdClass $cm course module object
param: stdClass $context context object
return: string[] array of pair file area => human file area name

h5pactivity_get_file_info(file_browser $browser, array $areas, stdClass $course,stdClass $cm, context $context, string $filearea, ?int $itemid = null,?string $filepath = null, ?string $filename = null)   X-Ref
File browsing support for data module.

param: file_browser $browser
param: array $areas
param: stdClass $course
param: stdClass $cm
param: context $context
param: string $filearea
param: int|null $itemid
param: string|null $filepath
param: string|null $filename
return: file_info_stored|null file_info_stored instance or null if not found

h5pactivity_pluginfile($course, $cm, context $context,string $filearea, array $args, bool $forcedownload, array $options = [])   X-Ref
Serves the files from the mod_h5pactivity file areas.

param: mixed $course course or id of the course
param: mixed $cm course module or id of the course module
param: context $context
param: string $filearea
param: array $args
param: bool $forcedownload
param: array $options additional options affecting the file serving
return: bool false if file not found, does not return if found - just send the file

h5pactivity_set_mainfile(stdClass $data)   X-Ref
Saves draft files as the activity package.

param: stdClass $data an object from the form

h5pactivity_dndupload_register()   X-Ref
Register the ability to handle drag and drop file uploads

return: array containing details of the files / types the mod can handle

h5pactivity_dndupload_handle($uploadinfo)   X-Ref
Handle a file that has been uploaded

param: object $uploadinfo details of the file / content that has been uploaded
return: int instance id of the newly created mod

h5pactivity_print_recent_activity($course, bool $viewfullnames, int $timestart)   X-Ref
Print recent activity from all h5pactivities in a given course

This is used by the recent activity block
param: mixed $course the course to print activity for
param: bool $viewfullnames boolean to determine whether to show full names or not
param: int $timestart the time the rendering started
return: bool true if activity was printed, false otherwise.

h5pactivity_get_recent_mod_activity(array &$activities, int &$index, int $timestart, int $courseid,int $cmid, int $userid=0, int $groupid=0)   X-Ref
Returns all h5pactivities since a given time.

param: array $activities The activity information is returned in this array
param: int $index The current index in the activities array
param: int $timestart The earliest activity to show
param: int $courseid Limit the search to this course
param: int $cmid The course module id
param: int $userid Optional user id
param: int $groupid Optional group id
return: void

h5pactivity_print_recent_mod_activity(stdClass $activity, int $courseid, bool $detail, array $modnames)   X-Ref
Print recent activity from all h5pactivities in a given course

This is used by course/recent.php
param: stdClass $activity
param: int $courseid
param: bool $detail
param: array $modnames

h5pactivity_fetch_recent_activity(array $submissions, int $courseid)   X-Ref
Fetches recent activity for course module.

param: array $submissions The activity submissions
param: int $courseid Limit the search to this course
return: array $recentactivity recent activity in a course.

h5pactivity_extend_settings_navigation(settings_navigation $settingsnav,navigation_node $h5pactivitynode = null)   X-Ref
Extends the settings navigation with the H5P activity settings
This function is called when the context for the page is an H5P activity. This is not called by AJAX
so it is safe to rely on the $PAGE.

param: settings_navigation $settingsnav The settings navigation object
param: navigation_node $h5pactivitynode The node to add module settings to