|
| create_attempt ($quizid, $userid, array $forcedrandomquestions=[], array $forcedvariants=[]) |
| Create a quiz attempt for a particular user at a particular course. More...
|
|
| create_content ($instance, $record=array()) |
| Generates a piece of content for the module. More...
|
|
| create_instance ($record=null, array $options=null) |
| Creates an instance of the module for testing purposes. More...
|
|
| create_override (array $data) |
| Create a quiz override (either user or group). More...
|
|
| get_modulename () |
| Returns module name. More...
|
|
| reset () |
| To be called from data reset code only, do not use in tests. More...
|
|
| submit_responses ($attemptid, array $responses, $checkbutton, $finishattempt) |
| Submit responses to a quiz attempt. More...
|
|
◆ create_attempt()
mod_quiz_generator::create_attempt |
( |
|
$quizid, |
|
|
|
$userid, |
|
|
array |
$forcedrandomquestions = [] , |
|
|
array |
$forcedvariants = [] |
|
) |
| |
Create a quiz attempt for a particular user at a particular course.
Currently this method can only create a first attempt for each user at each quiz. TODO remove this limitation.
- Parameters
-
int | $quizid | the quiz id (from the mdl_quit table, not cmid). |
int | $userid | the user id. |
array | $forcedrandomquestions | slot => questionid. Optional, used with random questions, to control which one is 'randomly' selected in that slot. |
array | $forcedvariants | slot => variantno. Optional. Optional, used with question where get_num_variants is > 1, to control which variants is 'randomly' selected. |
- Return values
-
◆ create_content()
testing_module_generator::create_content |
( |
|
$instance, |
|
|
|
$record = array() |
|
) |
| |
|
inherited |
◆ create_instance()
mod_quiz_generator::create_instance |
( |
|
$record = null , |
|
|
array |
$options = null |
|
) |
| |
Creates an instance of the module for testing purposes.
Module type will be taken from the class name. Each module type may overwrite this function to add other default values used by it.
- Parameters
-
array | stdClass | $record | data for module being generated. Requires 'course' key (an id or the full object). Also can have any fields from add module form. |
null | array | $options | general options for course module. Since 2.6 it is possible to omit this argument by merging options into $record |
- Return values
-
stdClass | record from module-defined table with additional field cmid (corresponding id in course_modules table) |
Reimplemented from testing_module_generator.
◆ create_override()
mod_quiz_generator::create_override |
( |
array |
$data | ) |
|
Create a quiz override (either user or group).
- Parameters
-
array | $data | must specify quizid, and one of userid or groupid. |
◆ get_modulename()
testing_module_generator::get_modulename |
( |
| ) |
|
|
inherited |
Returns module name.
- Return values
-
string | name of module that this class describes |
- Exceptions
-
◆ post_add_instance()
testing_module_generator::post_add_instance |
( |
|
$id, |
|
|
|
$cmid |
|
) |
| |
|
protectedinherited |
◆ precreate_course_module()
testing_module_generator::precreate_course_module |
( |
|
$courseid, |
|
|
array |
$options |
|
) |
| |
|
protectedinherited |
◆ prepare_moduleinfo_record()
testing_module_generator::prepare_moduleinfo_record |
( |
|
$record, |
|
|
|
$options |
|
) |
| |
|
protectedinherited |
Merges together arguments $record and $options and fills default module fields that are shared by all module types.
- Parameters
-
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 |
- Exceptions
-
◆ reset()
testing_module_generator::reset |
( |
| ) |
|
|
inherited |
◆ 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
-
◆ submit_responses()
mod_quiz_generator::submit_responses |
( |
|
$attemptid, |
|
|
array |
$responses, |
|
|
|
$checkbutton, |
|
|
|
$finishattempt |
|
) |
| |
Submit responses to a quiz attempt.
To be realistic, you should ensure that $USER is set to the user whose attempt it is before calling this.
- Parameters
-
int | $attemptid | the id of the attempt which is being |
array | $responses | array responses to submit. See description on core_question_generator::get_simulated_post_data_for_questions_in_usage(). |
bool | $checkbutton | if simulate a click on the check button for each question, else simulate save. This should only be used with behaviours that have a check button. |
bool | $finishattempt | if true, the attempt will be submitted. |
The documentation for this class was generated from the following file: