Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
Moodle's implementation of the H5P framework interface. More...
Public Member Functions | |
afterExportCreated ($content, $filename) | |
Will trigger after the export file is created. | |
alterLibrarySemantics (&$semantics, $name, $majorversion, $minorversion) | |
Makes it possible to alter the semantics, adding custom fields, etc. | |
clearFilteredParameters ($libraryids) | |
Will clear filtered params for all the content that uses the specified. | |
copyLibraryUsage ($contentid, $copyfromid, $contentmainid=null) | |
Give an H5P the same library dependencies as a given H5P. | |
deleteCachedAssets ($libraryid) | |
Locate hash keys for given library and delete them. | |
deleteContentData ($contentid) | |
Deletes content data. | |
deleteLibrary ($library) | |
Delete a library from database and file system. | |
deleteLibraryDependencies ($libraryid) | |
Delete all dependencies belonging to given library. | |
deleteLibraryUsage ($contentid) | |
Delete what libraries a content item is using. | |
fetchExternalData ($url, $data=null, $blocking=true, $stream=null, $fulldata=false, $headers=[], $files=[], $method='POST') | |
Fetches a file from a remote server using HTTP GET Implements fetchExternalData. | |
get_file () | |
Get the .h5p file. | |
get_latest_library_version (string $machinename) | |
Get the latest library version. | |
getAdminUrl () | |
Returns the URL to the library admin page. | |
getContentHubMetadataCache ($lang='en') | |
Get content hub metadata cache from db. | |
getContentHubMetadataChecked ($lang='en') | |
Get time of last content hub metadata check. | |
getLibraryConfig ($libraries=null) | |
Load config for libraries. | |
getLibraryContentCount () | |
Get the amount of content items associated to a library. | |
getLibraryFileUrl ($libraryfoldername, $filename) | |
Get URL to file in the specifimake_pluginfile_urlc library. | |
getLibraryId ($machinename, $majorversion=null, $minorversion=null) | |
Return the library's ID. | |
getLibraryStats ($type) | |
Generates statistics from the event log per library. | |
getLibraryUsage ($id, $skipcontent=false) | |
Get number of content/nodes using a library, and the number of dependencies to other libraries. | |
getMessages ($type) | |
Return messages. | |
getNumAuthors () | |
Aggregate the current number of H5P authors. | |
getNumContent ($libraryid, $skip=null) | |
Get number of contents using library as main library. | |
getNumNotFiltered () | |
Get number of contents that has to get their content dependencies rebuilt. | |
getOption ($name, $default=false) | |
Get stored setting. | |
getPlatformInfo () | |
Returns info for the current platform. | |
getUploadedH5pFolderPath ($setpath=null) | |
Get the Path to the last uploaded h5p. | |
getUploadedH5pPath ($setpath=null) | |
Get the path to the last uploaded h5p file. | |
getWhitelist ($islibrary, $defaultcontentwhitelist, $defaultlibrarywhitelist) | |
Get allowed file extension list. | |
hasPermission ($permission, $id=null) | |
Check whether a user has permissions to execute an action, such as embed H5P content. | |
insertContent ($content, $contentmainid=null) | |
Insert new content. | |
isContentSlugAvailable ($slug) | |
Determines if content slug is used. | |
isInDevMode () | |
Is H5P in development mode? Implements isInDevMode. | |
isPatchedLibrary ($library) | |
Is the library a patched version of an existing library? Implements isPatchedLibrary. | |
libraryHasUpgrade ($library) | |
Checks if the given library has a higher version. | |
loadAddons () | |
Load addon libraries. | |
loadContent ($id) | |
Load content. | |
loadContentDependencies ($id, $type=null) | |
Load dependencies for the given content of the given type. | |
loadLibraries () | |
Get a list of the current installed libraries. | |
loadLibrary ($machinename, $majorversion, $minorversion) | |
Loads a library. | |
loadLibrarySemantics ($name, $majorversion, $minorversion) | |
Loads library semantics. | |
lockDependencyStorage () | |
Start an atomic operation against the dependency storage. | |
mayUpdateLibraries () | |
Is the current user allowed to update libraries? Implements mayUpdateLibraries. | |
replaceContentHubMetadataCache ($metadata, $lang) | |
Replace content hub metadata cache. | |
replaceContentTypeCache ($contenttypecache) | |
Replaces existing content type cache with the one passed in. | |
resetContentUserData ($contentid) | |
Resets marked user data for the given content. | |
saveCachedAssets ($key, $libraries) | |
Stores hash keys for cached assets, aggregated JavaScripts and stylesheets, and connects it to libraries so that we know which cache file to delete when a library is updated. | |
saveLibraryData (&$librarydata, $new=true) | |
Store data about a library. | |
saveLibraryDependencies ($libraryid, $dependencies, $dependencytype) | |
Save what libraries a library is depending on. | |
saveLibraryUsage ($contentid, $librariesinuse) | |
Saves what libraries the content uses. | |
set_file (\stored_file $file) | |
Set the .h5p file. | |
setContentHubMetadataChecked ($time, $lang='en') | |
Set time of last content hub metadata check. | |
setErrorMessage ($message, $code=null) | |
Set an error message. | |
setInfoMessage ($message) | |
Set an info message. | |
setLibraryTutorialUrl ($libraryname, $url) | |
Set the tutorial URL for a library. | |
setOption ($name, $value) | |
Stores the given setting. | |
t ($message, $replacements=array()) | |
Translation function. | |
unlockDependencyStorage () | |
Start an atomic operation against the dependency storage. | |
updateContent ($content, $contentmainid=null) | |
Update old content or insert new content. | |
updateContentFields ($id, $fields) | |
This will update selected fields on the given content. | |
Static Public Member Functions | |
static | get_language () |
Get current H5P language code. | |
Moodle's implementation of the H5P framework interface.
core_h5p\framework::afterExportCreated | ( | $content, | |
$filename ) |
Will trigger after the export file is created.
Implements afterExportCreated.
array | $content | The content |
string | $filename | The file name |
core_h5p\framework::alterLibrarySemantics | ( | & | $semantics, |
$name, | |||
$majorversion, | |||
$minorversion ) |
Makes it possible to alter the semantics, adding custom fields, etc.
Implements alterLibrarySemantics.
array | $semantics | Associative array representing the semantics |
string | $name | The library's machine name |
int | $majorversion | The library's major version |
int | $minorversion | The library's minor version |
core_h5p\framework::clearFilteredParameters | ( | $libraryids | ) |
Will clear filtered params for all the content that uses the specified.
libraries. This means that the content dependencies will have to be rebuilt and the parameters re-filtered. Implements clearFilteredParameters().
array | $libraryids | Array of library ids |
core_h5p\framework::copyLibraryUsage | ( | $contentid, | |
$copyfromid, | |||
$contentmainid = null ) |
Give an H5P the same library dependencies as a given H5P.
Implements copyLibraryUsage.
int | $contentid | Id identifying the content |
int | $copyfromid | Id identifying the content to be copied |
int | $contentmainid | Main id for the content, typically used in frameworks |
core_h5p\framework::deleteCachedAssets | ( | $libraryid | ) |
Locate hash keys for given library and delete them.
Used when cache file are deleted. Implements deleteCachedAssets.
int | $libraryid | Library identifier |
array | List of hash keys removed |
core_h5p\framework::deleteContentData | ( | $contentid | ) |
Deletes content data.
Implements deleteContentData.
int | $contentid | Id identifying the content |
core_h5p\framework::deleteLibrary | ( | $library | ) |
Delete a library from database and file system.
Implements deleteLibrary.
stdClass | $library | Library object with id, name, major version and minor version |
core_h5p\framework::deleteLibraryDependencies | ( | $libraryid | ) |
Delete all dependencies belonging to given library.
Implements deleteLibraryDependencies.
int | $libraryid | Library identifier |
core_h5p\framework::deleteLibraryUsage | ( | $contentid | ) |
Delete what libraries a content item is using.
Implements deleteLibraryUsage.
int | $contentid | Content Id of the content we'll be deleting library usage for |
core_h5p\framework::fetchExternalData | ( | $url, | |
$data = null, | |||
$blocking = true, | |||
$stream = null, | |||
$fulldata = false, | |||
$headers = [], | |||
$files = [], | |||
$method = 'POST' ) |
Fetches a file from a remote server using HTTP GET Implements fetchExternalData.
string | $url | Where you want to get or send data. |
array | $data | Data to post to the URL. |
bool | $blocking | Set to 'FALSE' to instantly time out (fire and forget). |
string | $stream | Path to where the file should be saved. |
bool | $fulldata | Return additional response data such as headers and potentially other data |
array | $headers | Headers to send |
array | $files | Files to send |
string | $method |
string|array | The content (response body), or an array with data. NULL if something went wrong |
core_h5p\framework::get_file | ( | ) |
Get the .h5p file.
stored_file | The .h5p file. |
|
static |
Get current H5P language code.
string | Language Code |
core_h5p\framework::get_latest_library_version | ( | string | $machinename | ) |
Get the latest library version.
string | $machinename | The library's machine name |
stdClass|null | An object with the latest library version |
core_h5p\framework::getAdminUrl | ( | ) |
Returns the URL to the library admin page.
Implements getAdminUrl.
string | URL to admin page |
core_h5p\framework::getContentHubMetadataCache | ( | $lang = 'en' | ) |
Get content hub metadata cache from db.
string | $lang | Language code in ISO 639-1 |
JsonSerializable | Json string |
core_h5p\framework::getContentHubMetadataChecked | ( | $lang = 'en' | ) |
Get time of last content hub metadata check.
string | $lang | Language code iin ISO 639-1 format |
string|null | Time in RFC7231 format |
core_h5p\framework::getLibraryConfig | ( | $libraries = null | ) |
Load config for libraries.
Implements getLibraryConfig.
array | null | $libraries | List of libraries |
array|null | The library config if it exists, null otherwise |
core_h5p\framework::getLibraryContentCount | ( | ) |
Get the amount of content items associated to a library.
Implements getLibraryContentCount.
return array The number of content items associated to a library
core_h5p\framework::getLibraryFileUrl | ( | $libraryfoldername, | |
$filename ) |
Get URL to file in the specifimake_pluginfile_urlc library.
Implements getLibraryFileUrl.
string | $libraryfoldername | The name or path of the library's folder |
string | $filename | The file name |
string | URL to file |
core_h5p\framework::getLibraryId | ( | $machinename, | |
$majorversion = null, | |||
$minorversion = null ) |
Return the library's ID.
Implements getLibraryId.
string | $machinename | The librarys machine name |
string | $majorversion | Major version number for library (optional) |
string | $minorversion | Minor version number for library (optional) |
int|bool | Identifier, or false if non-existent |
core_h5p\framework::getLibraryStats | ( | $type | ) |
Generates statistics from the event log per library.
Implements getLibraryStats.
string | $type | Type of event to generate stats for |
array | Number values indexed by library name and version |
core_h5p\framework::getLibraryUsage | ( | $id, | |
$skipcontent = false ) |
Get number of content/nodes using a library, and the number of dependencies to other libraries.
Implements getLibraryUsage.
int | $id | Library identifier |
boolean | $skipcontent | Optional. Set as true to get number of content instances for library |
array | The array contains two elements, keyed by 'content' and 'libraries'. Each element contains a number |
core_h5p\framework::getMessages | ( | $type | ) |
Return messages.
Implements getMessages.
string | $type | The message type, e.g. 'info' or 'error' |
string[] | Array of messages |
core_h5p\framework::getNumAuthors | ( | ) |
Aggregate the current number of H5P authors.
Implements getNumAuthors.
int | The current number of H5P authors |
core_h5p\framework::getNumContent | ( | $libraryid, | |
$skip = null ) |
Get number of contents using library as main library.
Implements getNumContent().
int | $libraryid | The library ID |
array | $skip | The array of h5p content ID's that should be ignored |
int | The number of contents using library as main library |
core_h5p\framework::getNumNotFiltered | ( | ) |
Get number of contents that has to get their content dependencies rebuilt.
and parameters re-filtered. Implements getNumNotFiltered().
int | The number of contents that has to get their content dependencies rebuilt and parameters re-filtered |
core_h5p\framework::getOption | ( | $name, | |
$default = false ) |
Get stored setting.
Implements getOption.
To avoid updating the cache libraries when using the Hub selector, {
string | $name | Identifier for the setting |
string | $default | Optional default value if settings is not set |
mixed | Return Whatever has been stored as the setting |
core_h5p\framework::getPlatformInfo | ( | ) |
Returns info for the current platform.
Implements getPlatformInfo.
array | An associative array containing:
|
core_h5p\framework::getUploadedH5pFolderPath | ( | $setpath = null | ) |
Get the Path to the last uploaded h5p.
Implements getUploadedH5PFolderPath.
string | $setpath | The path to the folder of the last uploaded h5p |
string | Path to the folder where the last uploaded h5p for this session is located |
core_h5p\framework::getUploadedH5pPath | ( | $setpath = null | ) |
Get the path to the last uploaded h5p file.
Implements getUploadedH5PPath.
string | $setpath | The path to the last uploaded h5p |
string | Path to the last uploaded h5p |
core_h5p\framework::getWhitelist | ( | $islibrary, | |
$defaultcontentwhitelist, | |||
$defaultlibrarywhitelist ) |
Get allowed file extension list.
Implements getWhitelist.
The default extension list is part of h5p, but admins should be allowed to modify it.
boolean | $islibrary | TRUE if this is the whitelist for a library. FALSE if it is the whitelist for the content folder we are getting. |
string | $defaultcontentwhitelist | A string of file extensions separated by whitespace. |
string | $defaultlibrarywhitelist | A string of file extensions separated by whitespace. |
string | A string containing the allowed file extensions separated by whitespace. |
core_h5p\framework::hasPermission | ( | $permission, | |
$id = null ) |
Check whether a user has permissions to execute an action, such as embed H5P content.
Implements hasPermission.
H5PPermission | $permission | Permission type |
int | $id | Id need by platform to determine permission |
boolean | true if the user can execute the action defined in $permission; false otherwise |
core_h5p\framework::insertContent | ( | $content, | |
$contentmainid = null ) |
Insert new content.
Implements insertContent.
array | $content | An associative array containing:
|
int | $contentmainid | Main id for the content if this is a system that supports versions |
int | The ID of the newly inserted content |
core_h5p\framework::isContentSlugAvailable | ( | $slug | ) |
Determines if content slug is used.
Implements isContentSlugAvailable.
string | $slug | The content slug |
boolean | Whether the content slug is used |
core_h5p\framework::isInDevMode | ( | ) |
Is H5P in development mode? Implements isInDevMode.
boolean | TRUE if H5P development mode is active FALSE otherwise |
core_h5p\framework::isPatchedLibrary | ( | $library | ) |
Is the library a patched version of an existing library? Implements isPatchedLibrary.
array | $library | An associative array containing:
|
boolean | TRUE if the library is a patched version of an existing library FALSE otherwise |
core_h5p\framework::libraryHasUpgrade | ( | $library | ) |
Checks if the given library has a higher version.
Implements libraryHasUpgrade.
array | $library | An associative array containing:
|
boolean | Whether the library has a higher version |
core_h5p\framework::loadAddons | ( | ) |
Load addon libraries.
Implements loadAddons.
array | The array containing the addon libraries |
core_h5p\framework::loadContent | ( | $id | ) |
Load content.
Implements loadContent.
int | $id | Content identifier |
array | Associative array containing:
|
core_h5p\framework::loadContentDependencies | ( | $id, | |
$type = null ) |
Load dependencies for the given content of the given type.
Implements loadContentDependencies.
int | $id | Content identifier |
int | $type | The dependency type |
array | List of associative arrays containing:
|
core_h5p\framework::loadLibraries | ( | ) |
Get a list of the current installed libraries.
Implements loadLibraries.
array | Associative array containing one entry per machine name. For each machineName there is a list of libraries(with different versions). |
core_h5p\framework::loadLibrary | ( | $machinename, | |
$majorversion, | |||
$minorversion ) |
Loads a library.
Implements loadLibrary.
string | $machinename | The library's machine name |
int | $majorversion | The library's major version |
int | $minorversion | The library's minor version |
array|bool | Returns FALSE if the library does not exist Otherwise an associative array containing:
|
core_h5p\framework::loadLibrarySemantics | ( | $name, | |
$majorversion, | |||
$minorversion ) |
Loads library semantics.
Implements loadLibrarySemantics.
string | $name | Machine name for the library |
int | $majorversion | The library's major version |
int | $minorversion | The library's minor version |
string | The library's semantics as json |
core_h5p\framework::lockDependencyStorage | ( | ) |
Start an atomic operation against the dependency storage.
Implements lockDependencyStorage.
core_h5p\framework::mayUpdateLibraries | ( | ) |
Is the current user allowed to update libraries? Implements mayUpdateLibraries.
boolean | TRUE if the user is allowed to update libraries, FALSE if the user is not allowed to update libraries. |
core_h5p\framework::replaceContentHubMetadataCache | ( | $metadata, | |
$lang ) |
Replace content hub metadata cache.
JsonSerializable | $metadata | Metadata as received from content hub |
string | $lang | Language in ISO 639-1 |
mixed |
core_h5p\framework::replaceContentTypeCache | ( | $contenttypecache | ) |
Replaces existing content type cache with the one passed in.
Implements replaceContentTypeCache.
object | $contenttypecache | Json with an array called 'libraries' containing the new content type cache that should replace the old one |
core_h5p\framework::resetContentUserData | ( | $contentid | ) |
Resets marked user data for the given content.
Implements resetContentUserData.
int | $contentid | The h5p content id |
core_h5p\framework::saveCachedAssets | ( | $key, | |
$libraries ) |
Stores hash keys for cached assets, aggregated JavaScripts and stylesheets, and connects it to libraries so that we know which cache file to delete when a library is updated.
Implements saveCachedAssets.
string | $key | Hash key for the given libraries |
array | $libraries | List of dependencies(libraries) used to create the key |
core_h5p\framework::saveLibraryData | ( | & | $librarydata, |
$new = true ) |
Store data about a library.
Implements saveLibraryData.
Also fills in the libraryId in the libraryData object if the object is new.
array | $librarydata | Associative array containing:
|
bool | $new | Whether it is a new or existing library. |
core_h5p\framework::saveLibraryDependencies | ( | $libraryid, | |
$dependencies, | |||
$dependencytype ) |
Save what libraries a library is depending on.
Implements saveLibraryDependencies.
int | $libraryid | Library Id for the library we're saving dependencies for |
array | $dependencies | List of dependencies as associative arrays containing:
|
string | $dependencytype | The type of dependency |
core_h5p\framework::saveLibraryUsage | ( | $contentid, | |
$librariesinuse ) |
Saves what libraries the content uses.
Implements saveLibraryUsage.
int | $contentid | Id identifying the content |
array | $librariesinuse | List of libraries the content uses |
core_h5p\framework::set_file | ( | \stored_file | $file | ) |
Set the .h5p file.
stored_file | $file | The .h5p file. |
core_h5p\framework::setContentHubMetadataChecked | ( | $time, | |
$lang = 'en' ) |
Set time of last content hub metadata check.
int | null | $time | Time in RFC7231 format |
string | $lang | Language code iin ISO 639-1 format |
bool | True if successful |
core_h5p\framework::setErrorMessage | ( | $message, | |
$code = null ) |
Set an error message.
Implements setErrorMessage.
string | $message | The error message |
string | $code | An optional code |
core_h5p\framework::setInfoMessage | ( | $message | ) |
Set an info message.
Implements setInfoMessage.
string | $message | The info message |
core_h5p\framework::setLibraryTutorialUrl | ( | $libraryname, | |
$url ) |
Set the tutorial URL for a library.
All versions of the library is set. Implements setLibraryTutorialUrl.
string | $libraryname | |
string | $url |
core_h5p\framework::setOption | ( | $name, | |
$value ) |
Stores the given setting.
For example when did we last check h5p.org for updates to our libraries. Implements setOption.
string | $name | Identifier for the setting |
mixed | $value | Data Whatever we want to store as the setting |
core_h5p\framework::t | ( | $message, | |
$replacements = array() ) |
Translation function.
The purpose of this function is to map the strings used in the core h5p methods and replace them with the translated ones. If a translation for a particular string is not available, the default message (key) will be returned. Implements t.
string | $message | The english string to be translated |
array | $replacements | An associative array of replacements to make after translation |
string | Translated string or the english string if a translation is not available |
core_h5p\framework::unlockDependencyStorage | ( | ) |
Start an atomic operation against the dependency storage.
Implements unlockDependencyStorage.
core_h5p\framework::updateContent | ( | $content, | |
$contentmainid = null ) |
Update old content or insert new content.
Implements updateContent.
array | $content | An associative array containing:
|
int | $contentmainid | Main id for the content if this is a system that supports versions |
int | The ID of the newly inserted or updated content |
core_h5p\framework::updateContentFields | ( | $id, | |
$fields ) |
This will update selected fields on the given content.
Implements updateContentFields().
int | $id | Content identifier |
array | $fields | Content fields, e.g. filtered |