Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

(no description)

File Size: 996 lines (38 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

structure_test:: (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()
  test_can_add_random_questions()
  test_get_version_choices_for_slot()
  test_has_use_capability()


Class: structure_test  - 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, structure $structure)   X-Ref
Verify that the given layout matches that expected.

param: array $expectedlayout as for $layout in {@link create_test_quiz()}.
param: 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

test_can_add_random_questions()   X-Ref
Test for can_add_random_questions.


test_get_version_choices_for_slot()   X-Ref
Test to get the version information for a question to show in the version selection dropdown.


test_has_use_capability()   X-Ref
Test the current user have '...use' capability over the question(s) in a given slot.