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]

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(array $settings = [])   X-Ref
Get a test object containing mock test settings.

return: \stdClass Settings.