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.

Class: locallib_test  - X-Ref

Unit tests for (some of) mod/quiz/locallib.php.

test_quiz_rescale_grade()   X-Ref
No description

quiz_attempt_state_data_provider()   X-Ref
No description

test_quiz_attempt_state($attemptstate,$relativetimefinish, $relativetimeclose, $expectedstate)   X-Ref

param: unknown $attemptstate as in the quiz_attempts.state DB column.
param: unknown $relativetimefinish time relative to now when the attempt finished, or null for 0.
param: unknown $relativetimeclose time relative to now when the quiz closes, or null for 0.
param: unknown $expectedstate expected result. One of the mod_quiz_display_options constants/

test_quiz_question_tostring()   X-Ref
No description

test_quiz_view()   X-Ref
Test quiz_view

return: void

test_quiz_is_overriden_calendar_event_no_override()   X-Ref
Return false when there are not overrides for this quiz instance.


test_quiz_is_overriden_calendar_event_no_module_event()   X-Ref
Return false if the given event isn't an quiz module event.


test_quiz_is_overriden_calendar_event_different_quiz_instance()   X-Ref
Return false if there is overrides for this use but they belong to another quiz
instance.


test_quiz_is_overriden_calendar_event_user_override()   X-Ref
Return true if there is a user override for this event and quiz instance.


test_quiz_is_overriden_calendar_event_group_override()   X-Ref
Return true if there is a group override for the event and quiz instance.


test_quiz_get_user_timeclose()   X-Ref
Test test_quiz_get_user_timeclose().


setup_quiz_and_tags($qnum, $randomqnum, $questiontags = [], $unusedtags = [])   X-Ref
This function creates a quiz with some standard (non-random) and some random questions.
The standard questions are created first and then random questions follow them.
So in a quiz with 3 standard question and 2 random question, the first random question is at slot 4.

param: int $qnum Number of standard questions that should be created in the quiz.
param: int $randomqnum Number of random questions that should be created in the quiz.
param: array $questiontags Tags to be used for random questions.
param: string[] $unusedtags Some additional tags to be created.
return: array An array of 2 elements: $quiz and $tagobjects.

test_quiz_retrieve_slot_tags()   X-Ref
No description

test_quiz_retrieve_slot_tags_with_removed_tag()   X-Ref
No description

test_quiz_retrieve_slot_tags_for_standard_question()   X-Ref
No description

test_quiz_retrieve_slot_tag_ids()   X-Ref
No description

test_quiz_retrieve_slot_tag_ids_for_standard_question()   X-Ref
No description

get_quiz_retrieve_tags_for_slot_ids_test_cases()   X-Ref
Data provider for the get_random_question_summaries test.


test_quiz_retrieve_tags_for_slot_ids_combinations($questioncount,$randomquestioncount,$randomquestiontags,$unusedtags,$removeslottagids,$expected)   X-Ref
Test the quiz_retrieve_tags_for_slot_ids function with various parameter
combinations.

param: int $questioncount The number of regular questions to create
param: int $randomquestioncount The number of random questions to create
param: array $randomquestiontags The tags for the random questions
param: string[] $unusedtags Additional tags to create to populate the DB with data
param: int[] $removeslottagids Slot numbers to remove tag ids for
param: array $expected The expected output of tag names indexed by slot number

test_quiz_override_summary()   X-Ref
No description