Differences Between: [Versions 400 and 402] [Versions 400 and 403]
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 <safatshahin@catalyst-au.net> |
Copyright: | 2021 Catalyst IT Australia Pty Ltd |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 181 lines (7 kb) |
Included or required: | 3 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
create_test_quiz(\stdClass $course) X-Ref |
Create a test quiz for the specified course. return: \stdClass param: \stdClass $course |
add_two_regular_questions($questiongenerator, \stdClass $quiz, $override = null) X-Ref |
Helper method to add regular questions in quiz. param: component_generator_base $questiongenerator param: \stdClass $quiz param: array $override |
add_one_random_question($questiongenerator, \stdClass $quiz, $override = []) X-Ref |
Helper method to add random question to quiz. param: component_generator_base $questiongenerator param: \stdClass $quiz param: array $override |
attempt_quiz(\stdClass $quiz, \stdClass $user, $attemptnumber = 1) X-Ref |
Attempt questions for a quiz and user. return: array param: \stdClass $quiz Quiz to attempt. param: \stdClass $user A user to attempt the quiz. param: int $attemptnumber |
backup_quiz(\stdClass $quiz, \stdClass $user) X-Ref |
A helper method to backup test quiz. return: string A backup ID ready to be restored. param: \stdClass $quiz Quiz to attempt. param: \stdClass $user A user to attempt the quiz. |
restore_quiz(string $backupid, stdClass $course, stdClass $user) X-Ref |
A helper method to restore provided backup. param: string $backupid Backup ID to restore. param: stdClass $course param: stdClass $user |
duplicate_quiz($course, $quiz) X-Ref |
A helper method to emulate duplication of the quiz. return: \cm_info|null param: stdClass $course param: stdClass $quiz |