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.

Class: random_question_loader_testcase  - X-Ref

Tests for the {@link core_question\bank\random_question_loader} class.

test_empty_category_gives_null()   X-Ref
No description

test_unknown_category_behaves_like_empty()   X-Ref
No description

test_descriptions_not_returned()   X-Ref
No description

test_hidden_questions_not_returned()   X-Ref
No description

test_cloze_subquestions_not_returned()   X-Ref
No description

test_random_questions_not_returned()   X-Ref
No description

test_one_question_category_returns_that_q_then_null()   X-Ref
No description

test_two_question_category_returns_both_then_null()   X-Ref
No description

test_nested_categories()   X-Ref
No description

test_used_question_not_returned_until_later()   X-Ref
No description

test_previously_used_question_not_returned_until_later()   X-Ref
No description

test_empty_category_does_not_have_question_available()   X-Ref
No description

test_descriptions_not_available()   X-Ref
No description

test_existing_question_is_available_but_then_marked_used()   X-Ref
No description

get_questions_test_cases()   X-Ref
Data provider for the get_questions test.


test_get_questions_variations($categoryindex,$includesubcategories,$usetagnames,$expectedquestionindexes)   X-Ref
Test the get_questions function with various parameter combinations.

This function creates a data set as follows:
Category: cat1
Question: cat1q1
Tags: 'cat1', 'foo'
Question: cat1q2
Category: cat2
Question: cat2q1
Tags: 'cat2', 'foo'
Question: cat2q2
Category: subcat
Question: subcatq1
Tags: 'subcat', 'foo'
Question: subcatq2
Parent: cat1
Category: emptycat

param: string $categoryindex The named index for the category to use
param: bool $includesubcategories If the search should include subcategories
param: string[] $usetagnames The tag names to include in the search
param: string[] $expectedquestionindexes The questions expected in the result

test_get_questions_with_limit_and_offset()   X-Ref
get_questions should allow limiting and offsetting of the result set.


test_get_questions_with_restricted_fields()   X-Ref
get_questions should allow retrieving questions with only a subset of
fields populated.


count_questions_test_cases()   X-Ref
Data provider for the count_questions test.


test_count_questions_variations($categoryindex,$includesubcategories,$usetagnames,$expectedcount)   X-Ref
Test the count_questions function with various parameter combinations.

This function creates a data set as follows:
Category: cat1
Question: cat1q1
Tags: 'cat1', 'foo'
Question: cat1q2
Category: cat2
Question: cat2q1
Tags: 'cat2', 'foo'
Question: cat2q2
Category: subcat
Question: subcatq1
Tags: 'subcat', 'foo'
Question: subcatq2
Parent: cat1
Category: emptycat

param: string $categoryindex The named index for the category to use
param: bool $includesubcategories If the search should include subcategories
param: string[] $usetagnames The tag names to include in the search
param: int $expectedcount The number of questions expected in the result

create_category_and_questions($questioncount, $tagnames = [], $parentcategory = null)   X-Ref
Create a question category and create questions in that category. Tag
the first question in each category with the given tags.

param: int $questioncount How many questions to create.
param: string[] $tagnames The list of tags to use.
param: stdClass|null $parentcategory The category to set as the parent of the created category.
return: array The category and questions.