Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 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.

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.