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 401 and 402] [Versions 401 and 403]

(no description)

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

Defines 1 class


Class: submit_tags_test  - X-Ref

Question external functions tests.

setUp()   X-Ref
Set up for every test


test_submit_tags_form_incorrect_question_id()   X-Ref
submit_tags_form should throw an exception when the question id doesn't match
a question.


test_submit_tags_form_incorrect_context_id()   X-Ref
submit_tags_form should throw an exception when the context id doesn't match
a context.


test_submit_tags_form_tags_disabled()   X-Ref
submit_tags_form should return false when tags are disabled.


test_submit_tags_form_no_tag_permissions()   X-Ref
submit_tags_form should return false if the user does not have any capability
to tag the question.


test_submit_tags_form_tagmine_permission_non_owner_question()   X-Ref
submit_tags_form should return false if the user only has the capability to
tag their own questions and the question is not theirs.


get_submit_tags_form_testcases()   X-Ref
Data provided for the submit_tags_form test to check that course tags are
only created in the correct editing and question context combinations.

return: array Test cases

test_submit_tags_form_context_combinations($editingcontext,$questioncontext,$questiontags,$coursetags,$expectcoursetags)   X-Ref
Tests that submit_tags_form only creates course tags when the correct combination
of editing context and question context is provided.

Course tags can only be set on a course category or system context question that
is being editing in a course context.

param: string $editingcontext The type of the context the question is being edited in
param: string $questioncontext The type of the context the question belongs to
param: string[] $questiontags The tag names to set as question tags
param: string[] $coursetags The tag names to set as course tags
param: bool $expectcoursetags If the given course tags should have been set or not

generate_encoded_submit_tags_form_string($question, $questioncategory,$questioncontext, $tags = [], $coursetags = [])   X-Ref
Build the encoded form data expected by the submit_tags_form external function.

param: \stdClass $question         The question record
param: \stdClass $questioncategory The question category record
param: \context  $questioncontext  Context for the question category
param: array  $tags               A list of tag names for the question
param: array  $coursetags         A list of course tag names for the question
return: string                    HTML encoded string of the data

create_user_can_tag($course)   X-Ref
Create a user, enrol them in the course, and give them the capability to
tag all questions in the system context.

param: \stdClass $course The course record to enrol in
return: \stdClass         The user record