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.

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

A test helper trait.

Author: Andrew Madden <andrewmadden@catalyst-au.net>
Copyright: 2019 Catalyst IT
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 309 lines (10 kb)
Included or required: 8 times
Referenced: 0 times
Includes or requires: 0 files

Defines 11 functions


Functions that are not part of a class:

assign_user_capability($capability, $contextid, $roleid = null)   X-Ref
Assign a capability to $USER
The function creates a student $USER if $USER->id is empty

param: string $capability Capability name.
param: int $contextid Context ID.
param: int $roleid Role ID.
return: int The role id - mainly returned for creation, so calling function can reuse it.

strip_all_prefixes(\stdClass $settings)   X-Ref
Strip the seb_ prefix from each setting key.

param: \stdClass $settings Object containing settings.
return: \stdClass The modified settings object.

create_test_draftarea_file(string $xml)   X-Ref
Creates a file in the user draft area.

param: string $xml
return: int The user draftarea id

create_module_test_file(string $xml, string $cmid)   X-Ref
Create a file in a modules filearea.

param: string $xml XML content of the file.
param: string $cmid Course module id.
return: int Item ID of file.

create_test_quiz($course, $requiresafeexambrowser = settings_provider::USE_SEB_NO)   X-Ref
Create a test quiz for the specified course.

param: \stdClass $course
param: int $requiresafeexambrowser How to use SEB for this quiz?
return: array

attempt_quiz($quiz, $user)   X-Ref
Answer questions for a quiz + user.

param: \stdClass $quiz Quiz to attempt.
param: \stdClass $user A user to attempt the quiz.
return: array

create_template(string $xml = null)   X-Ref
Create test template.

param: string|null $xml Template content.
return: \quizaccess_seb\template Just created template.

get_access_manager()   X-Ref
Get access manager for testing.

return: \quizaccess_seb\access_manager

make_rule()   X-Ref
A helper method to make the rule form the currently created quiz and  course.

return: \quiz_access_rule_base|null

set_up_quiz_view_page()   X-Ref
A helper method to set up quiz view page.


get_test_settings()   X-Ref
Get a test object containing mock test settings.

return: \stdClass Settings.