Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Public Member Functions | |
create_content_file (string $file, string $filearea, int $contentid=0) | |
Add a record on files table for a file that belongs to. | |
create_content_types (array $typestonotinstall, core $core) | |
Create H5P content type records in the h5p_libraries database table. | |
create_contents_libraries_record (string $h5pid, int $libid, string $dependencytype='preloaded') | |
Create a record in the h5p_contents_libraries database table. | |
create_export_file (string $filename, int $contextid, string $component, string $filearea, int $typeurl=self::WSPLUGINFILE) | |
Create a fake export H5P deployed file. | |
create_file (string $file, string $content='') | |
Convenience function to create a file. | |
create_h5p_record (int $mainlibid, string $jsoncontent=null, string $filtered=null, ?array $filerecord=null) | |
Create a record in the h5p database table. | |
create_library (string $uploaddirectory, int $libraryid, string $machinename, int $majorversion, int $minorversion, ?array $langs=[]) | |
Create the necessary files and return an array structure for a library. | |
create_library_dependency_record (int $libid, int $requiredlibid, string $dependencytype='preloaded') | |
Create a record in the h5p_library_dependencies database table. | |
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) | |
Create a record in the h5p_libraries database table. | |
generate_h5p_data (bool $createlibraryfiles=false, ?array $filerecord=null) | |
Populate H5P database tables with relevant data to simulate the process of adding H5P content. | |
reset () | |
To be called from data reset code only, do not use in tests. | |
Public Attributes | |
const | PLUGINFILE = 2 |
Url pointing to plugin file. | |
const | TOKENPLUGINFILE = 1 |
Url pointing to token plugin file. | |
const | WSPLUGINFILE = 0 |
Url pointing to webservice plugin file. | |
Protected Member Functions | |
add_libfile_to_array (string $type, string $path, string $version, &$files) | |
Creates the file record. | |
insert_files (stdClass $instance, stdClass $record, string $table, context $context, string $component, string $filearea, int $targetitemid) | |
Update the instance record, inserting any files that are referenced. | |
set_user (?stdClass $user=null) | |
Set the current user during data generation. | |
Protected Attributes | |
testing_data_generator | $datagenerator |
|
protected |
Creates the file record.
Currently used for the cache tests.
string | $type | Either 'scripts' or 'styles'. |
string | $path | Path to the file in the file system. |
string | $version | Not really needed at the moment. |
core_h5p_generator::create_content_file | ( | string | $file, |
string | $filearea, | ||
int | $contentid = 0 ) |
Add a record on files table for a file that belongs to.
string | $file | File name and path inside the filearea. |
string | $filearea | The filearea in which the file is ("editor" or "content"). |
int | $contentid | Id of the H5P content to which the file belongs. null if the file is in the editor. |
stored_file; |
coding_exception |
core_h5p_generator::create_content_types | ( | array | $typestonotinstall, |
core | $core ) |
Create H5P content type records in the h5p_libraries database table.
array | $typestonotinstall | H5P content types that should not be installed |
core | $core | h5p_test_core instance required to use the exttests URL |
array | Data of the content types not installed. |
invalid_response_exception | If request to get the latest content types fails (usually due to a transient error) |
core_h5p_generator::create_contents_libraries_record | ( | string | $h5pid, |
int | $libid, | ||
string | $dependencytype = 'preloaded' ) |
Create a record in the h5p_contents_libraries database table.
string | $h5pid | The ID of the H5P content |
int | $libid | The ID of the library |
string | $dependencytype | The dependency type |
int | The ID of the added record |
core_h5p_generator::create_export_file | ( | string | $filename, |
int | $contextid, | ||
string | $component, | ||
string | $filearea, | ||
int | $typeurl = self::WSPLUGINFILE ) |
Create a fake export H5P deployed file.
string | $filename | Name of the H5P file to deploy. |
int | $contextid | Context id of the H5P activity. |
string | $component | component. |
string | $filearea | file area. |
int | $typeurl | Type of url to create the export url plugin file. |
array | return deployed file information. |
core_h5p_generator::create_file | ( | string | $file, |
string | $content = '' ) |
Convenience function to create a file.
string | $file | path to a file. |
string | $content | file content. |
core_h5p_generator::create_h5p_record | ( | int | $mainlibid, |
string | $jsoncontent = null, | ||
string | $filtered = null, | ||
?array | $filerecord = null ) |
Create a record in the h5p database table.
int | $mainlibid | The ID of the content's main library |
string | $jsoncontent | The content in json format |
string | $filtered | The filtered content parameters |
array | null | $filerecord | The file associated to the H5P entry. |
int | The ID of the added record |
core_h5p_generator::create_library | ( | string | $uploaddirectory, |
int | $libraryid, | ||
string | $machinename, | ||
int | $majorversion, | ||
int | $minorversion, | ||
?array | $langs = [] ) |
Create the necessary files and return an array structure for a library.
string | $uploaddirectory | Base directory for the library. |
int | $libraryid | Library id. |
string | $machinename | Name for this library. |
int | $majorversion | Major version (any number will do). |
int | $minorversion | Minor version (any number will do). |
array | $langs | Languages to be included into the library. |
array | A list of library data and files that the core API will understand. |
core_h5p_generator::create_library_dependency_record | ( | int | $libid, |
int | $requiredlibid, | ||
string | $dependencytype = 'preloaded' ) |
Create a record in the h5p_library_dependencies database table.
int | $libid | The ID of the library |
int | $requiredlibid | The ID of the required library |
string | $dependencytype | The dependency type |
int | The ID of the added record |
core_h5p_generator::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 ) |
Create a record in the h5p_libraries database table.
string | $machinename | The library machine name |
string | $title | The library's name |
int | $majorversion | The library's major version |
int | $minorversion | The library's minor version |
int | $patchversion | The library's patch version |
string | $semantics | Json describing the content structure for the library |
string | $addto | The plugin configuration data |
string | $tutorial | The tutorial URL |
string | $examlpe | The example URL |
bool | $enabled | Whether the library is enabled or not |
int | $runnable | Whether the library is runnable (1) or not (0) |
stdClass | An object representing the added library record |
core_h5p_generator::generate_h5p_data | ( | bool | $createlibraryfiles = false, |
?array | $filerecord = null ) |
Populate H5P database tables with relevant data to simulate the process of adding H5P content.
bool | $createlibraryfiles | Whether to create and store library files on the filesystem |
array | null | $filerecord | The file associated to the H5P entry. |
stdClass | An object representing the added H5P records |
|
protectedinherited |
Update the instance record, inserting any files that are referenced.
stdClass | $instance | The instance record of the already-created record |
stdClass | $record | The data passed in to create the instance |
string | $table | The table that the data exists in |
context | $context | The context of the instance |
string | $component | The component of the owning plugin |
string | $filearea | The name of the file area |
int | $targetitemid | The itemid to use when saving the files |
stdClass | The updated instance record |
|
inherited |
To be called from data reset code only, do not use in tests.
void |
Reimplemented in core_competency_generator, core_notes_generator, core_question_generator, mod_book_generator, mod_chat_generator, mod_data_generator, mod_forum_generator, mod_glossary_generator, mod_lesson_generator, mod_survey_generator, mod_wiki_generator, testing_block_generator, testing_module_generator, testing_repository_generator, and tool_dataprivacy_generator.
|
protectedinherited |
Set the current user during data generation.
This should be avoided wherever possible, but in some situations underlying code will insert data as the current user.
stdClass | $user |