Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

Generator for the core_h5p subsystem.

Copyright: 2019 Victor Deniz <victor@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 583 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: core_h5p_generator  - X-Ref

Generator for the core_h5p subsystem.

create_file(string $file, string $content='')   X-Ref
Convenience function to create a file.

param: string $file path to a file.
param: string $content file content.

add_libfile_to_array(string $type, string $path, string $version, &$files)   X-Ref
Creates the file record. Currently used for the cache tests.

param: string $type    Either 'scripts' or 'styles'.
param: string $path    Path to the file in the file system.
param: string $version Not really needed at the moment.

create_library(string $uploaddirectory, int $libraryid, string $machinename, int $majorversion,int $minorversion, ?array $langs = [])   X-Ref
Create the necessary files and return an array structure for a library.

param: string $uploaddirectory Base directory for the library.
param: int    $libraryid       Library id.
param: string $machinename     Name for this library.
param: int    $majorversion    Major version (any number will do).
param: int    $minorversion    Minor version (any number will do).
param: array  $langs           Languages to be included into the library.
return: array A list of library data and files that the core API will understand.

save_library(stdClass $lib)   X-Ref
Save the library files on the filesystem.

param: stdClss $lib The library data

generate_h5p_data(bool $createlibraryfiles = false)   X-Ref
Populate H5P database tables with relevant data to simulate the process of adding H5P content.

param: bool $createlibraryfiles Whether to create and store library files on the filesystem
return: stdClass An object representing the added H5P records

create_library_record(string $machinename, string $title, int $majorversion = 1,int $minorversion = 0, int $patchversion = 1, string $semantics = '', string $addto = null,string $tutorial = null, string $example = null, bool $enabled = true, int $runnable = 1)   X-Ref
Create a record in the h5p_libraries database table.

param: string $machinename The library machine name
param: string $title The library's name
param: int $majorversion The library's major version
param: int $minorversion The library's minor version
param: int $patchversion The library's patch version
param: string $semantics Json describing the content structure for the library
param: string $addto The plugin configuration data
param: string $tutorial The tutorial URL
param: string $examlpe The example URL
param: bool $enabled Whether the library is enabled or not
param: int $runnable Whether the library is runnable (1) or not (0)
return: stdClass An object representing the added library record

create_h5p_record(int $mainlibid, string $jsoncontent = null, string $filtered = null)   X-Ref
Create a record in the h5p database table.

param: int $mainlibid The ID of the content's main library
param: string $jsoncontent The content in json format
param: string $filtered The filtered content parameters
return: int The ID of the added record

create_contents_libraries_record(string $h5pid, int $libid,string $dependencytype = 'preloaded')   X-Ref
Create a record in the h5p_contents_libraries database table.

param: string $h5pid The ID of the H5P content
param: int $libid The ID of the library
param: string $dependencytype The dependency type
return: int The ID of the added record

create_library_dependency_record(int $libid, int $requiredlibid,string $dependencytype = 'preloaded')   X-Ref
Create a record in the h5p_library_dependencies database table.

param: int $libid The ID of the library
param: int $requiredlibid The ID of the required library
param: string $dependencytype The dependency type
return: int The ID of the added record

create_content_types(array $typestonotinstall, core $core)   X-Ref
Create H5P content type records in the h5p_libraries database table.

param: array $typestonotinstall H5P content types that should not be installed
param: core $core h5p_test_core instance required to use the exttests URL
return: array Data of the content types not installed.

create_content_file(string $file, string $filearea, int $contentid = 0)   X-Ref
Add a record on files table for a file that belongs to

param: string $file File name and path inside the filearea.
param: string $filearea The filearea in which the file is ("editor" or "content").
param: int $contentid Id of the H5P content to which the file belongs. null if the file is in the editor.
return: stored_file;

create_export_file(string $filename, int $contextid,string $component,string $filearea,int $typeurl = self::WSPLUGINFILE)   X-Ref
Create a fake export H5P deployed file.

param: string $filename Name of the H5P file to deploy.
param: int $contextid Context id of the H5P activity.
param: string $component component.
param: string $filearea file area.
param: int $typeurl Type of url to create the export url plugin file.
return: array return deployed file information.