mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-61905-34-privacyworkshop' of git://github.com/mudrd…
…8mz/moodle into MOODLE_34_STABLE
- Loading branch information
Showing
30 changed files
with
2,474 additions
and
188 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
mod/workshop/allocation/manual/classes/privacy/provider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Provides the class {@link workshopallocation_manual\privacy\provider} | ||
* | ||
* @package workshopallocation_manual | ||
* @category privacy | ||
* @copyright 2018 David Mudrák <david@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace workshopallocation_manual\privacy; | ||
|
||
use core_privacy\local\metadata\collection; | ||
use core_privacy\local\request\writer; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Privacy API implementation for the Manual allocation method. | ||
* | ||
* @copyright 2018 David Mudrák <david@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class provider implements \core_privacy\local\metadata\provider, \core_privacy\local\request\user_preference_provider { | ||
|
||
/** | ||
* Describe all the places where this plugin stores some personal data. | ||
* | ||
* @param collection $collection Collection of items to add metadata to. | ||
* @return collection Collection with our added items. | ||
*/ | ||
public static function get_metadata(collection $collection) : collection { | ||
|
||
$collection->add_user_preference('workshopallocation_manual_perpage', 'privacy:metadata:preference:perpage'); | ||
|
||
return $collection; | ||
} | ||
|
||
/** | ||
* Export user preferences controlled by this plugin. | ||
* | ||
* @param int $userid ID of the user we are exporting data form. | ||
*/ | ||
public static function export_user_preferences(int $userid) { | ||
|
||
$perpage = get_user_preferences('workshopallocation_manual_perpage', null, $userid); | ||
|
||
if ($perpage !== null) { | ||
writer::export_user_preference('workshopallocation_manual', 'workshopallocation_manual_perpage', $perpage, | ||
get_string('privacy:metadata:preference:perpage', 'workshopallocation_manual')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
mod/workshop/allocation/manual/tests/privacy_provider_test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Provides the {@link workshopallocation_manual_privacy_provider_testcase} class. | ||
* | ||
* @package workshopallocation_manual | ||
* @category test | ||
* @copyright 2018 David Mudrák <david@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
use core_privacy\local\request\writer; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Unit tests for the privacy API implementation. | ||
* | ||
* @copyright 2018 David Mudrák <david@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class workshopallocation_manual_privacy_provider_testcase extends \core_privacy\tests\provider_testcase { | ||
|
||
/** | ||
* When no preference exists, there should be no export. | ||
*/ | ||
public function test_no_preference() { | ||
global $USER; | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
|
||
\workshopallocation_manual\privacy\provider::export_user_preferences($USER->id); | ||
$this->assertFalse(writer::with_context(\context_system::instance())->has_any_data()); | ||
} | ||
|
||
/** | ||
* Test that the recently selected perpage is exported. | ||
*/ | ||
public function test_export_preferences() { | ||
global $USER; | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
|
||
set_user_preference('workshopallocation_manual_perpage', 81); | ||
|
||
\workshopallocation_manual\privacy\provider::export_user_preferences($USER->id); | ||
$this->assertTrue(writer::with_context(\context_system::instance())->has_any_data()); | ||
|
||
$prefs = writer::with_context(\context_system::instance())->get_user_preferences('workshopallocation_manual'); | ||
$this->assertNotEmpty($prefs->workshopallocation_manual_perpage); | ||
$this->assertEquals(81, $prefs->workshopallocation_manual_perpage->value); | ||
$this->assertContains(get_string('privacy:metadata:preference:perpage', 'workshopallocation_manual'), | ||
$prefs->workshopallocation_manual_perpage->description); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
mod/workshop/allocation/random/classes/privacy/provider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Provides the class {@link workshopallocation_random\privacy\provider} | ||
* | ||
* @package workshopallocation_random | ||
* @category privacy | ||
* @copyright 2018 David Mudrák <david@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace workshopallocation_random\privacy; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Privacy API implementation for the Random allocation method. | ||
* | ||
* @copyright 2018 David Mudrák <david@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class provider implements \core_privacy\local\metadata\null_provider { | ||
|
||
/** | ||
* Explain that this plugin stores no personal data. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_reason() : string { | ||
return 'privacy:metadata'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
mod/workshop/allocation/scheduled/classes/privacy/provider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Provides the class {@link workshopallocation_scheduled\privacy\provider} | ||
* | ||
* @package workshopallocation_scheduled | ||
* @category privacy | ||
* @copyright 2018 David Mudrák <david@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace workshopallocation_scheduled\privacy; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Privacy API implementation for the Scheduled allocation method. | ||
* | ||
* @copyright 2018 David Mudrák <david@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class provider implements \core_privacy\local\metadata\null_provider { | ||
|
||
/** | ||
* Explain that this plugin stores no personal data. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_reason() : string { | ||
return 'privacy:metadata'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.