Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_contentbank_generator Class Reference

Generator for the core_contentbank subsystem. More...

Inheritance diagram for core_contentbank_generator:
component_generator_base

Public Member Functions

 generate_contentbank_data (?string $contenttype, int $itemstocreate=1, int $userid=0, ?\context $context=null, bool $convert2class=true, string $filepath='contentfile.h5p', string $contentname='Test content ', int $visibility=content::VISIBILITY_PUBLIC)
 Populate contentbank database tables with relevant data to simulate the process of adding items to the content bank.
 
 reset ()
 To be called from data reset code only, do not use in tests.
 

Protected Member Functions

 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
 

Detailed Description

Generator for the core_contentbank subsystem.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ generate_contentbank_data()

core_contentbank_generator::generate_contentbank_data ( ?string $contenttype,
int $itemstocreate = 1,
int $userid = 0,
?\context $context = null,
bool $convert2class = true,
string $filepath = 'contentfile.h5p',
string $contentname = 'Test content ',
int $visibility = content::VISIBILITY_PUBLIC )

Populate contentbank database tables with relevant data to simulate the process of adding items to the content bank.

Parameters
string$contenttypeContent bank plugin type to add. If none is defined, contenttype_testable is used.
int$itemstocreateNumber of items to add to the content bank.
int$useridThe user identifier creating the content.
context$contextThe context where the content will be created.
bool$convert2classWhether the class should return stdClass or plugin instance.
string$filepathThe filepath of the file associated to the content to create.
string$contentnameThe name of the content that will be created.
int$visibilityThe visibility of the content that will be created.
Return values
arrayAn array with all the records added to the content bank.

◆ insert_files()

component_generator_base::insert_files ( stdClass $instance,
stdClass $record,
string $table,
context $context,
string $component,
string $filearea,
int $targetitemid )
protectedinherited

Update the instance record, inserting any files that are referenced.

Parameters
stdClass$instanceThe instance record of the already-created record
stdClass$recordThe data passed in to create the instance
string$tableThe table that the data exists in
context$contextThe context of the instance
string$componentThe component of the owning plugin
string$fileareaThe name of the file area
int$targetitemidThe itemid to use when saving the files
Return values
stdClassThe updated instance record

◆ reset()

◆ set_user()

component_generator_base::set_user ( ?stdClass $user = null)
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.

Parameters
stdClass$user

The documentation for this class was generated from the following file: