Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 and 403]

Quiz module external functions tests.

Copyright: 2016 Juan Leyva <juan@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 2192 lines (99 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: testable_mod_quiz_external  - X-Ref

Silly class to access mod_quiz_external internal methods.

validate_attempt($params, $checkaccessrules = true, $failifoverdue = true)   X-Ref
Public accessor.

param: array $params Array of parameters including the attemptid and preflight data
param: bool $checkaccessrules whether to check the quiz access rules or not
param: bool $failifoverdue whether to return error if the attempt is overdue
return: array containing the attempt object and access messages

validate_attempt_review($params)   X-Ref
Public accessor.

param: array $params Array of parameters including the attemptid
return: array containing the attempt object and display options

Class: external_test  - X-Ref

Quiz module external functions tests

setUp()   X-Ref
Set up for every test


create_quiz_with_questions($startattempt = false, $finishattempt = false, $behaviour = 'deferredfeedback',$includeqattachments = false, $extraoptions = [])   X-Ref
Create a quiz with questions including a started or finished attempt optionally

param: boolean $startattempt whether to start a new attempt
param: boolean $finishattempt whether to finish the new attempt
param: string $behaviour the quiz preferredbehaviour, defaults to 'deferredfeedback'.
param: boolean $includeqattachments whether to include a question that supports attachments, defaults to false.
param: array $extraoptions extra options for Quiz.
return: array array containing the quiz, context and the attempt

test_mod_quiz_get_quizzes_by_courses()   X-Ref
No description

test_view_quiz()   X-Ref
Test test_view_quiz


test_get_user_attempts()   X-Ref
Test get_user_attempts


test_get_user_attempts_with_marks_hidden()   X-Ref
Test get_user_attempts with marks hidden


test_get_user_best_grade()   X-Ref
Test get_user_best_grade


test_get_combined_review_options()   X-Ref
Test get_combined_review_options.
This is a basic test, this is already tested in display_options_testcase.


test_start_attempt()   X-Ref
Test start_attempt


test_validate_attempt()   X-Ref
Test validate_attempt


test_get_attempt_data()   X-Ref
Test get_attempt_data


test_get_attempt_data_with_blocked_questions()   X-Ref
Test get_attempt_data with blocked questions.


test_get_attempt_summary()   X-Ref
Test get_attempt_summary


test_save_attempt()   X-Ref
Test save_attempt


test_process_attempt()   X-Ref
Test process_attempt


test_validate_attempt_review()   X-Ref
Test validate_attempt_review


test_get_attempt_review()   X-Ref
Test get_attempt_review


test_view_attempt()   X-Ref
Test test_view_attempt


test_view_attempt_summary()   X-Ref
Test test_view_attempt_summary


test_view_attempt_review()   X-Ref
Test test_view_attempt_summary


test_get_quiz_feedback_for_grade()   X-Ref
Test get_quiz_feedback_for_grade


test_get_quiz_access_information()   X-Ref
Test get_quiz_access_information


test_get_attempt_access_information()   X-Ref
Test get_attempt_access_information


test_get_quiz_required_qtypes()   X-Ref
Test get_quiz_required_qtypes


test_get_quiz_required_qtypes_random()   X-Ref
Test get_quiz_required_qtypes for quiz with random questions


test_sequential_navigation_view_attempt()   X-Ref
Test that a sequential navigation quiz is not allowing to see questions in advance except if reviewing


test_sequential_navigation_attempt_summary()   X-Ref
Test that a sequential navigation quiz is not allowing to see questions in advance for a student


test_sequential_navigation_get_attempt_data()   X-Ref
Test that a sequential navigation quiz is not allowing to see questions in advance for student


prepare_sequential_quiz()   X-Ref
Prepare quiz for sequential navigation tests

return: quiz_settings

create_quiz_attempt_object(quiz_settings $quizobj,?int $userid = null,?bool $ispreview = false)   X-Ref
Create question attempt

param: quiz_settings $quizobj
param: int|null $userid
param: bool|null $ispreview
return: quiz_attempt