Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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: 2151 lines (98 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.

return: array containing the attempt object and access messages
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

validate_attempt_review($params)   X-Ref
Public accessor.

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

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

return: array array containing the quiz, context and the attempt
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.

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 mod_quiz_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

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

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