Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

(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.

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,
return: stdClass the new attempt.

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.