Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]
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 quiz_grading. 19 * 20 * @package quiz_grading 21 * @copyright 2020 The Open University 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace quiz_grading\privacy; 26 27 use core_privacy\local\metadata\collection; 28 use core_privacy\local\request\writer; 29 30 defined('MOODLE_INTERNAL') || die(); 31 32 /** 33 * Privacy subsystem for quiz_grading. 34 */ 35 class provider implements 36 \core_privacy\local\metadata\provider, 37 \core_privacy\local\request\user_preference_provider { 38 39 /** 40 * Returns meta data about this system. 41 * 42 * @param collection $collection The initialised collection to add items to. 43 * @return collection A listing of user data stored through this system. 44 */ 45 public static function get_metadata(collection $collection) : collection { 46 $collection->add_user_preference('quiz_grading_pagesize', 'privacy:preference:pagesize'); 47 $collection->add_user_preference('quiz_grading_order', 'privacy:preference:order'); 48 49 return $collection; 50 } 51 52 /** 53 * Export all user preferences for the plugin. 54 * 55 * @param int $userid The userid of the user whose data is to be exported. 56 */ 57 public static function export_user_preferences(int $userid) { 58 59 // Page size. 60 $pagesize = get_user_preferences("quiz_grading_pagesize", null, $userid); 61 if ($pagesize !== null) { 62 writer::export_user_preference('quiz_grading', 'pagesize', $pagesize, 63 get_string('privacy:preference:pagesize', 'quiz_grading')); 64 } 65 66 // Attempt order. 67 $order = get_user_preferences("quiz_grading_order", null, $userid); 68 if ($order !== null) { 69 switch ($order) { 70 case 'random': 71 $order = get_string('random', 'quiz_grading'); 72 break; 73 case 'date': 74 $order = get_string('date'); 75 break; 76 case 'studentfirstname': 77 $order = get_string('studentfirstname', 'quiz_grading'); 78 break; 79 case 'studentlastname': 80 $order = get_string('studentlastname', 'quiz_grading'); 81 break; 82 default: 83 $order = \core_user\fields::get_display_name($order); 84 } 85 writer::export_user_preference('quiz_grading', 'order', $order, 86 get_string('privacy:preference:order', 'quiz_grading')); 87 } 88 } 89 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body