Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)

Classes

class  behat_mod_quiz_generator
 Behat data generator for mod_quiz. More...
 

Functions

 add_one_random_question ($questiongenerator, stdClass $quiz, $override=[])
 Helper method to add random question to quiz.
 
 add_random_questions (int $quizid, int $page, int $categoryid, int $number)
 Add random questions to a quiz, with a filter condition based on a category ID.
 
 add_two_regular_questions ($questiongenerator, stdClass $quiz, $override=null)
 Helper method to add regular questions in quiz.
 
 attempt_quiz (\stdClass $quiz, stdClass $user, $attemptnumber=1)
 Attempt questions for a quiz and user.
 
 backup_quiz (\stdClass $quiz, stdClass $user)
 A helper method to backup test quiz.
 
 create_test_quiz (\stdClass $course)
 Create a test quiz for the specified course.
 
 duplicate_quiz ($course, $quiz)
 A helper method to emulate duplication of the quiz.
 
 restore_quiz (string $backupid, stdClass $course, stdClass $user)
 A helper method to restore provided backup.
 

Variables

stdClass $quiz
 $quiz A test quiz.
 
stdClass $user
 $user A test logged-in user.
 
trait quiz_question_helper_test_trait
 Helper trait for quiz question unit tests.
 

Detailed Description

Function Documentation

◆ add_one_random_question()

add_one_random_question ( $questiongenerator,
stdClass $quiz,
$override = [] )
protected

Helper method to add random question to quiz.

Parameters
component_generator_base$questiongenerator
stdClass$quiz
array$override

◆ add_random_questions()

add_random_questions ( int $quizid,
int $page,
int $categoryid,
int $number )
protected

Add random questions to a quiz, with a filter condition based on a category ID.

Parameters
int$quizidThe quiz to add the questions to.
int$pageThe page number to add the questions to.
int$categoryidThe category ID to use for the filter condition.
int$numberThe number of questions to add.
Return values
void

◆ add_two_regular_questions()

add_two_regular_questions ( $questiongenerator,
stdClass $quiz,
$override = null )
protected

Helper method to add regular questions in quiz.

Parameters
component_generator_base$questiongenerator
stdClass$quiz
array$override

◆ attempt_quiz()

attempt_quiz ( \stdClass $quiz,
stdClass $user,
$attemptnumber = 1 )
protected

Attempt questions for a quiz and user.

Parameters
stdClass$quizQuiz to attempt.
stdClass$userA user to attempt the quiz.
int$attemptnumber
Return values
array

◆ backup_quiz()

backup_quiz ( \stdClass $quiz,
stdClass $user )
protected

A helper method to backup test quiz.

Parameters
stdClass$quizQuiz to attempt.
stdClass$userA user to attempt the quiz.
Return values
stringA backup ID ready to be restored.

◆ create_test_quiz()

create_test_quiz ( \stdClass $course)
protected

Create a test quiz for the specified course.

Parameters
stdClass$course
Return values
stdClass

◆ duplicate_quiz()

duplicate_quiz ( $course,
$quiz )
protected

A helper method to emulate duplication of the quiz.

Parameters
stdClass$course
stdClass$quiz
Return values
cm_info|null

◆ restore_quiz()

restore_quiz ( string $backupid,
stdClass $course,
stdClass $user )
protected

A helper method to restore provided backup.

Parameters
string$backupidBackup ID to restore.
stdClass$course
stdClass$user

Variable Documentation

◆ quiz_question_helper_test_trait

trait quiz_question_helper_test_trait
Initial value:
{
protected stdClass $course

Helper trait for quiz question unit tests.

This trait helps to execute different tests for quiz, for example if it needs to create a quiz, add question to the question, add random quetion to the quiz, do a backup or restore.

Author
Safat Shahin safat.nosp@m.shah.nosp@m.in@ca.nosp@m.taly.nosp@m.st-au.nosp@m..net
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later