Skip to content

Commit

Permalink
adds metadata provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
stopfstedt committed Mar 16, 2024
1 parent be91d4d commit e9eebf1
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
67 changes: 67 additions & 0 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* 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);
}
}
}
2 changes: 2 additions & 0 deletions lang/en/qtype_knowledgecheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';

0 comments on commit e9eebf1

Please sign in to comment.