See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
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 qtype_numerical. 19 * 20 * @package qtype_numerical 21 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace qtype_numerical\privacy; 26 27 use \core_privacy\local\metadata\collection; 28 use \core_privacy\local\request\transform; 29 use \core_privacy\local\request\user_preference_provider; 30 use \core_privacy\local\request\writer; 31 32 defined('MOODLE_INTERNAL') || die(); 33 34 /** 35 * Privacy Subsystem for qtype_numerical implementing user_preference_provider. 36 * 37 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class provider implements 41 // This component has data. 42 // We need to return default options that have been set a user preferences. 43 \core_privacy\local\metadata\provider, 44 \core_privacy\local\request\user_preference_provider 45 { 46 47 /** 48 * Returns meta data about this system. 49 * 50 * @param collection $collection The initialised collection to add items to. 51 * @return collection A listing of user data stored through this system. 52 */ 53 public static function get_metadata(collection $collection) : collection { 54 $collection->add_user_preference('qtype_numerical_defaultmark', 'privacy:preference:defaultmark'); 55 $collection->add_user_preference('qtype_numerical_penalty', 'privacy:preference:penalty'); 56 $collection->add_user_preference('qtype_numerical_unitrole', 'privacy:preference:unitrole'); 57 $collection->add_user_preference('qtype_numerical_unitpenalty', 'privacy:preference:unitpenalty'); 58 $collection->add_user_preference('qtype_numerical_unitgradingtypes', 'privacy:preference:unitgradingtypes'); 59 $collection->add_user_preference('qtype_numerical_multichoicedisplay', 'privacy:preference:multichoicedisplay'); 60 $collection->add_user_preference('qtype_numerical_unitsleft', 'privacy:preference:unitsleft'); 61 return $collection; 62 } 63 64 /** 65 * Export all user preferences for the plugin. 66 * 67 * @param int $userid The userid of the user whose data is to be exported. 68 */ 69 public static function export_user_preferences(int $userid) { 70 $preference = get_user_preferences('qtype_numerical_defaultmark', null, $userid); 71 if (null !== $preference) { 72 $desc = get_string('privacy:preference:defaultmark', 'qtype_numerical'); 73 writer::export_user_preference('qtype_numerical', 'defaultmark', $preference, $desc); 74 } 75 76 $preference = get_user_preferences('qtype_numerical_penalty', null, $userid); 77 if (null !== $preference) { 78 $desc = get_string('privacy:preference:penalty', 'qtype_numerical'); 79 writer::export_user_preference('qtype_numerical', 'penalty', transform::percentage($preference), $desc); 80 } 81 82 $preference = get_user_preferences('qtype_numerical_unitrole', null, $userid); 83 if (null !== $preference) { 84 if ($preference == \qtype_numerical::UNITNONE) { 85 $stringvalue = get_string('onlynumerical', 'qtype_numerical'); 86 } else if ($preference == \qtype_numerical::UNITOPTIONAL) { 87 $stringvalue = get_string('manynumerical', 'qtype_numerical'); 88 } else if ($preference == \qtype_numerical::UNITGRADED) { 89 $stringvalue = get_string('unitgraded', 'qtype_numerical'); 90 } 91 $desc = get_string('privacy:preference:unitrole', 'qtype_numerical'); 92 writer::export_user_preference('qtype_numerical', 'unitrole', $stringvalue, $desc); 93 } 94 95 $preference = get_user_preferences('qtype_numerical_unitpenalty', null, $userid); 96 if (null !== $preference) { 97 $desc = get_string('privacy:preference:unitpenalty', 'qtype_numerical'); 98 writer::export_user_preference('qtype_numerical', 'unitpenalty', $preference, $desc); 99 } 100 101 $preference = get_user_preferences('qtype_numerical_unitgradingtypes', null, $userid); 102 if (null !== $preference) { 103 if ($preference == \qtype_numerical::UNITGRADEDOUTOFMARK) { 104 $stringvalue = get_string('decfractionofresponsegrade', 'qtype_numerical'); 105 } else if ($preference == \qtype_numerical::UNITGRADEDOUTOFMAX) { 106 $stringvalue = get_string('decfractionofquestiongrade', 'qtype_numerical'); 107 } 108 $desc = get_string('privacy:preference:unitgradingtypes', 'qtype_numerical'); 109 writer::export_user_preference('qtype_numerical', 'unitgradingtypes', $stringvalue, $desc); 110 } 111 112 $preference = get_user_preferences('qtype_numerical_multichoicedisplay', null, $userid); 113 if (null !== $preference) { 114 if ($preference == \qtype_numerical::UNITINPUT) { 115 $stringvalue = get_string('editableunittext', 'qtype_numerical'); 116 } else if ($preference == \qtype_numerical::UNITRADIO) { 117 $stringvalue = get_string('unitchoice', 'qtype_numerical'); 118 } else if ($preference == \qtype_numerical::UNITSELECT) { 119 $stringvalue = get_string('unitselect', 'qtype_numerical'); 120 } 121 $desc = get_string('privacy:preference:multichoicedisplay', 'qtype_numerical'); 122 writer::export_user_preference('qtype_numerical', 'multichoicedisplay', $stringvalue, $desc); 123 } 124 125 $preference = get_user_preferences('qtype_numerical_unitsleft', null, $userid); 126 if (null !== $preference) { 127 if ($preference) { 128 $stringvalue = get_string('leftexample', 'qtype_numerical'); 129 } else { 130 $stringvalue = get_string('rightexample', 'qtype_numerical'); 131 } 132 $desc = get_string('privacy:preference:unitsleft', 'qtype_numerical'); 133 writer::export_user_preference('qtype_numerical', 'unitsleft', $stringvalue, $desc); 134 } 135 } 136 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body