Differences Between: [Versions 400 and 402] [Versions 400 and 403]
Class for providing quiz settings, to make setting up quiz form manageable. To make sure there are no inconsistencies between data sets, run tests in tests/phpunit/settings_provider_test.php.
Author: | Luca Bösch <luca.boesch@bfh.ch> |
Author: | Andrew Madden <andrewmadden@catalyst-au.net> |
Author: | Dmitrii Metelkin <dmitriim@catalyst-au.net> |
Copyright: | 2019 Catalyst IT |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1118 lines (43 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
settings_provider:: (48 methods):
insert_element()
remove_element()
add_help_button()
set_default()
set_type()
freeze_element()
add_seb_header_element()
add_seb_usage_options()
add_seb_templates()
add_seb_config_file()
add_seb_show_download_link()
add_seb_allowedbrowserexamkeys()
add_seb_config_elements()
add_seb_settings_fields()
hide_seb_elements()
lock_seb_elements()
get_uploaded_seb_file_download_link()
get_seb_config_elements()
get_seb_config_element_types()
is_conflicting_permissions()
get_requiresafeexambrowser_options()
get_template_options()
get_filemanager_options()
get_seb_config_element_defaults()
validate_draftarea_configfile()
get_current_user_draft_file()
get_module_context_sebconfig_file()
save_filemanager_sebconfigfile_draftarea()
delete_uploaded_config_file()
can_configure_seb()
can_use_seb_template()
can_upload_seb_file()
can_change_seb_showsebdownloadlink()
can_change_seb_allowedbrowserexamkeys()
can_configure_manually()
can_manage_seb_config_setting()
build_config_capabilities_to_check()
get_seb_settings_map()
get_allowed_settings()
build_allowed_settings()
get_quiz_hideifs()
build_setting_capability_name()
is_seb_settings_locked()
filter_by_prefix()
filter_by_settings_map()
filter_plugin_settings()
strip_all_prefixes()
add_prefix()
Class: settings_provider - X-Ref
Helper class for providing quiz settings, to make setting up quiz form manageable.insert_element(\mod_quiz_mod_form $quizform,\MoodleQuickForm $mform, \HTML_QuickForm_element $element, $before = 'security') X-Ref |
Insert form element. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. param: \HTML_QuickForm_element $element Element to insert. param: string $before Insert element before. |
remove_element(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform, string $elementname) X-Ref |
Remove element from the form. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. param: string $elementname Element name. |
add_help_button(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform, string $elementname) X-Ref |
Add help button to the element. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. param: string $elementname Element name. |
set_default(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform, string $elementname, $value) X-Ref |
Set default value for the element. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. param: string $elementname Element name. param: mixed $value Default value. |
set_type(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform, string $elementname, string $type) X-Ref |
Set element type. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. param: string $elementname Element name. param: string $type Type of the form element. |
freeze_element(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform, string $elementname) X-Ref |
Freeze form element. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. param: string $elementname Element name. |
add_seb_header_element(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Add SEB header element to the form. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
add_seb_usage_options(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Add SEB usage element with all available options. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
add_seb_templates(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Add Templates element. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
add_seb_config_file(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Add upload config file element. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
add_seb_show_download_link(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Add Show Safe Exam Browser download button. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
add_seb_allowedbrowserexamkeys(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Add Allowed Browser Exam Keys setting. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
add_seb_config_elements(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Add SEB config elements. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
add_seb_settings_fields(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Add setting fields. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
hide_seb_elements(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Hide SEB elements if required. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
lock_seb_elements(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Lock SEB elements if required. param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
get_uploaded_seb_file_download_link(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) X-Ref |
Return uploaded SEB config file link. return: string param: \mod_quiz_mod_form $quizform the quiz settings form that is being built. param: \MoodleQuickForm $mform the wrapped MoodleQuickForm. |
get_seb_config_elements() X-Ref |
Get the type of element for each of the form elements in quiz settings. Contains all setting elements. Array key is name of 'form element'/'database column (excluding prefix)'. return: array All quiz form elements to be added and their types. |
get_seb_config_element_types() X-Ref |
Get the types of the quiz settings elements. return: array List of types for the setting elements. |
is_conflicting_permissions(\context $context) X-Ref |
Check that we have conflicting permissions. In Some point we can have settings save by the person who use specific type of SEB usage (e.g. use templates). But then another person who can't use template (but still can update other settings) edit the same quiz. This is conflict of permissions and we'd like to build the settings form having this in mind. return: bool param: \context $context Context used with capability checking. |
get_requiresafeexambrowser_options(\context $context) X-Ref |
Returns a list of all options of SEB usage. return: array param: \context $context Context used with capability checking selection options. |
get_template_options() X-Ref |
Returns a list of templates. return: array |
get_filemanager_options() X-Ref |
Returns a list of options for the file manager element. return: array |
get_seb_config_element_defaults() X-Ref |
Get the default values of the quiz settings. Array key is name of 'form element'/'database column (excluding prefix)'. return: array List of settings and their defaults. |
validate_draftarea_configfile($itemid) X-Ref |
Validate that if a file has been uploaded by current user, that it is a valid PLIST XML file. This function is only called if requiresafeexambrowser == settings_provider::USE_SEB_UPLOAD_CONFIG. return: void|lang_string param: string $itemid Item ID of file in user draft file area. |
get_current_user_draft_file(string $itemid) X-Ref |
Try and get a file in the user draft filearea by itemid. return: stored_file|null Returns null if no file is found. param: string $itemid Item ID of the file. |
get_module_context_sebconfig_file(string $cmid) X-Ref |
Get the file that is stored in the course module file area. return: stored_file|null Returns null if no file is found. param: string $cmid The course module id which is used as an itemid reference. |
save_filemanager_sebconfigfile_draftarea(string $draftitemid, string $cmid) X-Ref |
Saves filemanager_sebconfigfile files to the moodle storage backend. return: bool Always true param: string $draftitemid The id of the draft area to use. param: string $cmid The cmid of for the quiz. |
delete_uploaded_config_file(string $cmid) X-Ref |
Cleanup function to delete the saved config when it has not been specified. This will be called when settings_provider::USE_SEB_UPLOAD_CONFIG is not true. return: bool Always true or exception if error occurred param: string $cmid The cmid of for the quiz. |
can_configure_seb(\context $context) X-Ref |
Check if the current user can configure SEB. return: bool param: \context $context Context to check access in. |
can_use_seb_template(\context $context) X-Ref |
Check if the current user can use preconfigured templates. return: bool param: \context $context Context to check access in. |
can_upload_seb_file(\context $context) X-Ref |
Check if the current user can upload own SEB config file. return: bool param: \context $context Context to check access in. |
can_change_seb_showsebdownloadlink(\context $context) X-Ref |
Check if the current user can change Show Safe Exam Browser download button setting. return: bool param: \context $context Context to check access in. |
can_change_seb_allowedbrowserexamkeys(\context $context) X-Ref |
Check if the current user can change Allowed Browser Exam Keys setting. return: bool param: \context $context Context to check access in. |
can_configure_manually(\context $context) X-Ref |
Check if the current user can config SEB manually. return: bool param: \context $context Context to check access in. |
can_manage_seb_config_setting(string $settingname, \context $context) X-Ref |
Check if the current user can manage provided SEB setting. return: bool param: string $settingname Name of the setting. param: \context $context Context to check access in. |
build_config_capabilities_to_check(string $settingname, array $settings) X-Ref |
Helper method to build a list of capabilities to check. return: array param: string $settingname Given setting name to build caps for. param: array $settings A list of settings to go through. |
get_seb_settings_map() X-Ref |
Helper method to return a map of all settings. return: array |
get_allowed_settings(int $requiresafeexambrowser) X-Ref |
Get allowed settings for provided SEB usage type. return: array param: int $requiresafeexambrowser SEB usage type. |
build_allowed_settings(array $settings) X-Ref |
Recursive method to build a list of allowed settings. return: array param: array $settings A list of settings from settings map. |
get_quiz_hideifs() X-Ref |
Get the conditions that an element should be hid in the form. Expects matching using 'eq'. Array key is name of 'form element'/'database column (excluding prefix)'. Values are instances of hideif_rule class. return: array List of rules per element. |
build_setting_capability_name(string $settingname) X-Ref |
Build a capability name for the provided SEB setting. return: string param: string $settingname Name of the setting. |
is_seb_settings_locked($quizid) X-Ref |
Check if settings is locked. return: bool param: int $quizid Quiz ID. |
filter_by_prefix(\stdClass $settings) X-Ref |
Filter a standard class by prefix. return: stdClass Filtered object. param: stdClass $settings Quiz settings object. |
filter_by_settings_map(stdClass $settings) X-Ref |
Filter settings based on the setting map. Set value of not allowed settings to null. return: \stdClass param: stdClass $settings Quiz settings. |
filter_plugin_settings(stdClass $settings) X-Ref |
Filter quiz settings for this plugin only. return: stdClass Filtered settings. param: stdClass $settings Quiz settings. |
strip_all_prefixes(\stdClass $settings) X-Ref |
Strip the seb_ prefix from each setting key. return: \stdClass The modified settings object. param: \stdClass $settings Object containing settings. |
add_prefix(string $name) X-Ref |
Add prefix to string. return: string String with prefix. param: string $name String to add prefix to. |