var expected = semver.validRange(grunt.file.readJSON('package.json').engines.node);
var actual = semver.valid(process.version);
if (!semver.satisfies(actual, expected)) {
- grunt.fail.fatal('Node version too old. Require ' + expected + ', version installed: ' + actual);
+ grunt.fail.fatal('Node version not satisfied. Require ' + expected + ', version installed: ' + actual);
}
// Windows users can't run grunt in a subdirectory, so allow them to set
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
+ <MOODLE version="3.6" requires="3.1">
+ <UNICODE level="required">
+ <FEEDBACK>
+ <ON_ERROR message="unicoderequired" />
+ </FEEDBACK>
+ </UNICODE>
+ <DATABASE level="required">
+ <VENDOR name="mariadb" version="5.5.31" />
+ <VENDOR name="mysql" version="5.6" />
+ <VENDOR name="postgres" version="9.4" />
+ <VENDOR name="mssql" version="10.0" />
+ <VENDOR name="oracle" version="11.2" />
+ </DATABASE>
+ <PHP version="7.0.0" level="required">
+ </PHP>
+ <PCREUNICODE level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="pcreunicodewarning" />
+ </FEEDBACK>
+ </PCREUNICODE>
+ <PHP_EXTENSIONS>
+ <PHP_EXTENSION name="iconv" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="iconvrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="mbstring" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="mbstringrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="curl" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="curlrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="openssl" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="opensslrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="tokenizer" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="tokenizerrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="xmlrpc" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="xmlrpcrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="soap" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="soaprecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="ctype" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="ctyperequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="zip" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="ziprequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="zlib" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="gd" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="gdrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="simplexml" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="simplexmlrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="spl" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="splrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="pcre" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="dom" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="xml" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="xmlreader" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="intl" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="intlrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="json" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="hash" level="required"/>
+ <PHP_EXTENSION name="fileinfo" level="required"/>
+ </PHP_EXTENSIONS>
+ <PHP_SETTINGS>
+ <PHP_SETTING name="memory_limit" value="96M" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="settingmemorylimit" />
+ </FEEDBACK>
+ </PHP_SETTING>
+ <PHP_SETTING name="file_uploads" value="1" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="settingfileuploads" />
+ </FEEDBACK>
+ </PHP_SETTING>
+ <PHP_SETTING name="opcache.enable" value="1" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="opcacherecommended" />
+ </FEEDBACK>
+ </PHP_SETTING>
+ </PHP_SETTINGS>
+ <CUSTOM_CHECKS>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="unsupporteddbstorageengine" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="quizattemptsupgradedmessage" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="slashargumentswarning" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="unsupporteddbtablerowformat" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_unoconv_version" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="unoconvwarning" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="libcurlwarning" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_format" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="unsupporteddbfileformat" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_per_table" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="unsupporteddbfilepertable" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_large_prefix" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="unsupporteddblargeprefix" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_is_https" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="ishttpswarning" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_incomplete_unicode_support" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="incompleteunicodesupport" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ <CUSTOM_CHECK file="lib/upgradelib.php" function="check_sixtyfour_bits" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="sixtyfourbitswarning" />
+ </FEEDBACK>
+ </CUSTOM_CHECK>
+ </CUSTOM_CHECKS>
+ </MOODLE>
</COMPATIBILITY_MATRIX>
$table->set_attribute('class', 'admintable generaltable');
$table->setup();
+ $pluginmanager = core_plugin_manager::instance();
+
foreach ($modules as $module) {
+ $plugininfo = $pluginmanager->get_plugin_info('mod_'.$module->name);
+ $status = $plugininfo->get_status();
- if (!file_exists("$CFG->dirroot/mod/$module->name/lib.php")) {
+ if ($status === core_plugin_manager::PLUGIN_STATUS_MISSING) {
$strmodulename = '<span class="notifyproblem">'.$module->name.' ('.get_string('missingfromdisk').')</span>';
$missing = true;
} else {
if ($siteunregistrationform->is_cancelled()) {
redirect(new moodle_url('/admin/registration/index.php'));
} else if ($data = $siteunregistrationform->get_data()) {
- if (\core\hub\registration::unregister($data->unpublishalladvertisedcourses,
- $data->unpublishalluploadedcourses)) {
+ \core\hub\registration::unregister($data->unpublishalladvertisedcourses,
+ $data->unpublishalluploadedcourses);
+ if (!\core\hub\registration::is_registered()) {
redirect(new moodle_url('/admin/registration/index.php'));
}
}
}
public function save_changes() {
- global $DB, $CFG;
+ global $DB;
if (!$this->roleid) {
// Creating role.
// the UI. It would be better to do this only when we know that fields affected are
// updated. But thats getting into the weeds of the coursecat cache and role edits
// should not be that frequent, so here is the ugly brutal approach.
- require_once($CFG->libdir . '/coursecatlib.php');
- coursecat::role_assignment_changed($this->role->id, context_system::instance());
+ core_course_category::role_assignment_changed($this->role->id, context_system::instance());
}
// Assignable contexts.
Scenario: Enable registration of multiple accounts with the same email address
Given the following config values are set as admin:
| allowaccountssameemail | 1 |
- When I navigate to "Add a new user" node in "Site administration>Users>Accounts"
+ When I navigate to "Users > Accounts > Add a new user" in site administration
And I set the following fields to these values:
| Username | testmultiemailuser1 |
| Choose an authentication method | Manual accounts |
Scenario: Disable registration of multiple accounts with the same email address
Given the following config values are set as admin:
| allowaccountssameemail | 0 |
- When I navigate to "Add a new user" node in "Site administration>Users>Accounts"
+ When I navigate to "Users > Accounts > Add a new user" in site administration
And I set the following fields to these values:
| Username | testmultiemailuser1 |
| Choose an authentication method | Manual accounts |
+++ /dev/null
-<?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/>.
-
-/**
- * Script to show all the assignments that have not been upgraded after the main upgrade.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-define('NO_OUTPUT_BUFFERING', true);
-
-require_once(__DIR__ . '/../../../config.php');
-require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentstable.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentsbatchform.php');
-
-require_sesskey();
-
-// This calls require_login and checks moodle/site:config.
-admin_externalpage_setup('assignmentupgrade', '', array(), tool_assignmentupgrade_url('batchupgrade'));
-
-$PAGE->set_pagelayout('maintenance');
-$PAGE->navbar->add(get_string('batchupgrade', 'tool_assignmentupgrade'));
-
-$renderer = $PAGE->get_renderer('tool_assignmentupgrade');
-
-$confirm = required_param('confirm', PARAM_BOOL);
-if (!$confirm) {
- print_error('invalidrequest');
- die();
-}
-raise_memory_limit(MEMORY_EXTRA);
-// Release session.
-\core\session\manager::write_close();
-
-echo $renderer->header();
-echo $renderer->heading(get_string('batchupgrade', 'tool_assignmentupgrade'));
-
-$current = 0;
-if (optional_param('upgradeall', false, PARAM_BOOL)) {
- $assignmentids = tool_assignmentupgrade_load_all_upgradable_assignmentids();
-} else {
- $assignmentids = explode(',', optional_param('selected', '', PARAM_TEXT));
-}
-$total = count($assignmentids);
-
-foreach ($assignmentids as $assignmentid) {
- list($summary, $success, $log) = tool_assignmentupgrade_upgrade_assignment($assignmentid);
- $current += 1;
- $params = array('current'=>$current, 'total'=>$total);
- echo $renderer->heading(get_string('upgradeprogress', 'tool_assignmentupgrade', $params), 3);
- echo $renderer->convert_assignment_result($summary, $success, $log);
-}
-
-echo $renderer->continue_button(tool_assignmentupgrade_url('listnotupgraded'));
-echo $renderer->footer();
+++ /dev/null
-<?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 tool_assignmentupgrade.
- *
- * @package tool_assignmentupgrade
- * @copyright 2018 Zig Tan <zig@moodle.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace tool_assignmentupgrade\privacy;
-
-use core_privacy\local\metadata\collection;
-use core_privacy\local\request\writer;
-
-defined('MOODLE_INTERNAL') || die();
-
-/**
- * Privacy Subsystem for tool_assignmentupgrade implementing metadata, plugin, and user_preference providers.
- *
- * @copyright 2018 Zig Tan <zig@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 {
-
- /**
- * 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(
- 'tool_assignmentupgrade_perpage',
- 'privacy:metadata:preference:perpage'
- );
- 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) {
- $perpage = get_user_preferences('tool_assignmentupgrade_perpage', null, $userid);
- if ($perpage !== null) {
- writer::export_user_preference(
- 'tool_assignmentupgrade',
- 'perpage',
- $perpage,
- get_string('privacy:metadata:preference:perpage', 'tool_assignmentupgrade')
- );
- }
- }
-
-}
+++ /dev/null
-<?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/>.
-
-/**
- * This tool can upgrade old assignment activities to the new assignment activity type
- *
- * The upgrade can be done on any old assignment instance providing it is using one of the core
- * assignment subtypes (online text, single upload, etc).
- * The new assignment module was introduced in Moodle 2.3 and although it completely reproduces
- * the features of the existing assignment type it wasn't designed to replace it entirely as there
- * are many custom assignment types people use and it wouldn't be practical to try to convert them.
- * Instead the existing assignment type will be left in core and people will be encouraged to
- * use the new assignment type.
- *
- * This screen is the main entry-point to the plugin, it gives the admin a list
- * of options available to them.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once(__DIR__ . '/../../../config.php');
-require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
-
-// This calls require_login and checks moodle/site:config.
-admin_externalpage_setup('assignmentupgrade');
-
-$renderer = $PAGE->get_renderer('tool_assignmentupgrade');
-
-$actions = array();
-
-$header = get_string('pluginname', 'tool_assignmentupgrade');
-$actions[] = tool_assignmentupgrade_action::make('listnotupgraded');
-
-echo $renderer->index_page($header, $actions);
+++ /dev/null
-<?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/>.
-
-/**
- * Strings for the assignment upgrade tool
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-$string['areyousure'] = 'Are you sure?';
-$string['areyousuremessage'] = 'Are you sure you want to upgrade the assignment "{$a->name}"?';
-$string['assignmentid'] = 'Assignment ID';
-$string['assignmentnotfound'] = 'Assignment could not be found (id={$a})';
-$string['assignmentsperpage'] = 'Assignments per page';
-$string['assignmenttype'] = 'Assignment type';
-$string['backtoindex'] = 'Back to index';
-$string['batchoperations'] = 'Batch operations';
-$string['batchupgrade'] = 'Upgrade multiple assignments';
-$string['confirmbatchupgrade'] = 'Confirm batch upgrade assignments';
-$string['conversioncomplete'] = 'Assignment converted';
-$string['conversionfailed'] = 'The assignment conversion was not successful. The log from the upgrade was: <br />{$a}';
-$string['listnotupgraded'] = 'List assignments that have not been upgraded';
-$string['listnotupgraded_desc'] = 'You can upgrade individual assignments from here';
-$string['noassignmentsselected'] = 'No assignments selected';
-$string['noassignmentstoupgrade'] = 'There are no assignments that require upgrading';
-$string['notsupported'] = '';
-$string['notupgradedintro'] = 'This page lists the assignments created with an older version of Moodle that have not been upgraded to the new assignment module in Moodle 2.3. Not all assignments can be upgraded - if they were created with a custom assignment subtype, then that subtype will need to be upgraded to the new assignment plugin format in order to complete the upgrade.';
-$string['notupgradedtitle'] = 'Assignments not upgraded';
-$string['pluginname'] = 'Assignment upgrade helper';
-$string['select'] = 'Select';
-$string['submissions'] = 'Submissions';
-$string['supported'] = 'Upgrade';
-$string['updatetable'] = 'Update table';
-$string['unknown'] = 'Unknown';
-$string['upgradeassignmentsummary'] = 'Upgrade assignment: {$a->name} (Course: {$a->shortname})';
-$string['upgradeassignmentsuccess'] = 'Result: Upgrade successful';
-$string['upgradeassignmentfailed'] = 'Result: Upgrade failed. The log from the upgrade was: <br/><div class="tool_assignmentupgrade_upgradelog">{$a->log}</div>';
-$string['upgradable'] = 'Upgradable';
-$string['upgradeselected'] = 'Upgrade selected assignments';
-$string['upgradeselectedcount'] = 'Upgrade {$a} selected assignments?';
-$string['upgradeall'] = 'Upgrade all assignments';
-$string['upgradeallconfirm'] = 'Upgrade all assignments?';
-$string['upgradeprogress'] = 'Upgrade assignment {$a->current} of {$a->total}';
-$string['upgradesingle'] = 'Upgrade single assignment';
-$string['viewcourse'] = 'View the course with the converted assignment';
-$string['privacy:metadata:preference:perpage'] = 'The assignment upgrade records per page preference set for the user.';
+++ /dev/null
-<?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/>.
-
-/**
- * Script to show all the assignments that have not been upgraded after the main upgrade.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once(__DIR__ . '/../../../config.php');
-require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentstable.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentsbatchform.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/paginationform.php');
-
-// This calls require_login and checks moodle/site:config.
-admin_externalpage_setup('assignmentupgrade', '', array(), tool_assignmentupgrade_url('listnotupgraded'));
-$PAGE->navbar->add(get_string('listnotupgraded', 'tool_assignmentupgrade'));
-
-$renderer = $PAGE->get_renderer('tool_assignmentupgrade');
-
-$perpage = optional_param('perpage', 0, PARAM_INT);
-if (!$perpage) {
- $perpage = get_user_preferences('tool_assignmentupgrade_perpage', 100);
-} else {
- set_user_preference('tool_assignmentupgrade_perpage', $perpage);
-}
-$assignments = new tool_assignmentupgrade_assignments_table($perpage);
-
-$batchform = new tool_assignmentupgrade_batchoperations_form();
-$data = $batchform->get_data();
-
-if ($data && $data->selectedassignments != '' || $data && isset($data->upgradeall)) {
- require_sesskey();
- echo $renderer->confirm_batch_operation_page($data);
-} else {
- $paginationform = new tool_assignmentupgrade_pagination_form();
- $pagedata = new stdClass();
- $pagedata->perpage = $perpage;
- $paginationform->set_data($pagedata);
- echo $renderer->assignment_list_page($assignments, $batchform, $paginationform);
-}
-
+++ /dev/null
-<?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/>.
-
-/**
- * Assignment upgrade tool library functions
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-/**
- * Get the URL of a script within this plugin.
- * @param string $script the script name, without .php. E.g. 'index'
- * @param array $params URL parameters (optional)
- * @return moodle_url
- */
-function tool_assignmentupgrade_url($script, $params = array()) {
- return new moodle_url('/admin/tool/assignmentupgrade/' . $script . '.php', $params);
-}
-
-/**
- * Class to encapsulate the continue / cancel for batch operations
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class tool_assignmentupgrade_batchoperationconfirm implements renderable {
- /** @var string $continuemessage The message to show above the continue cancel buttons */
- public $continuemessage = '';
- /** @var string $continueurl The url to load if the user clicks continue */
- public $continueurl;
-
- /**
- * Constructor for this class
- * @param stdClass $data - The data from the previous batch form
- */
- public function __construct($data) {
- if (isset($data->upgradeselected)) {
- $this->continuemessage = get_string('upgradeselectedcount',
- 'tool_assignmentupgrade',
- count(explode(',', $data->selectedassignments)));
- $urlparams = array('upgradeselected'=>'1',
- 'confirm'=>'1',
- 'sesskey'=>sesskey(),
- 'selected'=>$data->selectedassignments);
- $this->continueurl = new moodle_url('/admin/tool/assignmentupgrade/batchupgrade.php', $urlparams);
- } else if (isset($data->upgradeall)) {
- if (!tool_assignmentupgrade_any_upgradable_assignments()) {
- $this->continuemessage = get_string('noassignmentstoupgrade', 'tool_assignmentupgrade');
- $this->continueurl = '';
- } else {
- $this->continuemessage = get_string('upgradeallconfirm', 'tool_assignmentupgrade');
- $urlparams = array('upgradeall'=>'1', 'confirm'=>'1', 'sesskey'=>sesskey());
- $this->continueurl = new moodle_url('/admin/tool/assignmentupgrade/batchupgrade.php', $urlparams);
- }
- }
- }
-}
-
-
-/**
- * Class to encapsulate one of the functionalities that this plugin offers.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class tool_assignmentupgrade_action {
- /** @var string the name of this action. */
- public $name;
- /** @var moodle_url the URL to launch this action. */
- public $url;
- /** @var string a description of this aciton. */
- public $description;
-
- /**
- * Constructor to set the fields.
- *
- * In order to create a new tool_assignmentupgrade_action instance you must use
- * the tool_assignmentupgrade_action::make
- * method.
- *
- * @param string $name the name of this action.
- * @param moodle_url $url the URL to launch this action.
- * @param string $description a description of this aciton.
- */
- protected function __construct($name, moodle_url $url, $description) {
- $this->name = $name;
- $this->url = $url;
- $this->description = $description;
- }
-
- /**
- * Make an action with standard values.
- * @param string $shortname internal name of the action. Used to get strings and build a URL.
- * @param array $params any URL params required.
- * @return tool_assignmentupgrade_action
- */
- public static function make($shortname, $params = array()) {
- return new self(
- get_string($shortname, 'tool_assignmentupgrade'),
- tool_assignmentupgrade_url($shortname, $params),
- get_string($shortname . '_desc', 'tool_assignmentupgrade'));
- }
-}
-
-/**
- * Determine if there are any assignments that can be upgraded
- * @return boolean - Are there any assignments that can be upgraded
- */
-function tool_assignmentupgrade_any_upgradable_assignments() {
- global $DB, $CFG;
- require_once($CFG->dirroot . '/mod/assign/locallib.php');
- // First find all the unique assignment types.
- $types = $DB->get_records_sql('SELECT plugin AS assignmenttype,
- value AS version
- FROM {config_plugins}
- WHERE
- name = ? AND
- plugin LIKE ?', array('version', 'assignment_%'));
-
- $upgradabletypes = array();
-
- foreach ($types as $assignment) {
- $shorttype = substr($assignment->assignmenttype, strlen('assignment_'));
- if (assign::can_upgrade_assignment($shorttype, $assignment->version)) {
- $upgradabletypes[] = $shorttype;
- }
- }
- list($sql, $params) = $DB->get_in_or_equal($upgradabletypes);
-
- $count = $DB->count_records_sql('SELECT COUNT(id) FROM {assignment} WHERE assignmenttype ' . $sql, $params);
-
- return $count > 0;
-}
-
-/**
- * Load a list of all the assignmentids that can be upgraded
- * @return array of assignment ids
- */
-function tool_assignmentupgrade_load_all_upgradable_assignmentids() {
- global $DB, $CFG;
- require_once($CFG->dirroot . '/mod/assign/locallib.php');
- // First find all the unique assignment types.
- $types = $DB->get_records_sql('SELECT
- plugin AS assignmenttype,
- value AS version
- FROM {config_plugins}
- WHERE
- name = ? AND
- plugin LIKE ?', array('version', 'assignment_%'));
-
- $upgradabletypes = array();
-
- foreach ($types as $assignment) {
- $shorttype = substr($assignment->assignmenttype, strlen('assignment_'));
- if (assign::can_upgrade_assignment($shorttype, $assignment->version)) {
- $upgradabletypes[] = $shorttype;
- }
- }
-
- list($sql, $params) = $DB->get_in_or_equal($upgradabletypes);
-
- $records = $DB->get_records_sql('SELECT id from {assignment} where assignmenttype ' . $sql, $params);
- $ids = array();
- foreach ($records as $record) {
- $ids[] = $record->id;
- }
-
- return $ids;
-}
-
-
-/**
- * Upgrade a single assignment. This is used by both upgrade single and upgrade batch
- *
- * @param int $assignmentid - The assignment id to upgrade
- * @return array(string, boolean, string) -
- * The array contains
- * - the assignment summary (returned by tool_assignmentupgrade_get_assignment)
- * - success
- * - the upgrade log
- */
-function tool_assignmentupgrade_upgrade_assignment($assignmentid) {
- global $CFG;
- require_once($CFG->dirroot . '/mod/assign/upgradelib.php');
-
- $assignment_upgrader = new assign_upgrade_manager();
- $info = tool_assignmentupgrade_get_assignment($assignmentid);
- if ($info) {
- $log = '';
- $success = $assignment_upgrader->upgrade_assignment($assignmentid, $log);
- } else {
- $success = false;
- $log = get_string('assignmentnotfound', 'tool_assignmentupgrade', $assignmentid);
- $info = new stdClass();
- $info->name = get_string('unknown', 'tool_assignmentupgrade');
- $info->shortname = get_string('unknown', 'tool_assignmentupgrade');
- }
-
- return array($info, $success, $log);
-}
-
-/**
- * Get the information about a assignment to be upgraded.
- * @param int $assignmentid the assignment id.
- * @return stdClass the information about that assignment.
- */
-function tool_assignmentupgrade_get_assignment($assignmentid) {
- global $DB;
- return $DB->get_record_sql("
- SELECT a.id, a.name, c.shortname, c.id AS courseid
- FROM {assignment} a
- JOIN {course} c ON c.id = a.course
- WHERE a.id = ?", array($assignmentid));
-}
-
+++ /dev/null
-M.tool_assignmentupgrade = {
- init_upgrade_table: function(Y) {
-
- Y.use('node', function(Y) {
- checkboxes = Y.all('td.c0 input');
- checkboxes.each(function(node) {
- node.on('change', function(e) {
- rowelement = e.currentTarget.get('parentNode').get('parentNode');
- if (e.currentTarget.get('checked')) {
- rowelement.setAttribute('class', 'selectedrow');
- } else {
- rowelement.setAttribute('class', 'unselectedrow');
- }
- });
-
- rowelement = node.get('parentNode').get('parentNode');
- if (node.get('checked')) {
- rowelement.setAttribute('class', 'selectedrow');
- } else {
- rowelement.setAttribute('class', 'unselectedrow');
- }
- });
- });
-
- var selectall = Y.one('th.c0 input');
- selectall.on('change', function(e) {
- if (e.currentTarget.get('checked')) {
- checkboxes = Y.all('td.c0 input');
- checkboxes.each(function(node) {
- rowelement = node.get('parentNode').get('parentNode');
- node.set('checked', true);
- rowelement.setAttribute('class', 'selectedrow');
- });
- } else {
- checkboxes = Y.all('td.c0 input');
- checkboxes.each(function(node) {
- rowelement = node.get('parentNode').get('parentNode');
- node.set('checked', false);
- rowelement.setAttribute('class', 'unselectedrow');
- });
- }
- });
-
- var upgradeselectedbutton = Y.one('#id_upgradeselected');
- upgradeselectedbutton.on('click', function(e) {
- checkboxes = Y.all('td.c0 input');
- var selectedassignments = [];
- checkboxes.each(function(node) {
- if (node.get('checked')) {
- selectedassignments[selectedassignments.length] = node.get('value');
- }
- });
-
- operation = Y.one('#id_operation');
- assignmentsinput = Y.one('input.selectedassignments');
- assignmentsinput.set('value', selectedassignments.join(','));
- if (selectedassignments.length == 0) {
- alert(M.util.get_string('noassignmentsselected', 'tool_assignmentupgrade'));
- e.preventDefault();
- }
- });
-
- var perpage = Y.one('#id_perpage');
- perpage.on('change', function(e) {
- window.onbeforeunload = null;
- Y.one('.tool_assignmentupgrade_paginationform form').submit();
- });
-
- }
-}
+++ /dev/null
-<?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/>.
-
-/**
- * This file contains the forms to create and edit an instance of this module
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
-
-require_once($CFG->libdir.'/formslib.php');
-
-/**
- * Assignment upgrade table display options
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class tool_assignmentupgrade_pagination_form extends moodleform {
- /**
- * Define this form - called from the parent constructor
- */
- public function definition() {
- $mform = $this->_form;
- $instance = $this->_customdata;
-
- $mform->addElement('header', 'general', get_string('assignmentsperpage', 'tool_assignmentupgrade'));
- // Visible elements.
- $options = array(10=>'10', 20=>'20', 50=>'50', 100=>'100');
- $mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options);
-
- // Hidden params.
- $mform->addElement('hidden', 'action', 'saveoptions');
- $mform->setType('action', PARAM_ALPHA);
-
- // Buttons.
- $this->add_action_buttons(false, get_string('updatetable', 'tool_assignmentupgrade'));
- }
-}
-
+++ /dev/null
-<?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/>.
-
-/**
- * Defines the renderer for the assignment upgrade helper plugin.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-/**
- * Renderer for the assignment upgrade helper plugin.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class tool_assignmentupgrade_renderer extends plugin_renderer_base {
-
- /**
- * Render the index page.
- * @param string $detected information about what sort of site was detected.
- * @param array $actions list of actions to show on this page.
- * @return string html to output.
- */
- public function index_page($detected, array $actions) {
- $output = '';
- $output .= $this->header();
- $output .= $this->heading(get_string('pluginname', 'tool_assignmentupgrade'));
- $output .= $this->box($detected);
- $output .= html_writer::start_tag('ul');
- foreach ($actions as $action) {
- $output .= html_writer::tag('li',
- html_writer::link($action->url, $action->name) . ' - ' .
- $action->description);
- }
- $output .= html_writer::end_tag('ul');
- $output .= $this->footer();
- return $output;
- }
-
- /**
- * Render a page that is just a simple message.
- * @param string $message the message to display.
- * @return string html to output.
- */
- public function simple_message_page($message) {
- $output = '';
- $output .= $this->header();
- $output .= $this->heading($message);
- $output .= $this->back_to_index();
- $output .= $this->footer();
- return $output;
- }
-
- /**
- * Render the confirm batch operation page
- * @param stdClass $data Submitted form data with list of assignments to upgrade
- * @return string html to output.
- */
- public function confirm_batch_operation_page(stdClass $data) {
- $output = '';
- $output .= $this->header();
-
- $output .= $this->heading(get_string('confirmbatchupgrade', 'tool_assignmentupgrade'));
- $output .= $this->output->spacer(array(), true);
-
- $output .= $this->container_start('tool_assignmentupgrade_confirmbatch');
-
- $output .= $this->render(new tool_assignmentupgrade_batchoperationconfirm($data));
- $output .= $this->container_end();
-
- $output .= $this->back_to_index();
- $output .= $this->footer();
- return $output;
- }
-
- /**
- * Render the confirm batch continue / cancel links
- * @param tool_assignmentupgrade_batchoperationconfirm $confirm Wrapper class to determine the continue message and url
- * @return string html to output.
- */
- public function render_tool_assignmentupgrade_batchoperationconfirm(tool_assignmentupgrade_batchoperationconfirm $confirm) {
- $output = '';
-
- if ($confirm->continueurl) {
- $output .= $this->output->confirm($confirm->continuemessage,
- $confirm->continueurl,
- tool_assignmentupgrade_url('listnotupgraded'));
- } else {
- $output .= $this->output->box($confirm->continuemessage);
- $output .= $this->output->continue_button(tool_assignmentupgrade_url('listnotupgraded'));
- }
- return $output;
- }
-
- /**
- * Render the list of assignments that still need to be upgraded page.
- * @param tool_assignmentupgrade_assignments_table $assignments of data about assignments.
- * @param tool_assignmentupgrade_batchoperations_form $batchform Submitted form with list of assignments to upgrade
- * @param tool_assignmentupgrade_pagination_form $paginationform Form which contains the preferences for paginating the table
- * @return string html to output.
- */
- public function assignment_list_page(tool_assignmentupgrade_assignments_table $assignments,
- tool_assignmentupgrade_batchoperations_form $batchform,
- tool_assignmentupgrade_pagination_form $paginationform) {
- $output = '';
- $output .= $this->header();
- $this->page->requires->js_init_call('M.tool_assignmentupgrade.init_upgrade_table', array());
- $this->page->requires->string_for_js('noassignmentsselected', 'tool_assignmentupgrade');
-
- $output .= $this->heading(get_string('notupgradedtitle', 'tool_assignmentupgrade'));
- $output .= $this->box(get_string('notupgradedintro', 'tool_assignmentupgrade'));
- $output .= $this->output->spacer(array(), true);
-
- $output .= $this->container_start('tool_assignmentupgrade_upgradetable');
-
- $output .= $this->container_start('tool_assignmentupgrade_paginationform');
- $output .= $this->moodleform($paginationform);
- $output .= $this->container_end();
-
- $output .= $this->flexible_table($assignments, $assignments->get_rows_per_page(), true);
- $output .= $this->container_end();
-
- if ($assignments->anyupgradableassignments) {
- $output .= $this->container_start('tool_assignmentupgrade_batchform');
- $output .= $this->moodleform($batchform);
- $output .= $this->container_end();
- }
-
- $output .= $this->back_to_index();
- $output .= $this->footer();
- return $output;
- }
-
- /**
- * Render the result of an assignment conversion
- * @param stdClass $assignmentsummary data about the assignment to upgrade.
- * @param bool $success Set to true if the outcome of the conversion was a success
- * @param string $log The log from the conversion
- * @return string html to output.
- */
- public function convert_assignment_result($assignmentsummary, $success, $log) {
- $output = '';
-
- $output .= $this->container_start('tool_assignmentupgrade_result');
- $output .= $this->container(get_string('upgradeassignmentsummary', 'tool_assignmentupgrade', $assignmentsummary));
- if (!$success) {
- $output .= $this->container(get_string('conversionfailed', 'tool_assignmentupgrade', $log));
- } else {
- $output .= $this->container(get_string('upgradeassignmentsuccess', 'tool_assignmentupgrade'));
- $url = new moodle_url('/course/view.php', array('id'=>$assignmentsummary->courseid));
- $output .= $this->container(html_writer::link($url, get_string('viewcourse', 'tool_assignmentupgrade')));
- }
- $output .= $this->container_end();
-
- return $output;
- }
-
- /**
- * Render the are-you-sure page to confirm a manual upgrade.
- * @param stdClass $assignmentsummary data about the assignment to upgrade.
- * @return string html to output.
- */
- public function convert_assignment_are_you_sure($assignmentsummary) {
- $output = '';
- $output .= $this->header();
- $output .= $this->heading(get_string('areyousure', 'tool_assignmentupgrade'));
-
- $params = array('id' => $assignmentsummary->id, 'confirmed' => 1, 'sesskey' => sesskey());
- $output .= $this->confirm(get_string('areyousuremessage', 'tool_assignmentupgrade', $assignmentsummary),
- new single_button(tool_assignmentupgrade_url('upgradesingle', $params), get_string('yes')),
- tool_assignmentupgrade_url('listnotupgraded'));
-
- $output .= $this->footer();
- return $output;
- }
-
- /**
- * Helper method dealing with the fact we can not just fetch the output of flexible_table
- *
- * @param flexible_table $table
- * @param int $rowsperpage
- * @param bool $displaylinks Show links in the table
- * @return string HTML
- */
- protected function flexible_table(flexible_table $table, $rowsperpage, $displaylinks) {
-
- $o = '';
- ob_start();
- $table->out($rowsperpage, $displaylinks);
- $o = ob_get_contents();
- ob_end_clean();
-
- return $o;
- }
-
- /**
- * Helper method dealing with the fact we can not just fetch the output of moodleforms
- *
- * @param moodleform $mform
- * @return string HTML
- */
- protected function moodleform(moodleform $mform) {
-
- $o = '';
- ob_start();
- $mform->display();
- $o = ob_get_contents();
- ob_end_clean();
-
- return $o;
- }
-
-
- /**
- * Render a link in a div, such as the 'Back to plugin main page' link.
- * @param string|moodle_url $url the link URL.
- * @param string $text the link text.
- * @return string html to output.
- */
- public function end_of_page_link($url, $text) {
- return html_writer::tag('div', html_writer::link($url, $text), array('class' => 'mdl-align'));
- }
-
- /**
- * Output a link back to the plugin index page.
- * @return string html to output.
- */
- public function back_to_index() {
- return $this->end_of_page_link(tool_assignmentupgrade_url('index'), get_string('backtoindex', 'tool_assignmentupgrade'));
- }
-}
+++ /dev/null
-#page-admin-tool-assignmentupgrade-listnotupgraded .tool_assignmentupgrade_upgradetable .c0 {
- display: none;
-}
-
-#page-admin-tool-assignmentupgrade-listnotupgraded.jsenabled .tool_assignmentupgrade_upgradetable .c0 {
- display: table-cell;
-}
-/*
-.gradingbatchoperationsform { display: none; }
-.jsenabled .gradingbatchoperationsform { display: block; }
-*/
-
-#page-admin-tool-assignmentupgrade-listnotupgraded .tool_assignmentupgrade_upgradetable tr.selectedrow td {
- background-color: #fec;
-}
-
-#page-admin-tool-assignmentupgrade-listnotupgraded .tool_assignmentupgrade_upgradetable tr.unselectedrow td {
- background-color: white;
-}
-
-#page-admin-tool-assignmentupgrade-listnotupgraded .tool_assignmentupgrade_paginationform .hidden {
- display: none;
-}
+++ /dev/null
-<?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 tests for tool_assignmentupgrade.
- *
- * @package tool_assignmentupgrade
- * @category test
- * @copyright 2018 Zig Tan <zig@moodle.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-use \core_privacy\tests\provider_testcase;
-use \core_privacy\local\request\writer;
-use \tool_assignmentupgrade\privacy\provider;
-
-/**
- * Unit tests for tool_assignmentupgrade/classes/privacy/policy
- *
- * @copyright 2018 Zig Tan <zig@moodle.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class tool_assignmentupgrade_privacy_testcase extends provider_testcase {
-
- /**
- * Overriding setUp() function to always reset after tests.
- */
- public function setUp() {
- $this->resetAfterTest(true);
- }
-
- /**
- * Test for provider::test_export_user_preferences().
- */
- public function test_export_user_preferences() {
- // Test setup.
- $user = $this->getDataGenerator()->create_user();
- $this->setUser($user);
-
- // Add a user home page preference for the User.
- set_user_preference('tool_assignmentupgrade_perpage', '100', $user);
-
- // Test the user preference exists.
- $params = [
- 'userid' => $user->id,
- 'name' => 'tool_assignmentupgrade_perpage'
- ];
-
- // Test the user preferences export contains 1 user preference record for the User.
- provider::export_user_preferences($user->id);
- $contextuser = context_user::instance($user->id);
- $writer = writer::with_context($contextuser);
- $this->assertTrue($writer->has_any_data());
-
- $exportedpreferences = $writer->get_user_preferences('tool_assignmentupgrade');
- $this->assertCount(1, (array) $exportedpreferences);
- $this->assertEquals('100', $exportedpreferences->perpage->value);
- }
-
-}
+++ /dev/null
-<?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/>.
-
-/**
- * This file contains the forms to create and edit an instance of this module
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
-
-require_once($CFG->libdir.'/formslib.php');
-
-/**
- * Assignment upgrade batch operations form.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class tool_assignmentupgrade_batchoperations_form extends moodleform {
- /**
- * Define this form - is called from parent constructor.
- */
- public function definition() {
- $mform = $this->_form;
- $instance = $this->_customdata;
-
- $mform->addElement('header', 'general', get_string('batchoperations', 'tool_assignmentupgrade'));
- // Visible elements.
- $mform->addElement('hidden', 'selectedassignments', '', array('class'=>'selectedassignments'));
- $mform->setType('selectedassignments', PARAM_SEQUENCE);
-
- $mform->addElement('submit', 'upgradeselected', get_string('upgradeselected', 'tool_assignmentupgrade'));
- $mform->addElement('submit', 'upgradeall', get_string('upgradeall', 'tool_assignmentupgrade'));
- }
-
-}
-
+++ /dev/null
-<?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/>.
-
-/**
- * This file contains the definition for the grading table which subclassses easy_table
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/gradelib.php');
-require_once($CFG->dirroot.'/mod/assign/locallib.php');
-
-/**
- * Extends table_sql to provide a table of assignment submissions
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class tool_assignmentupgrade_assignments_table extends table_sql implements renderable {
-
- /** @var int $perpage */
- private $perpage = 10;
- /** @var int $rownum (global index of current row in table) */
- private $rownum = -1;
- /** @var renderer_base for getting output */
- private $output = null;
- /** @var boolean anyupgradableassignments - True if there is one or more assignments that can upgraded */
- public $anyupgradableassignments = false;
-
- /**
- * This table loads a list of the old assignment instances and tests them to see
- * if they can be upgraded
- *
- * @param int $perpage How many per page
- * @param int $rowoffset The starting row for pagination
- */
- public function __construct($perpage, $rowoffset=0) {
- global $PAGE;
- parent::__construct('tool_assignmentupgrade_assignments');
- $this->perpage = $perpage;
- $this->output = $PAGE->get_renderer('tool_assignmentupgrade');
-
- $this->define_baseurl(new moodle_url('/admin/tool/assignmentupgrade/listnotupgraded.php'));
-
- $this->anyupgradableassignments = tool_assignmentupgrade_any_upgradable_assignments();
-
- // Do some business - then set the sql.
- if ($rowoffset) {
- $this->rownum = $rowoffset - 1;
- }
-
- $fields = 'a.id as id,
- a.name as name,
- a.assignmenttype as type,
- c.shortname as courseshortname,
- c.id as courseid,
- COUNT(s.id) as submissioncount';
- $from = '{assignment} a JOIN {course} c ON a.course = c.id ' .
- ' LEFT JOIN {assignment_submissions} s ON a.id = s.assignment';
-
- $where = '1 = 1';
- $where .= ' GROUP BY a.id, a.name, a.assignmenttype, c.shortname, c.id ';
-
- $this->set_sql($fields, $from, $where, array());
- $this->set_count_sql('SELECT COUNT(*) FROM {assignment} a JOIN {course} c ON a.course = c.id', array());
-
- $columns = array();
- $headers = array();
-
- $columns[] = 'select';
- $headers[] = get_string('select', 'tool_assignmentupgrade') .
- '<div class="selectall">' .
- '<input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/>' .
- '</div>';
- $columns[] = 'upgradable';
- $headers[] = get_string('upgradable', 'tool_assignmentupgrade');
- $columns[] = 'id';
- $headers[] = get_string('assignmentid', 'tool_assignmentupgrade');
- $columns[] = 'courseshortname';
- $headers[] = get_string('course');
- $columns[] = 'name';
- $headers[] = get_string('name');
- $columns[] = 'type';
- $headers[] = get_string('assignmenttype', 'tool_assignmentupgrade');
- $columns[] = 'submissioncount';
- $headers[] = get_string('submissions', 'tool_assignmentupgrade');
-
- // Set the columns.
- $this->define_columns($columns);
- $this->define_headers($headers);
- $this->no_sorting('upgradable');
- $this->no_sorting('select');
- }
-
- /**
- * Return the number of rows to display on a single page
- *
- * @return int The number of rows per page
- */
- public function get_rows_per_page() {
- return $this->perpage;
- }
-
- /**
- * Format a link to the assignment instance
- *
- * @param stdClass $row
- * @return string
- */
- public function col_name(stdClass $row) {
- $url = new moodle_url('/mod/assignment/view.php', array('a' => $row->id));
- return html_writer::link($url, $row->name);
- }
-
-
- /**
- * Format a link to the upgrade single tool
- *
- * @param stdClass $row (contains cached result from previous upgradable check)
- * @return string
- */
- public function col_upgradable(stdClass $row) {
- if ($row->upgradable) {
- $urlparams = array('id' => $row->id, 'sesskey' => sesskey());
- $url = new moodle_url('/admin/tool/assignmentupgrade/upgradesingleconfirm.php', $urlparams);
- return html_writer::link($url, get_string('supported', 'tool_assignmentupgrade'));
- } else {
- return get_string('notsupported', 'tool_assignmentupgrade');
- }
- }
-
- /**
- * Insert a checkbox for selecting the current row for batch operations
- *
- * @param stdClass $row
- * @return string
- */
- public function col_select(stdClass $row) {
- global $CFG;
- $version = get_config('assignment_' . $row->type, 'version');
- require_once($CFG->dirroot . '/mod/assign/locallib.php');
- if (assign::can_upgrade_assignment($row->type, $version)) {
- $row->upgradable = true;
- return '<input type="checkbox" name="selectedassignment" value="' . $row->id . '"/>';
- }
- $row->upgradable = false;
- return '';
- }
-
- /**
- * Override the table show_hide_link to not show for select column
- *
- * @param string $column the column name, index into various names.
- * @param int $index numerical index of the column.
- * @return string HTML fragment.
- */
- protected function show_hide_link($column, $index) {
- if ($index > 0) {
- return parent::show_hide_link($column, $index);
- }
- return '';
- }
-}
+++ /dev/null
-<?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/>.
-
-/**
- * Script to show all the assignments that have not been upgraded after the main upgrade.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once(__DIR__ . '/../../../config.php');
-require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
-
-require_sesskey();
-
-$assignmentid = required_param('id', PARAM_INT);
-
-// This calls require_login and checks moodle/site:config.
-admin_externalpage_setup('assignmentupgrade',
- '',
- array(),
- tool_assignmentupgrade_url('upgradesingle', array('id' => $assignmentid)));
-
-$PAGE->navbar->add(get_string('upgradesingle', 'tool_assignmentupgrade'));
-$renderer = $PAGE->get_renderer('tool_assignmentupgrade');
-
-$log = '';
-list($summary, $success, $log) = tool_assignmentupgrade_upgrade_assignment($assignmentid);
-
-echo $renderer->header();
-echo $renderer->heading(get_string('conversioncomplete', 'tool_assignmentupgrade'));
-echo $renderer->convert_assignment_result($summary, $success, $log);
-echo $renderer->continue_button(tool_assignmentupgrade_url('listnotupgraded'));
-echo $renderer->footer();
+++ /dev/null
-<?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/>.
-
-/**
- * Script to show all the assignments that have not been upgraded after the main upgrade.
- *
- * @package tool_assignmentupgrade
- * @copyright 2012 NetSpot
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once(__DIR__ . '/../../../config.php');
-require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
-
-require_sesskey();
-
-$assignmentid = required_param('id', PARAM_INT);
-
-// This calls require_login and checks moodle/site:config.
-admin_externalpage_setup('assignmentupgrade',
- '',
- array(),
- tool_assignmentupgrade_url('upgradesingle', array('id' => $assignmentid)));
-
-$PAGE->navbar->add(get_string('upgradesingle', 'tool_assignmentupgrade'));
-$renderer = $PAGE->get_renderer('tool_assignmentupgrade');
-
-$assignmentinfo = tool_assignmentupgrade_get_assignment($assignmentid);
-
-echo $renderer->convert_assignment_are_you_sure($assignmentinfo);
And the following config values are set as admin:
| enableavailability | 1 |
And I am on homepage
- And I navigate to "Manage restrictions" node in "Site administration > Plugins > Availability restrictions"
+ And I navigate to "Plugins > Availability restrictions > Manage restrictions" in site administration
# Having clicked on it, I should also see the list of plugins.
And I should see "Restriction by date"
| Course 1 | C1 | topics |
And I log in as "admin"
And I am on site homepage
- When I navigate to "Manage restrictions" node in "Site administration > Plugins > Availability restrictions"
+ When I navigate to "Plugins > Availability restrictions > Manage restrictions" in site administration
# Check the icon is there (it should be a Hide icon, meaning is currently visible).
Then "Hide" "icon" should exist in the "Restriction by date" "table_row"
| student1 | CHSB |
| student1 | CHC |
When I log in as "admin"
- And I navigate to "Cohorts" node in "Site administration > Users > Accounts"
+ And I navigate to "Users > Accounts > Cohorts" in site administration
Then the following should exist in the "cohorts" table:
| Name | Cohort size |
| System cohort A | 1 |
| wiki | C1 | wiki1 | Test this one | Test this one | Test this one | collaborative | 0 |
And I log in as "admin"
And I am on "Course 1" course homepage
- And I navigate to "Reset" node in "Course administration"
+ And I navigate to "Reset" in current page administration
# Select (multi-select) - Checking "the select box should contain".
And I expand all fieldsets
And the "Unenrol users" select box should contain "No roles"
And the field "two" matches value ""
# Check if field xpath set/match works.
And I am on "Course 1" course homepage
- And I navigate to "Edit settings" node in "Course administration"
+ And I navigate to "Edit settings" in current page administration
And I set the field with xpath "//input[@id='id_idnumber']" to "Course id number"
And the field with xpath "//input[@name='idnumber']" matches value "Course id number"
And the field with xpath "//input[@name='idnumber']" does not match value ""
And I press "Save and display"
- And I navigate to "Edit settings" node in "Course administration"
+ And I navigate to "Edit settings" in current page administration
And the field "Course ID number" matches value "Course id number"
Scenario: with JS disabled all form fields getters and setters works as expected
Background:
Given I am on homepage
And I log in as "admin"
- And I navigate to "Acceptance testing" node in "Site administration > Development"
+ And I navigate to "Development > Acceptance testing" in site administration
@javascript
Scenario: Accessing the list
$string['taskname'] = 'Sync cohort role assignments';
$string['thisuserroles'] = 'Roles assigned relative to this user';
$string['privacy:metadata:tool_cohortroles'] = 'The Cohort roles management plugin stores user cohort role mappings.';
-$string['privacy:metadata:tool_cohortroles:id'] = 'The ID of the cohort role mapping record.';
-$string['privacy:metadata:tool_cohortroles:cohortid'] = 'The ID of the cohort.';
-$string['privacy:metadata:tool_cohortroles:roleid'] = 'The ID of the role.';
-$string['privacy:metadata:tool_cohortroles:userid'] = 'The ID of the user.';
-$string['privacy:metadata:tool_cohortroles:timecreated'] = 'The date/time of when the cohort role mapping was created.';
-$string['privacy:metadata:tool_cohortroles:timemodified'] = 'The date/time of when the cohort role mapping was modified.';
-$string['privacy:metadata:tool_cohortroles:usermodified'] = 'The ID of the user who last modified the cohort role mapping.';
+$string['privacy:metadata:tool_cohortroles:id'] = 'The ID of the cohort role mapping record';
+$string['privacy:metadata:tool_cohortroles:cohortid'] = 'The ID of the cohort';
+$string['privacy:metadata:tool_cohortroles:roleid'] = 'The ID of the role';
+$string['privacy:metadata:tool_cohortroles:userid'] = 'The ID of the user';
+$string['privacy:metadata:tool_cohortroles:timecreated'] = 'The time when the cohort role mapping was created';
+$string['privacy:metadata:tool_cohortroles:timemodified'] = 'The time when the cohort role mapping was modified';
+$string['privacy:metadata:tool_cohortroles:usermodified'] = 'The ID of the user who last modified the cohort role mapping';
$string['checkout'] = 'Open language pack for editing';
$string['checkoutdone'] = 'Language pack loaded';
$string['checkoutinprogress'] = 'Loading language pack';
-$string['confirmcheckin'] = 'You are about to save modifications to your local language pack. This will export the customised strings from the translator into you Moodle data directory and Moodle will start using the modified strings. Press \'Continue\' to proceed with saving.';
+$string['confirmcheckin'] = 'You are about to save modifications to your local language pack. This will export the customised strings from the translator into your site data directory and your site will start using the modified strings. Press \'Continue\' to proceed with saving.';
$string['customlang:edit'] = 'Edit local translation';
$string['customlang:view'] = 'View local translation';
$string['filter'] = 'Filter strings';
var stringkeys = [
{
key: 'deletecategory',
- component: 'tool_dataprivacy',
- param: categoryname
+ component: 'tool_dataprivacy'
},
{
key: 'deletecategorytext',
component: 'tool_dataprivacy',
param: categoryname
+ },
+ {
+ key: 'delete'
}
];
Str.get_strings(stringkeys).then(function(langStrings) {
var title = langStrings[0];
var confirmMessage = langStrings[1];
+ var buttonText = langStrings[2];
return ModalFactory.create({
title: title,
body: confirmMessage,
type: ModalFactory.types.SAVE_CANCEL
}).then(function(modal) {
- modal.setSaveButtonText(title);
+ modal.setSaveButtonText(buttonText);
// Handle save event.
modal.getRoot().on(ModalEvents.save, function() {
var stringkeys = [
{
key: 'deletepurpose',
- component: 'tool_dataprivacy',
- param: purposename
+ component: 'tool_dataprivacy'
},
{
key: 'deletepurposetext',
component: 'tool_dataprivacy',
param: purposename
+ },
+ {
+ key: 'delete'
}
];
Str.get_strings(stringkeys).then(function(langStrings) {
var title = langStrings[0];
var confirmMessage = langStrings[1];
+ var buttonText = langStrings[2];
return ModalFactory.create({
title: title,
body: confirmMessage,
type: ModalFactory.types.SAVE_CANCEL
}).then(function(modal) {
- modal.setSaveButtonText(title);
+ modal.setSaveButtonText(buttonText);
// Handle save event.
modal.getRoot().on(ModalEvents.save, function() {
/** The request is now being processed. */
const DATAREQUEST_STATUS_PROCESSING = 4;
- /** Data request completed. */
+ /** Information/other request completed. */
const DATAREQUEST_STATUS_COMPLETE = 5;
/** Data request cancelled by the user. */
/** Data request rejected by the DPO. */
const DATAREQUEST_STATUS_REJECTED = 7;
+ /** Data request download ready. */
+ const DATAREQUEST_STATUS_DOWNLOAD_READY = 8;
+
+ /** Data request expired. */
+ const DATAREQUEST_STATUS_EXPIRED = 9;
+
+ /** Data delete request completed, account is removed. */
+ const DATAREQUEST_STATUS_DELETED = 10;
+
/**
* Determines whether the user can contact the site's Data Protection Officer via Moodle.
*
require_capability('tool/dataprivacy:managedataregistry', $context);
}
+ /**
+ * Fetches the role shortnames of Data Protection Officer roles.
+ *
+ * @return array An array of the DPO role shortnames
+ */
+ public static function get_dpo_role_names() : array {
+ global $DB;
+
+ $dporoleids = explode(',', str_replace(' ', '', get_config('tool_dataprivacy', 'dporoles')));
+ $dponames = array();
+
+ if (!empty($dporoleids)) {
+ list($insql, $inparams) = $DB->get_in_or_equal($dporoleids);
+ $dponames = $DB->get_fieldset_select('role', 'shortname', "id {$insql}", $inparams);
+ }
+
+ return $dponames;
+ }
+
/**
* Fetches the list of users with the Data Protection Officer role.
*
}
}
+ // If any are due to expire, expire them and re-fetch updated data.
+ if (empty($statuses)
+ || in_array(self::DATAREQUEST_STATUS_DOWNLOAD_READY, $statuses)
+ || in_array(self::DATAREQUEST_STATUS_EXPIRED, $statuses)) {
+ $expiredrequests = data_request::get_expired_requests($userid);
+
+ if (!empty($expiredrequests)) {
+ data_request::expire($expiredrequests);
+ $results = self::get_data_requests($userid, $statuses, $types, $sort, $offset, $limit);
+ }
+ }
+
return $results;
}
self::DATAREQUEST_STATUS_COMPLETE,
self::DATAREQUEST_STATUS_CANCELLED,
self::DATAREQUEST_STATUS_REJECTED,
+ self::DATAREQUEST_STATUS_DOWNLOAD_READY,
+ self::DATAREQUEST_STATUS_EXPIRED,
+ self::DATAREQUEST_STATUS_DELETED,
];
list($insql, $inparams) = $DB->get_in_or_equal($nonpendingstatuses, SQL_PARAMS_NAMED);
$select = 'type = :type AND userid = :userid AND status NOT ' . $insql;
self::DATAREQUEST_STATUS_COMPLETE,
self::DATAREQUEST_STATUS_CANCELLED,
self::DATAREQUEST_STATUS_REJECTED,
+ self::DATAREQUEST_STATUS_DOWNLOAD_READY,
+ self::DATAREQUEST_STATUS_EXPIRED,
+ self::DATAREQUEST_STATUS_DELETED,
];
return !in_array($status, $finalstatuses);
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir . '/coursecatlib.php');
-
/**
* Data registry business logic methods. Mostly internal stuff.
*
/**
* Returns all site categories that are visible to the current user.
*
- * @return \coursecat[]
+ * @return \core_course_category[]
*/
public static function get_site_categories() {
global $DB;
- if (method_exists('\coursecat', 'get_all')) {
- $categories = \coursecat::get_all(['returnhidden' => true]);
+ if (method_exists('\core_course_category', 'get_all')) {
+ $categories = \core_course_category::get_all(['returnhidden' => true]);
} else {
// Fallback (to be removed once this gets integrated into master).
$ids = $DB->get_fieldset_select('course_categories', 'id', '');
- $categories = \coursecat::get_many($ids);
+ $categories = \core_course_category::get_many($ids);
}
foreach ($categories as $key => $category) {
if ($contextcourse = $context->get_course_context(false)) {
// Below course level we look at module or block level roles + course-assigned roles.
- $courseroles = get_roles_with_assignment_on_context($contextcourse);
- $roles = $courseroles + get_roles_with_assignment_on_context($context);
+ $courseroles = get_roles_used_in_context($contextcourse, false);
+ $roles = $courseroles + get_roles_used_in_context($context, false);
} else {
// We list category + system for others (we don't work with user instances so no need to work about them).
$roles = get_roles_used_in_context($context);
api::DATAREQUEST_STATUS_COMPLETE,
api::DATAREQUEST_STATUS_CANCELLED,
api::DATAREQUEST_STATUS_REJECTED,
+ api::DATAREQUEST_STATUS_DOWNLOAD_READY,
+ api::DATAREQUEST_STATUS_EXPIRED,
+ api::DATAREQUEST_STATUS_DELETED,
],
'type' => PARAM_INT
],
],
];
}
+
+ /**
+ * Determines whether a completed data export request has expired.
+ * The response will be valid regardless of the expiry scheduled task having run.
+ *
+ * @param data_request $request the data request object whose expiry will be checked.
+ * @return bool true if the request has expired.
+ */
+ public static function is_expired(data_request $request) {
+ $result = false;
+
+ // Only export requests expire.
+ if ($request->get('type') == api::DATAREQUEST_TYPE_EXPORT) {
+ switch ($request->get('status')) {
+ // Expired requests are obviously expired.
+ case api::DATAREQUEST_STATUS_EXPIRED:
+ $result = true;
+ break;
+ // Complete requests are expired if the expiry time has elapsed.
+ case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
+ $expiryseconds = get_config('tool_dataprivacy', 'privacyrequestexpiry');
+ if ($expiryseconds > 0 && time() >= ($request->get('timemodified') + $expiryseconds)) {
+ $result = true;
+ }
+ break;
+ }
+ }
+
+ return $result;
+ }
+
+
+
+ /**
+ * Fetch completed data requests which are due to expire.
+ *
+ * @param int $userid Optional user ID to filter by.
+ *
+ * @return array Details of completed requests which are due to expire.
+ */
+ public static function get_expired_requests($userid = 0) {
+ global $DB;
+
+ $expiryseconds = get_config('tool_dataprivacy', 'privacyrequestexpiry');
+ $expirytime = strtotime("-{$expiryseconds} second");
+ $table = self::TABLE;
+ $sqlwhere = 'type = :export_type AND status = :completestatus AND timemodified <= :expirytime';
+ $params = array(
+ 'export_type' => api::DATAREQUEST_TYPE_EXPORT,
+ 'completestatus' => api::DATAREQUEST_STATUS_DOWNLOAD_READY,
+ 'expirytime' => $expirytime,
+ );
+ $sort = 'id';
+ $fields = 'id, userid';
+
+ // Filter by user ID if specified.
+ if ($userid > 0) {
+ $sqlwhere .= ' AND (userid = :userid OR requestedby = :requestedby)';
+ $params['userid'] = $userid;
+ $params['requestedby'] = $userid;
+ }
+
+ return $DB->get_records_select_menu($table, $sqlwhere, $params, $sort, $fields, 0, 2000);
+ }
+
+ /**
+ * Expire a given set of data requests.
+ * Update request status and delete the files.
+ *
+ * @param array $expiredrequests [requestid => userid]
+ *
+ * @return void
+ */
+ public static function expire($expiredrequests) {
+ global $DB;
+
+ $ids = array_keys($expiredrequests);
+
+ if (count($ids) > 0) {
+ list($insql, $inparams) = $DB->get_in_or_equal($ids);
+ $initialparams = array(api::DATAREQUEST_STATUS_EXPIRED, time());
+ $params = array_merge($initialparams, $inparams);
+
+ $update = "UPDATE {" . self::TABLE . "}
+ SET status = ?, timemodified = ?
+ WHERE id $insql";
+
+ if ($DB->execute($update, $params)) {
+ $fs = get_file_storage();
+
+ foreach ($expiredrequests as $id => $userid) {
+ $usercontext = \context_user::instance($userid);
+ $fs->delete_area_files($usercontext->id, 'tool_dataprivacy', 'export', $id);
+ }
+ }
+ }
+ }
}
switch ($this->persistent->get('status')) {
case api::DATAREQUEST_STATUS_PENDING:
- $values['statuslabelclass'] = 'label-default';
+ $values['statuslabelclass'] = 'label-info';
// Request can be manually completed for general enquiry requests.
$values['canmarkcomplete'] = $requesttype == api::DATAREQUEST_TYPE_OTHERS;
break;
$values['statuslabelclass'] = 'label-info';
break;
case api::DATAREQUEST_STATUS_COMPLETE:
+ case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
+ case api::DATAREQUEST_STATUS_DELETED:
$values['statuslabelclass'] = 'label-success';
break;
case api::DATAREQUEST_STATUS_CANCELLED:
case api::DATAREQUEST_STATUS_REJECTED:
$values['statuslabelclass'] = 'label-important';
break;
+ case api::DATAREQUEST_STATUS_EXPIRED:
+ $values['statuslabelclass'] = 'label-default';
+ break;
}
return $values;
if (!isset($statuses[$status])) {
throw new moodle_exception('errorinvalidrequeststatus', 'tool_dataprivacy');
}
+
return $statuses[$status];
}
api::DATAREQUEST_STATUS_APPROVED => get_string('statusapproved', 'tool_dataprivacy'),
api::DATAREQUEST_STATUS_PROCESSING => get_string('statusprocessing', 'tool_dataprivacy'),
api::DATAREQUEST_STATUS_COMPLETE => get_string('statuscomplete', 'tool_dataprivacy'),
+ api::DATAREQUEST_STATUS_DOWNLOAD_READY => get_string('statusready', 'tool_dataprivacy'),
+ api::DATAREQUEST_STATUS_EXPIRED => get_string('statusexpired', 'tool_dataprivacy'),
api::DATAREQUEST_STATUS_CANCELLED => get_string('statuscancelled', 'tool_dataprivacy'),
api::DATAREQUEST_STATUS_REJECTED => get_string('statusrejected', 'tool_dataprivacy'),
+ api::DATAREQUEST_STATUS_DELETED => get_string('statusdeleted', 'tool_dataprivacy'),
];
}
$internaldata['compliant'] = false;
}
// Check to see if we are an external plugin.
- $componentshortname = explode('_', $component);
+ // Plugin names can contain _ characters, limit to 2 to just remove initial plugintype.
+ $componentshortname = explode('_', $component, 2);
$shortname = array_pop($componentshortname);
if (isset($contributedplugins[$plugintype][$shortname])) {
$internaldata['external'] = true;
}
+
+ // Check if the interface is deprecated.
+ if (!$manager->is_empty_subsystem($component)) {
+ $classname = $manager->get_provider_classname_for_component($component);
+ $componentclass = new $classname();
+ if ($componentclass instanceof \core_privacy\local\deprecated) {
+ $internaldata['deprecated'] = true;
+ }
+ }
+
return $internaldata;
}, $leaves['plugins']);
$fullyrichtree[$branch]['plugin_type_raw'] = $plugintype;
use templatable;
use tool_dataprivacy\data_registry;
-require_once($CFG->libdir . '/coursecatlib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
require_once($CFG->libdir . '/blocklib.php');
throw new \coding_exception('A course category context should be provided');
}
- $coursecat = \coursecat::get($catcontext->instanceid);
+ $coursecat = \core_course_category::get($catcontext->instanceid);
$courses = $coursecat->get_courses();
$branches = [];
/** @var bool Whether this table is being rendered for managing data requests. */
protected $manage = false;
- /** @var stdClass[] Array of data request persistents. */
+ /** @var \tool_dataprivacy\data_request[] Array of data request persistents. */
protected $datarequests = [];
/**
$actiontext = get_string('denyrequest', 'tool_dataprivacy');
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
break;
- }
-
- if ($status == api::DATAREQUEST_STATUS_COMPLETE) {
- $userid = $data->foruser->id;
- $usercontext = \context_user::instance($userid, IGNORE_MISSING);
- if ($usercontext && api::can_download_data_request_for_user($userid, $data->requestedbyuser->id)) {
- $actions[] = api::get_download_link($usercontext, $requestid);
- }
+ case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
+ $userid = $data->foruser->id;
+ $usercontext = \context_user::instance($userid, IGNORE_MISSING);
+ // If user has permission to view download link, show relevant action item.
+ if ($usercontext && api::can_download_data_request_for_user($userid, $data->requestedbyuser->id)) {
+ $actions[] = api::get_download_link($usercontext, $requestid);
+ }
+ break;
}
$actionsmenu = new action_menu($actions);
$actionsmenu->set_menu_trigger(get_string('actions'));
$actionsmenu->set_owner_selector('request-actions-' . $requestid);
$actionsmenu->set_alignment(\action_menu::TL, \action_menu::BL);
+ $actionsmenu->set_constraint('[data-region=data-requests-table] > .no-overflow');
return $OUTPUT->render($actionsmenu);
}
public function query_db($pagesize, $useinitialsbar = true) {
global $PAGE;
- // Count data requests from the given conditions.
- $total = api::get_data_requests_count($this->userid, $this->statuses, $this->types);
- $this->pagesize($pagesize, $total);
+ // Set dummy page total until we fetch full result set.
+ $this->pagesize($pagesize, $pagesize + 1);
$sort = $this->get_sql_sort();
// Get data requests from the given conditions.
$datarequests = api::get_data_requests($this->userid, $this->statuses, $this->types, $sort,
$this->get_page_start(), $this->get_page_size());
+
+ // Count data requests from the given conditions.
+ $total = api::get_data_requests_count($this->userid, $this->statuses, $this->types);
+ $this->pagesize($pagesize, $total);
+
$this->rawdata = [];
$context = \context_system::instance();
$renderer = $PAGE->get_renderer('tool_dataprivacy');
+
foreach ($datarequests as $persistent) {
+ $this->datarequests[$persistent->get('id')] = $persistent;
$exporter = new data_request_exporter($persistent, ['context' => $context]);
$this->rawdata[] = $exporter->export($renderer);
}
$item->statuslabelclass = 'label-success';
$item->statuslabel = get_string('statuscomplete', 'tool_dataprivacy');
$cancancel = false;
- // Show download links only for export-type data requests.
- $candownload = $type == api::DATAREQUEST_TYPE_EXPORT;
+ break;
+ case api::DATAREQUEST_STATUS_DOWNLOAD_READY:
+ $item->statuslabelclass = 'label-success';
+ $item->statuslabel = get_string('statusready', 'tool_dataprivacy');
+ $cancancel = false;
+ $candownload = true;
+
if ($usercontext) {
$candownload = api::can_download_data_request_for_user(
$request->get('userid'), $request->get('requestedby'));
}
break;
+ case api::DATAREQUEST_STATUS_DELETED:
+ $item->statuslabelclass = 'label-success';
+ $item->statuslabel = get_string('statusdeleted', 'tool_dataprivacy');
+ $cancancel = false;
+ break;
+ case api::DATAREQUEST_STATUS_EXPIRED:
+ $item->statuslabelclass = 'label-default';
+ $item->statuslabel = get_string('statusexpired', 'tool_dataprivacy');
+ $item->statuslabeltitle = get_string('downloadexpireduser', 'tool_dataprivacy');
+ $cancancel = false;
+ break;
case api::DATAREQUEST_STATUS_CANCELLED:
case api::DATAREQUEST_STATUS_REJECTED:
$cancancel = false;
--- /dev/null
+<?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/>.
+
+/**
+ * Scheduled task to delete files and update statuses of expired data requests.
+ *
+ * @package tool_dataprivacy
+ * @copyright 2018 Michael Hawkins
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace tool_dataprivacy\task;
+
+use coding_exception;
+use core\task\scheduled_task;
+use tool_dataprivacy\api;
+
+defined('MOODLE_INTERNAL') || die();
+
+require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
+
+/**
+ * Scheduled task to delete files and update request statuses once they expire.
+ *
+ * @package tool_dataprivacy
+ * @copyright 2018 Michael Hawkins
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class delete_expired_requests extends scheduled_task {
+
+ /**
+ * Returns the task name.
+ *
+ * @return string
+ */
+ public function get_name() {
+ return get_string('deleteexpireddatarequeststask', 'tool_dataprivacy');
+ }
+
+ /**
+ * Run the task to delete expired data request files and update request statuses.
+ *
+ */
+ public function execute() {
+ $expiredrequests = \tool_dataprivacy\data_request::get_expired_requests();
+ $deletecount = count($expiredrequests);
+
+ if ($deletecount > 0) {
+ \tool_dataprivacy\data_request::expire($expiredrequests);
+
+ mtrace($deletecount . ' expired completed data requests have been deleted');
+ }
+ }
+}
// Update the status of this request as pre-processing.
mtrace('Processing request...');
api::update_request_status($requestid, api::DATAREQUEST_STATUS_PROCESSING);
+ $completestatus = api::DATAREQUEST_STATUS_COMPLETE;
if ($request->type == api::DATAREQUEST_TYPE_EXPORT) {
// Get the collection of approved_contextlist objects needed for core_privacy data export.
$filerecord->author = fullname($foruser);
// Save somewhere.
$thing = $fs->create_file_from_pathname($filerecord, $exportedcontent);
-
+ $completestatus = api::DATAREQUEST_STATUS_DOWNLOAD_READY;
} else if ($request->type == api::DATAREQUEST_TYPE_DELETE) {
// Get the collection of approved_contextlist objects needed for core_privacy data deletion.
$approvedclcollection = api::get_approved_contextlist_collection_for_request($requestpersistent);
$manager->set_observer(new \tool_dataprivacy\manager_observer());
$manager->delete_data_for_user($approvedclcollection);
+ $completestatus = api::DATAREQUEST_STATUS_DELETED;
}
// When the preparation of the metadata finishes, update the request status to awaiting approval.
- api::update_request_status($requestid, api::DATAREQUEST_STATUS_COMPLETE);
+ api::update_request_status($requestid, $completestatus);
mtrace('The processing of the user data request has been completed...');
// Create message to notify the user regarding the processing results.
echo $OUTPUT->header();
-$table = new \tool_dataprivacy\output\expired_contexts_table($filter);
-$table->baseurl = $url;
-$table->baseurl->param('filter', $filter);
-
-$datadeletionpage = new \tool_dataprivacy\output\data_deletion_page($filter, $table);
-
-$output = $PAGE->get_renderer('tool_dataprivacy');
-echo $output->render($datadeletionpage);
+if (\tool_dataprivacy\api::is_site_dpo($USER->id)) {
+ $table = new \tool_dataprivacy\output\expired_contexts_table($filter);
+ $table->baseurl = $url;
+ $table->baseurl->param('filter', $filter);
+
+ $datadeletionpage = new \tool_dataprivacy\output\data_deletion_page($filter, $table);
+
+ $output = $PAGE->get_renderer('tool_dataprivacy');
+ echo $output->render($datadeletionpage);
+} else {
+ $dponamestring = implode (',', tool_dataprivacy\api::get_dpo_role_names());
+ $message = get_string('privacyofficeronly', 'tool_dataprivacy', $dponamestring);
+ echo $OUTPUT->notification($message, 'error');
+}
echo $OUTPUT->footer();
$output = $PAGE->get_renderer('tool_dataprivacy');
echo $output->header();
-$dataregistry = new tool_dataprivacy\output\data_registry_page($contextlevel, $contextid);
-
-echo $output->render($dataregistry);
+if (\tool_dataprivacy\api::is_site_dpo($USER->id)) {
+ $dataregistry = new tool_dataprivacy\output\data_registry_page($contextlevel, $contextid);
+ echo $output->render($dataregistry);
+} else {
+ $dponamestring = implode (', ', tool_dataprivacy\api::get_dpo_role_names());
+ $message = get_string('privacyofficeronly', 'tool_dataprivacy', $dponamestring);
+ echo $OUTPUT->notification($message, 'error');
+}
echo $OUTPUT->footer();
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
-$filtersapplied = optional_param_array('request-filters', [-1], PARAM_NOTAGS);
-$filterscleared = optional_param('filters-cleared', 0, PARAM_INT);
-if ($filtersapplied === [-1]) {
- // If there are no filters submitted, check if there is a saved filters from the user preferences.
- $filterprefs = get_user_preferences(\tool_dataprivacy\local\helper::PREF_REQUEST_FILTERS, null);
- if ($filterprefs && empty($filterscleared)) {
- $filtersapplied = json_decode($filterprefs);
- } else {
- $filtersapplied = [];
+if (\tool_dataprivacy\api::is_site_dpo($USER->id)) {
+ $filtersapplied = optional_param_array('request-filters', [-1], PARAM_NOTAGS);
+ $filterscleared = optional_param('filters-cleared', 0, PARAM_INT);
+ if ($filtersapplied === [-1]) {
+ // If there are no filters submitted, check if there is a saved filters from the user preferences.
+ $filterprefs = get_user_preferences(\tool_dataprivacy\local\helper::PREF_REQUEST_FILTERS, null);
+ if ($filterprefs && empty($filterscleared)) {
+ $filtersapplied = json_decode($filterprefs);
+ } else {
+ $filtersapplied = [];
+ }
}
-}
-// Save the current applied filters to the user preferences.
-set_user_preference(\tool_dataprivacy\local\helper::PREF_REQUEST_FILTERS, json_encode($filtersapplied));
+ // Save the current applied filters to the user preferences.
+ set_user_preference(\tool_dataprivacy\local\helper::PREF_REQUEST_FILTERS, json_encode($filtersapplied));
-$types = [];
-$statuses = [];
-foreach ($filtersapplied as $filter) {
- list($category, $value) = explode(':', $filter);
- switch($category) {
- case \tool_dataprivacy\local\helper::FILTER_TYPE:
- $types[] = $value;
- break;
- case \tool_dataprivacy\local\helper::FILTER_STATUS:
- $statuses[] = $value;
- break;
+ $types = [];
+ $statuses = [];
+ foreach ($filtersapplied as $filter) {
+ list($category, $value) = explode(':', $filter);
+ switch($category) {
+ case \tool_dataprivacy\local\helper::FILTER_TYPE:
+ $types[] = $value;
+ break;
+ case \tool_dataprivacy\local\helper::FILTER_STATUS:
+ $statuses[] = $value;
+ break;
+ }
}
-}
-$table = new \tool_dataprivacy\output\data_requests_table(0, $statuses, $types, true);
-$table->baseurl = $url;
+ $table = new \tool_dataprivacy\output\data_requests_table(0, $statuses, $types, true);
+ $table->baseurl = $url;
-$requestlist = new tool_dataprivacy\output\data_requests_page($table, $filtersapplied);
-$requestlistoutput = $PAGE->get_renderer('tool_dataprivacy');
-echo $requestlistoutput->render($requestlist);
+ $requestlist = new tool_dataprivacy\output\data_requests_page($table, $filtersapplied);
+ $requestlistoutput = $PAGE->get_renderer('tool_dataprivacy');
+ echo $requestlistoutput->render($requestlist);
+} else {
+ $dponamestring = implode (', ', tool_dataprivacy\api::get_dpo_role_names());
+ $message = get_string('privacyofficeronly', 'tool_dataprivacy', $dponamestring);
+ echo $OUTPUT->notification($message, 'error');
+}
echo $OUTPUT->footer();
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="admin/tool/dataprivacy/db" VERSION="20180313" COMMENT="XMLDB file for Moodle tool/dataprivacy"
+<XMLDB PATH="admin/tool/dataprivacy/db" VERSION="20180821" COMMENT="XMLDB file for Moodle tool/dataprivacy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="commentsformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="userid" TYPE="int" LENGT