See Release Notes
Long Term Support Release
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Privacy Subsystem implementation for scormreport_objectives. 19 * 20 * @package scormreport_objectives 21 * @copyright 2018 Sara Arjona <sara@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace scormreport_objectives\privacy; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use \core_privacy\local\metadata\collection; 30 use \core_privacy\local\request\transform; 31 use \core_privacy\local\request\writer; 32 33 /** 34 * Privacy Subsystem for scormreport_objectives. 35 * 36 * @copyright 2018 Sara Arjona <sara@moodle.com> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class provider implements 40 \core_privacy\local\metadata\provider, 41 \core_privacy\local\request\user_preference_provider { 42 43 /** 44 * Returns meta data about this system. 45 * 46 * @param collection $collection The initialised item collection to add items to. 47 * @return collection A listing of user data stored through this system. 48 */ 49 public static function get_metadata(collection $collection) : collection { 50 // User preferences shared between different scorm reports. 51 $collection->add_user_preference('scorm_report_pagesize', 'privacy:metadata:preference:scorm_report_pagesize'); 52 53 // User preferences specific for this scorm report. 54 $collection->add_user_preference( 55 'scorm_report_objectives_score', 56 'privacy:metadata:preference:scorm_report_objectives_score' 57 ); 58 59 return $collection; 60 } 61 62 /** 63 * Store all user preferences for the plugin. 64 * 65 * @param int $userid The userid of the user whose data is to be exported. 66 */ 67 public static function export_user_preferences(int $userid) { 68 static::get_and_export_user_preference($userid, 'scorm_report_pagesize'); 69 static::get_and_export_user_preference($userid, 'scorm_report_objectives_score', true); 70 } 71 72 /** 73 * Get and export a user preference. 74 * 75 * @param int $userid The userid of the user whose data is to be exported. 76 * @param string $userpreference The user preference to export. 77 * @param boolean $transform If true, transform value to yesno. 78 */ 79 protected static function get_and_export_user_preference(int $userid, string $userpreference, $transform = false) { 80 $prefvalue = get_user_preferences($userpreference, null, $userid); 81 if ($prefvalue !== null) { 82 if ($transform) { 83 $transformedvalue = transform::yesno($prefvalue); 84 } else { 85 $transformedvalue = $prefvalue; 86 } 87 writer::export_user_preference( 88 'scormreport_objectives', 89 $userpreference, 90 $transformedvalue, 91 get_string('privacy:metadata:preference:'.$userpreference, 'scormreport_objectives') 92 ); 93 } 94 } 95 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body