diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php new file mode 100644 index 0000000..bf205a8 --- /dev/null +++ b/classes/privacy/provider.php @@ -0,0 +1,67 @@ +. + +/** + * Privacy Subsystem implementation for qtype_knowledgecheck. + * + * @package qtype_knowledgecheck + * @copyright (c) The Regents of the University of California + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace qtype_knowledgecheck\privacy; + +use \core_privacy\local\metadata\collection; +use core_privacy\local\metadata\provider as base_provider; +use \core_privacy\local\request\user_preference_provider; +use \core_privacy\local\request\writer; + +defined('MOODLE_INTERNAL') || die(); + +/** + * Privacy Subsystem for qtype_knowledgecheck implementing user_preference_provider. + * + * @package qtype_knowledgecheck + * @copyright (c) The Regents of the University of California + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class provider implements base_provider, user_preference_provider +{ + + /** + * Returns meta-data about this system. + * + * @param collection $collection The initialised collection to add items to. + * @return collection A listing of user data stored through this system. + */ + public static function get_metadata(collection $collection) : collection { + $collection->add_user_preference('qtype_knowledgecheck_defaultmark', 'privacy:preference:defaultmark'); + return $collection; + } + + /** + * Export all user preferences for the plugin. + * + * @param int $userid The userid of the user whose data is to be exported. + */ + public static function export_user_preferences(int $userid) { + $preference = get_user_preferences('qtype_knowledgecheck_defaultmark', null, $userid); + if (null !== $preference) { + $desc = get_string('privacy:preference:defaultmark', 'qtype_knowledgecheck'); + writer::export_user_preference('qtype_knowledgecheck', 'defaultmark', $preference, $desc); + } + } +} diff --git a/lang/en/qtype_knowledgecheck.php b/lang/en/qtype_knowledgecheck.php index 04a1c5d..a15a3f1 100644 --- a/lang/en/qtype_knowledgecheck.php +++ b/lang/en/qtype_knowledgecheck.php @@ -28,6 +28,8 @@ $string['pluginnameadding'] = 'Adding a knowledge check question'; $string['pluginnameediting'] = 'Editing a knowledge check question'; $string['pluginnamesummary'] = 'Students can check their knowledge and get immediate or delayed feedback (depending on the question settings). All answers are automatically graded and assumed to be correct. The main purpose of this question type is to automatically provide students with feedback on their responses.'; +$string['privacy:metadata'] = 'Knowledgecheck question type plugin allows question authors to set default options as user preferences.'; +$string['privacy:preference:defaultmark'] = 'The default mark set for a given question.'; $string['responsetemplate'] = 'Response template'; $string['responsetemplate_help'] = 'Any text entered here will be displayed in the response input box when a new attempt at the question starts.';