Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

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: 2094 lines (96 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 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_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($quizobj, $userid = null, $ispreview = false)   X-Ref
Create question attempt

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