Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
Contains helper class for the H5P area.
Copyright: | 2019 Sara Arjona <sara@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 476 lines (18 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
helper:: (15 methods):
save_h5p()
get_messages()
get_display_options()
decode_display_options()
can_deploy_package()
can_update_library()
create_fake_stored_file_from_path()
get_h5p_tools_info()
convert_info_into_array()
get_cache_buster()
get_core_settings()
get_core_assets()
get_cache_librarykey()
parse_js_array()
get_export_info()
save_h5p(factory $factory, \stored_file $file, \stdClass $config, bool $onlyupdatelibs = false,bool $skipcontent = false) X-Ref |
Store an H5P file. return: int|false|null The H5P identifier or null if there is an error when saving or false if it's not a valid H5P package param: factory $factory The \core_h5p\factory object param: stored_file $file Moodle file instance param: stdClass $config Button options config param: bool $onlyupdatelibs Whether new libraries can be installed or only the existing ones can be updated param: bool $skipcontent Should the content be skipped (so only the libraries will be saved)? |
get_messages(\stdClass $messages, factory $factory) X-Ref |
Get the error messages stored in our H5P framework. return: stdClass with framework error messages. param: stdClass $messages The error, exception and info messages, raised while preparing and running an H5P content. param: factory $factory The \core_h5p\factory object |
get_display_options(core $core, \stdClass $config) X-Ref |
Get the representation of display options as int. return: int The representation of display options as int param: core $core The \core_h5p\core object param: stdClass $config Button options config |
decode_display_options(core $core, int $displayint = null) X-Ref |
Convert the int representation of display options into stdClass return: int The representation of display options as int param: core $core The \core_h5p\core object param: int $displayint integer value representing display options |
can_deploy_package(\stored_file $file) X-Ref |
Checks if the author of the .h5p file is "trustable". If the file hasn't been uploaded by a user with the required capability, the content won't be deployed. return: bool Returns true if the file can be deployed, false otherwise. param: stored_file $file The .h5p file to be deployed |
can_update_library(\stored_file $file) X-Ref |
Checks if the content-type libraries can be upgraded. The H5P content-type libraries can only be upgraded if the author of the .h5p file can manage content-types or if all the content-types exist, to avoid users without the required capability to upload malicious content. return: bool Returns true if the content-type libraries can be created/updated, false otherwise. param: stored_file $file The .h5p file to be deployed |
create_fake_stored_file_from_path(string $filepath, int $userid = 0,\context $context = null) X-Ref |
Convenience to take a fixture test file and create a stored_file. return: stored_file The file created param: string $filepath The filepath of the file param: int $userid The author of the file param: \context $context The context where the file will be created |
get_h5p_tools_info() X-Ref |
Get information about different H5P tools and their status. return: array Data to render by the template |
convert_info_into_array(string $tool,\moodle_url $link,int $status,string $statusaction = '') X-Ref |
Convert information into needed mustache template data array return: array param: string $tool The name of the tool param: \moodle_url $link The URL to management page param: int $status The current status of the tool param: string $statusaction A link to 'Run now' option for the task |
get_cache_buster() X-Ref |
Get a query string with the theme revision number to include at the end of URLs. This is used to force the browser to reload the asset when the theme caches are cleared. return: string |
get_core_settings() X-Ref |
Get the settings needed by the H5P library. return: array The settings. |
get_core_assets() X-Ref |
Get the core H5P assets, including all core H5P JavaScript and CSS. return: Array core H5P assets. |
get_cache_librarykey(string $library) X-Ref |
Prepare the library name to be used as a cache key (remove whitespaces and replace dots to underscores). return: string Library name in a cache simple key format (a-zA-Z0-9_). param: string $library Library name. |
parse_js_array(string $jscontent) X-Ref |
Parse a JS array to a PHP array. return: array The JS array converted to PHP array. param: string $jscontent The JS array to parse to PHP array. |
get_export_info(string $exportfilename, \moodle_url $url = null, ?factory $factory = null) X-Ref |
Get the information related to the H5P export file. The information returned will be: - filename, filepath, mimetype, filesize, timemodified and fileurl. return: array|null The information export file otherwise null. param: string $exportfilename The H5P export filename (with slug). param: \moodle_url $url The URL of the exported file. param: factory $factory The \core_h5p\factory object |