Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
mod_lesson data generator class. More...
Public Member Functions | |
create_answer ($record=null, array $options=null) | |
Creates an answer in a page for testing purposes. | |
create_cluster (stdClass $lesson, array $record=[]) | |
Creates a cluster page for testing purposes. | |
create_content ($lesson, $record=array()) | |
Creates a content page for testing purposes. | |
create_endofbranch (stdClass $lesson, array $record=[]) | |
Creates a end of branch page for testing purposes. | |
create_endofcluster (stdClass $lesson, array $record=[]) | |
Creates a end of cluster page for testing purposes. | |
create_instance ($record=null, array $options=null) | |
Creates a lesson instance for testing purposes. | |
create_override (array $data) | |
Create a lesson override (either user or group). | |
create_page ($record=null, array $options=null) | |
Creates a page for testing purposes. | |
create_question_essay ($lesson, $record=array()) | |
Create essay question pages. | |
create_question_matching ($lesson, $record=array()) | |
Create matching question pages. | |
create_question_multichoice ($lesson, $record=array()) | |
Create multichoice question pages. | |
create_question_numeric ($lesson, $record=array()) | |
Create shortanswer question pages. | |
create_question_shortanswer ($lesson, $record=array()) | |
Create shortanswer question pages. | |
create_question_truefalse ($lesson, $record=array()) | |
Create True/false question pages. | |
finish_generate_answer () | |
All answers in a table have been generated, create the pages. | |
get_modulename () | |
Returns module name. | |
reset () | |
To be called from data reset code only, do not use in tests. | |
Protected Member Functions | |
convert_page_jumpto (int $lessonid, ?array $jumptolist) | |
Convert the jumpto using a string to an integer value. | |
create_candidate_pages () | |
Create candidate pages. | |
get_previouspage_id (int $lessonid, string $pagetitle) | |
Calculate the previous page id. | |
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. | |
post_add_instance ($id, $cmid) | |
Called after *_add_instance() | |
precreate_course_module ($courseid, array $options) | |
Create course module and link it to course. | |
prepare_moduleinfo_record ($record, $options) | |
Merges together arguments $record and $options and fills default module fields that are shared by all module types. | |
set_user (?stdClass $user=null) | |
Set the current user during data generation. | |
Protected Attributes | |
array | $candidatepages = [] |
list of candidate pages to be created when all answers have been added. | |
testing_data_generator | $datagenerator |
int | $instancecount = 0 |
number of created instances | |
array | $jumptomap |
map of readable jumpto to integer value. | |
int | $pagecount = 0 |
keep track of how many pages have been created. | |
mod_lesson data generator class.
|
protected |
Convert the jumpto using a string to an integer value.
The jumpto can contain a page name or one of our predefined values.
int | $lessonid | the lesson id. |
array | null | $jumptolist | list of jumpto to treat. |
array|null | list of jumpto already treated. |
coding_exception |
mod_lesson_generator::create_answer | ( | $record = null, | |
array | $options = null ) |
Creates an answer in a page for testing purposes.
null | array | stdClass | $record | data for module being generated. |
null | array | $options | general options. |
coding_exception |
|
protected |
Create candidate pages.
coding_exception |
mod_lesson_generator::create_cluster | ( | stdClass | $lesson, |
array | $record = [] ) |
Creates a cluster page for testing purposes.
stdClass | $lesson | instance where to create the page. |
array | $record | data for page being generated. |
stdClass | page record. |
mod_lesson_generator::create_content | ( | $lesson, | |
$record = array() ) |
Creates a content page for testing purposes.
stdClass | $lesson | instance where to create the page. |
array | stdClass | $record | data for page being generated. |
stdClass | page record. |
Reimplemented from testing_module_generator.
mod_lesson_generator::create_endofbranch | ( | stdClass | $lesson, |
array | $record = [] ) |
Creates a end of branch page for testing purposes.
stdClass | $lesson | instance where to create the page. |
array | $record | data for page being generated. |
stdClass | page record. |
mod_lesson_generator::create_endofcluster | ( | stdClass | $lesson, |
array | $record = [] ) |
Creates a end of cluster page for testing purposes.
stdClass | $lesson | instance where to create the page. |
array | $record | data for page being generated. |
stdClass | page record. |
mod_lesson_generator::create_instance | ( | $record = null, | |
array | $options = null ) |
Creates a lesson instance for testing purposes.
null | array | stdClass | $record | data for module being generated. |
null | array | $options | general options for course module. |
stdClass | record from module-defined table with additional field cmid (corresponding id in course_modules table) |
Reimplemented from testing_module_generator.
mod_lesson_generator::create_override | ( | array | $data | ) |
Create a lesson override (either user or group).
array | $data | must specify lessonid, and one of userid or groupid. |
coding_exception |
mod_lesson_generator::create_page | ( | $record = null, | |
array | $options = null ) |
Creates a page for testing purposes.
The page will be created when answers are added.
null | array | stdClass | $record | data for page being generated. |
null | array | $options | general options. |
mod_lesson_generator::create_question_essay | ( | $lesson, | |
$record = array() ) |
Create essay question pages.
object | $lesson | |
array | $record |
stdClass | page record. |
mod_lesson_generator::create_question_matching | ( | $lesson, | |
$record = array() ) |
Create matching question pages.
object | $lesson | |
array | $record |
stdClass | page record. |
mod_lesson_generator::create_question_multichoice | ( | $lesson, | |
$record = array() ) |
Create multichoice question pages.
object | $lesson | |
array | $record |
stdClass | page record. |
mod_lesson_generator::create_question_numeric | ( | $lesson, | |
$record = array() ) |
Create shortanswer question pages.
object | $lesson | |
array | $record |
stdClass | page record. |
mod_lesson_generator::create_question_shortanswer | ( | $lesson, | |
$record = array() ) |
Create shortanswer question pages.
object | $lesson | |
array | $record |
stdClass | page record. |
mod_lesson_generator::create_question_truefalse | ( | $lesson, | |
$record = array() ) |
Create True/false question pages.
object | $lesson | |
array | $record |
stdClass | page record. |
|
inherited |
Returns module name.
string | name of module that this class describes |
coding_exception | if class invalid |
|
protected |
Calculate the previous page id.
If no page title is supplied, use the last page created in the lesson (0 if no pages). If page title is supplied, search it in DB and the list of candidate pages.
int | $lessonid | the lesson id. |
string | $pagetitle | the page title, for example 'Test page'. '0' if no previous page. |
int | corresponding id. 0 if no previous page. |
coding_exception |
|
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 |
|
protectedinherited |
Called after *_add_instance()
Since 2.6 it is recommended to use function add_moduleinfo() to create a module.
int | $id | |
int | $cmid |
stdClass | module instance |
|
protectedinherited |
Create course module and link it to course.
Since 2.6 it is recommended to use function add_moduleinfo() to create a module.
integer | $courseid | |
array | $options | section, visible |
integer\$cm | instance id |
|
protectedinherited |
Merges together arguments $record and $options and fills default module fields that are shared by all module types.
object | array | $record | fields (different from defaults) for this module |
null | array | $options | for backward-compatibility this may include fields from course_modules table. They are merged into $record |
coding_exception | if $record->course is not specified |
mod_lesson_generator::reset | ( | ) |
To be called from data reset code only, do not use in tests.
void |
Reimplemented from testing_module_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 |
|
protected |
map of readable jumpto to integer value.