Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]

(no description)

File Size: 208 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

mod_quiz_generator:: (4 methods):
  create_instance()
  create_attempt()
  submit_responses()
  create_override()


Class: mod_quiz_generator  - X-Ref

Quiz module test data generator class

create_instance($record = null, array $options = null)   X-Ref
No description

create_attempt($quizid, $userid, array $forcedrandomquestions = [],array $forcedvariants = [])   X-Ref
Create a quiz attempt for a particular user at a particular course.

return: stdClass the new attempt.
param: int $quizid the quiz id (from the mdl_quit table, not cmid).
param: int $userid the user id.
param: array $forcedrandomquestions slot => questionid. Optional,
param: array $forcedvariants slot => variantno. Optional. Optional,

submit_responses($attemptid, array $responses, $checkbutton, $finishattempt)   X-Ref
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.

param: int $attemptid the id of the attempt which is being
param: array $responses array responses to submit. See description on
param: bool $checkbutton if simulate a click on the check button for each question, else simulate save.
param: bool $finishattempt if true, the attempt will be submitted.

create_override(array $data)   X-Ref
Create a quiz override (either user or group).

param: array $data must specify quizid, and one of userid or groupid.