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.

Class: question_test  - X-Ref

Unit tests for the matching question definition class.

test_get_question_summary()   X-Ref
No description

test_summarise_response(int $responserequired, int $attachmentsrequired,string $answertext, int $attachmentuploaded, string $expected)   X-Ref
Test summarise_response() when teachers view quiz attempts and then
review them to see what has been saved in the response history table.

param: int $responserequired
param: int $attachmentsrequired
param: string $answertext
param: int $attachmentuploaded
param: string $expected

summarise_response_provider()   X-Ref
Data provider for summarise_response() test cases.

return: array List of data sets (test cases)

test_is_same_response()   X-Ref
No description

test_is_same_response_with_template()   X-Ref
No description

test_is_complete_response()   X-Ref
No description

test_get_question_definition_for_external_rendering()   X-Ref
test_get_question_definition_for_external_rendering


test_get_validation_error(int $responserequired,int $minwordlimit, int $maxwordlimit, string $expected)   X-Ref
Test get_validation_error when users submit their input text.

(The tests are done with a fixed 14-word response.)

param: int $responserequired whether response required (yes = 1, no = 0)
param: int $minwordlimit minimum word limit
param: int $maxwordlimit maximum word limit
param: string $expected error message | null

get_min_max_wordlimit_test_cases()   X-Ref
Data provider for get_validation_error test.

return: array the test cases.

test_get_word_count_message_for_review(?int $minwordlimit, ?int $maxwordlimit, string $expected)   X-Ref
Test get_word_count_message_for_review when users submit their input text.

(The tests are done with a fixed 14-word response.)

param: int|null $minwordlimit minimum word limit
param: int|null $maxwordlimit maximum word limit
param: string $expected error message | null

get_word_count_message_for_review_test_cases()   X-Ref
Data provider for test_get_word_count_message_for_review.

return: array the test cases.

create_user_and_sample_attachments($numberofattachments = 4)   X-Ref
Create sample attachemnts and retun generated attachments.

param: int $numberofattachments
return: array