Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

Quiz events tests.

Copyright: 2013 Adrian Greeve
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1067 lines (40 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

mod_quiz_structure_testcase:: (42 methods):
  prepare_quiz_data()
  create_test_quiz()
  assert_quiz_layout()
  parse_section_name()
  test_get_quiz_slots()
  test_quiz_has_one_section_by_default()
  test_get_sections()
  test_remove_section_heading()
  test_cannot_remove_first_section()
  test_move_slot_to_the_same_place_does_nothing()
  test_move_slot_end_of_one_page_to_start_of_next()
  test_move_last_slot_to_previous_page_emptying_the_last_page()
  test_end_of_one_section_to_start_of_next()
  test_start_of_one_section_to_end_of_previous()
  test_move_slot_on_same_page()
  test_move_slot_up_onto_previous_page()
  test_move_slot_emptying_a_page_renumbers_pages()
  test_move_slot_too_small_page_number_detected()
  test_move_slot_too_large_page_number_detected()
  test_move_slot_within_section()
  test_move_slot_to_new_section()
  test_move_slot_to_start()
  test_move_slot_down_to_start_of_second_section()
  test_move_first_slot_down_to_start_of_page_2()
  test_move_first_slot_to_same_place_on_page_1()
  test_move_first_slot_to_before_page_1()
  test_move_slot_up_to_start_of_second_section()
  test_move_slot_does_not_violate_heading_unique_key()
  test_quiz_remove_slot()
  test_quiz_removing_a_random_question_deletes_the_question()
  test_cannot_remove_all_slots_in_a_section()
  test_cannot_remove_last_slot_in_a_section()
  test_can_remove_last_question_in_a_quiz()
  test_add_question_updates_headings()
  test_add_question_updates_headings_even_with_one_question_sections()
  test_add_question_at_end_does_not_update_headings()
  test_remove_page_break()
  test_add_page_break()
  test_update_question_dependency()
  get_slot_tags_for_slot_test_cases()
  test_get_slot_tags_for_slot()
  test_can_add_random_questions()


Class: mod_quiz_structure_testcase  - X-Ref

Unit tests for quiz events.

prepare_quiz_data()   X-Ref
Create a course with an empty quiz.

return: array with three elements quiz, cm and course.

create_test_quiz($layout)   X-Ref
Creat a test quiz.

$layout looks like this:
$layout = array(
'Heading 1'
array('TF1', 1, 'truefalse'),
'Heading 2*'
array('TF2', 2, 'truefalse'),
);
That is, either a string, which represents a section heading,
or an array that represents a question.

If the section heading ends with *, that section is shuffled.

The elements in the question array are name, page number, and question type.

param: array $layout as above.
return: quiz the created quiz.

assert_quiz_layout($expectedlayout, \mod_quiz\structure $structure)   X-Ref
Verify that the given layout matches that expected.

param: array $expectedlayout as for $layout in {@link create_test_quiz()}.
param: \mod_quiz\structure $structure the structure to test.

parse_section_name($heading)   X-Ref
Parse the section name, optionally followed by a * to mean shuffle, as
used by create_test_quiz as assert_quiz_layout.

param: string $heading the heading.
return: array with two elements, the heading and the shuffle setting.

test_get_quiz_slots()   X-Ref
No description

test_quiz_has_one_section_by_default()   X-Ref
No description

test_get_sections()   X-Ref
No description

test_remove_section_heading()   X-Ref
No description

test_cannot_remove_first_section()   X-Ref
No description

test_move_slot_to_the_same_place_does_nothing()   X-Ref
No description

test_move_slot_end_of_one_page_to_start_of_next()   X-Ref
No description

test_move_last_slot_to_previous_page_emptying_the_last_page()   X-Ref
No description

test_end_of_one_section_to_start_of_next()   X-Ref
No description

test_start_of_one_section_to_end_of_previous()   X-Ref
No description

test_move_slot_on_same_page()   X-Ref
No description

test_move_slot_up_onto_previous_page()   X-Ref
No description

test_move_slot_emptying_a_page_renumbers_pages()   X-Ref
No description

test_move_slot_too_small_page_number_detected()   X-Ref
No description

test_move_slot_too_large_page_number_detected()   X-Ref
No description

test_move_slot_within_section()   X-Ref
No description

test_move_slot_to_new_section()   X-Ref
No description

test_move_slot_to_start()   X-Ref
No description

test_move_slot_down_to_start_of_second_section()   X-Ref
No description

test_move_first_slot_down_to_start_of_page_2()   X-Ref
No description

test_move_first_slot_to_same_place_on_page_1()   X-Ref
No description

test_move_first_slot_to_before_page_1()   X-Ref
No description

test_move_slot_up_to_start_of_second_section()   X-Ref
No description

test_move_slot_does_not_violate_heading_unique_key()   X-Ref
No description

test_quiz_remove_slot()   X-Ref
No description

test_quiz_removing_a_random_question_deletes_the_question()   X-Ref
No description

test_cannot_remove_all_slots_in_a_section()   X-Ref
Unit test to make sue it is not possible to remove all slots in a section at once.


test_cannot_remove_last_slot_in_a_section()   X-Ref
No description

test_can_remove_last_question_in_a_quiz()   X-Ref
No description

test_add_question_updates_headings()   X-Ref
No description

test_add_question_updates_headings_even_with_one_question_sections()   X-Ref
No description

test_add_question_at_end_does_not_update_headings()   X-Ref
No description

test_remove_page_break()   X-Ref
No description

test_add_page_break()   X-Ref
No description

test_update_question_dependency()   X-Ref
No description

get_slot_tags_for_slot_test_cases()   X-Ref
Data provider for the get_slot_tags_for_slot test.


test_get_slot_tags_for_slot($layout, $tagnames, $slotnumber, $expected)   X-Ref

param: array $layout Quiz layout for create_test_quiz function
param: array $tagnames Tags to create for each question slot
param: int $slotnumber The slot number to select tags from
param: string[] $expected The tags expected for the given $slotnumber

test_can_add_random_questions()   X-Ref
Test for can_add_random_questions.