Merge branch 'install_master' of https://git.in.moodle.com/amosbot/moodle-install
authorAndrew Nicols <andrew@nicols.co.uk>
Fri, 3 Aug 2018 03:30:09 +0000 (11:30 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Fri, 3 Aug 2018 03:30:09 +0000 (11:30 +0800)
129 files changed:
admin/tool/assignmentupgrade/batchupgrade.php [deleted file]
admin/tool/assignmentupgrade/classes/privacy/provider.php [deleted file]
admin/tool/assignmentupgrade/index.php [deleted file]
admin/tool/assignmentupgrade/lang/en/tool_assignmentupgrade.php [deleted file]
admin/tool/assignmentupgrade/listnotupgraded.php [deleted file]
admin/tool/assignmentupgrade/locallib.php [deleted file]
admin/tool/assignmentupgrade/module.js [deleted file]
admin/tool/assignmentupgrade/paginationform.php [deleted file]
admin/tool/assignmentupgrade/renderer.php [deleted file]
admin/tool/assignmentupgrade/settings.php [deleted file]
admin/tool/assignmentupgrade/styles.css [deleted file]
admin/tool/assignmentupgrade/tests/privacy_test.php [deleted file]
admin/tool/assignmentupgrade/upgradableassignmentsbatchform.php [deleted file]
admin/tool/assignmentupgrade/upgradableassignmentstable.php [deleted file]
admin/tool/assignmentupgrade/upgradesingle.php [deleted file]
admin/tool/assignmentupgrade/upgradesingleconfirm.php [deleted file]
admin/tool/policy/tests/behat/consent.feature
admin/tool/upgrade.txt
auth/shibboleth/auth.php
auth/shibboleth/lang/en/auth_shibboleth.php
auth/shibboleth/lib.php [new file with mode: 0644]
auth/shibboleth/settings.php
auth/tests/behat/displayloginfailures.feature
auth/tests/behat/validateagedigitalconsentmap.feature
backup/moodle2/tests/behat/import_multiple_times.feature
blocks/recent_activity/block_recent_activity.php
blocks/recent_activity/classes/task/cleanup.php [new file with mode: 0644]
blocks/recent_activity/db/tasks.php [moved from mod/quiz/db/renamedclasses.php with 60% similarity]
blocks/recent_activity/lang/en/block_recent_activity.php
blocks/recent_activity/version.php
blocks/rss_client/block_rss_client.php
blocks/rss_client/classes/task/refreshfeeds.php [new file with mode: 0644]
blocks/rss_client/db/tasks.php [moved from admin/tool/assignmentupgrade/version.php with 59% similarity]
blocks/rss_client/lang/en/block_rss_client.php
blocks/rss_client/tests/cron_test.php
blocks/rss_client/version.php
calendar/classes/local/event/container.php
calendar/classes/local/event/strategies/raw_event_retrieval_strategy.php
calendar/lib.php
calendar/tests/lib_test.php
calendar/tests/raw_event_retrieval_strategy_test.php
calendar/upgrade.txt
competency/tests/privacy_test.php
enrol/paypal/ipn.php
error/index.php
grade/edit/letter/index.php
lib/adminlib.php
lib/classes/event/base.php
lib/classes/plugin_manager.php
lib/classes/session/manager.php
lib/classes/task/events_cron_task.php [deleted file]
lib/coursecatlib.php
lib/db/renamedclasses.php
lib/db/tasks.php
lib/db/upgrade.php
lib/deprecatedlib.php
lib/eventslib.php [deleted file]
lib/form/submitlink.php [deleted file]
lib/formslib.php
lib/gradelib.php
lib/medialib.php [deleted file]
lib/moodlelib.php
lib/outputrenderers.php
lib/phpunit/classes/util.php
lib/setup.php
lib/tests/admintree_test.php
lib/tests/coursecatlib_test.php
lib/tests/event_test.php
lib/tests/eventslib_test.php [deleted file]
lib/tests/gradelib_test.php
lib/tests/medialib_test.php
lib/tests/moodlelib_test.php
lib/tests/plugin_manager_test.php
lib/upgrade.txt
lib/upgradelib.php
media/classes/player.php
media/upgrade.txt
message/lib.php
mod/assign/lib.php
mod/assign/locallib.php
mod/assign/submission/file/locallib.php
mod/assign/tests/lib_test.php
mod/assign/tests/locallib_test.php
mod/assign/upgrade.txt
mod/assignment/lang/en/assignment.php
mod/assignment/view.php
mod/feedback/classes/responses_table.php
mod/feedback/lib.php
mod/forum/lib.php
mod/label/lib.php
mod/label/tests/behat/label_idnumber.feature [new file with mode: 0644]
mod/label/version.php
mod/lesson/essay.php
mod/lesson/locallib.php
mod/quiz/lib.php
mod/quiz/locallib.php
mod/quiz/upgrade.txt
mod/scorm/db/renamedclasses.php [deleted file]
mod/scorm/report/basic/db/renamedclasses.php [deleted file]
mod/scorm/report/basic/upgrade.txt [new file with mode: 0644]
mod/scorm/upgrade.txt
mod/scorm/view.php
mod/upgrade.txt
mod/wiki/locallib.php
mod/wiki/pagelib.php
question/templates/tag_condition.mustache
repository/dropbox/classes/dropbox.php
repository/dropbox/tests/api_test.php
search/classes/base.php
search/classes/document.php
tag/tests/events_test.php
tag/tests/taglib_test.php
tag/upgrade.txt
theme/bootstrapbase/less/moodle/core.less
theme/bootstrapbase/style/moodle.css
user/classes/search/user.php
user/editlib.php
user/index.php
user/profile/lib.php
user/selector/lib.php
user/tests/behat/addnewuser.feature [new file with mode: 0644]
user/tests/behat/custom_profile_fields.feature
user/tests/behat/filter_participants_showall.feature
user/tests/behat/view_participants.feature
user/tests/fixtures/testable_user_selector.php [new file with mode: 0644]
user/tests/search_test.php
user/tests/userselector_test.php [new file with mode: 0644]
user/upgrade.txt [new file with mode: 0644]
version.php

diff --git a/admin/tool/assignmentupgrade/batchupgrade.php b/admin/tool/assignmentupgrade/batchupgrade.php
deleted file mode 100644 (file)
index 7744063..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?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();
diff --git a/admin/tool/assignmentupgrade/classes/privacy/provider.php b/admin/tool/assignmentupgrade/classes/privacy/provider.php
deleted file mode 100644 (file)
index 452cc15..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<?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')
-            );
-        }
-    }
-
-}
diff --git a/admin/tool/assignmentupgrade/index.php b/admin/tool/assignmentupgrade/index.php
deleted file mode 100644 (file)
index 7720ac7..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?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);
diff --git a/admin/tool/assignmentupgrade/lang/en/tool_assignmentupgrade.php b/admin/tool/assignmentupgrade/lang/en/tool_assignmentupgrade.php
deleted file mode 100644 (file)
index c7e7d26..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?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.';
diff --git a/admin/tool/assignmentupgrade/listnotupgraded.php b/admin/tool/assignmentupgrade/listnotupgraded.php
deleted file mode 100644 (file)
index 0836076..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?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);
-}
-
diff --git a/admin/tool/assignmentupgrade/locallib.php b/admin/tool/assignmentupgrade/locallib.php
deleted file mode 100644 (file)
index 27db509..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-<?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));
-}
-
diff --git a/admin/tool/assignmentupgrade/module.js b/admin/tool/assignmentupgrade/module.js
deleted file mode 100644 (file)
index ab7f670..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-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();
-        });
-
-    }
-}
diff --git a/admin/tool/assignmentupgrade/paginationform.php b/admin/tool/assignmentupgrade/paginationform.php
deleted file mode 100644 (file)
index e4c9028..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?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'));
-    }
-}
-
diff --git a/admin/tool/assignmentupgrade/renderer.php b/admin/tool/assignmentupgrade/renderer.php
deleted file mode 100644 (file)
index 2811232..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-<?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'));
-    }
-}
diff --git a/admin/tool/assignmentupgrade/settings.php b/admin/tool/assignmentupgrade/settings.php
deleted file mode 100644 (file)
index 1a91922..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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/>.
-
-/**
- * Adds this plugin to the admin menu.
- *
- * @package    tool_assignmentupgrade
- * @copyright  2012 NetSpot
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die;
-
-if ($hassiteconfig) {
-    // Needs this condition or there is error on login page.
-    $ADMIN->add('root', new admin_externalpage('assignmentupgrade',
-            get_string('pluginname', 'tool_assignmentupgrade'),
-            new moodle_url('/admin/tool/assignmentupgrade/index.php')));
-}
diff --git a/admin/tool/assignmentupgrade/styles.css b/admin/tool/assignmentupgrade/styles.css
deleted file mode 100644 (file)
index bdb9fa5..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#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;
-}
diff --git a/admin/tool/assignmentupgrade/tests/privacy_test.php b/admin/tool/assignmentupgrade/tests/privacy_test.php
deleted file mode 100644 (file)
index d22770c..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-<?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);
-    }
-
-}
diff --git a/admin/tool/assignmentupgrade/upgradableassignmentsbatchform.php b/admin/tool/assignmentupgrade/upgradableassignmentsbatchform.php
deleted file mode 100644 (file)
index 291329d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?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'));
-    }
-
-}
-
diff --git a/admin/tool/assignmentupgrade/upgradableassignmentstable.php b/admin/tool/assignmentupgrade/upgradableassignmentstable.php
deleted file mode 100644 (file)
index a7851b9..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-<?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 '';
-    }
-}
diff --git a/admin/tool/assignmentupgrade/upgradesingle.php b/admin/tool/assignmentupgrade/upgradesingle.php
deleted file mode 100644 (file)
index 8a1f78d..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?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();
diff --git a/admin/tool/assignmentupgrade/upgradesingleconfirm.php b/admin/tool/assignmentupgrade/upgradesingleconfirm.php
deleted file mode 100644 (file)
index 3c41fd9..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?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);
index d345b23..2b9b026 100644 (file)
@@ -364,7 +364,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
     And I log out
     # Create new policy document.
     And I log in as "admin"
-    And I navigate to "Manage policies" node in "Site administration > Privacy and policies"
+    And I navigate to "Manage policies" node in "Site administration > Users > Privacy and policies"
     And I should see "Policies and agreements"
     And I should see "New policy"
     And I follow "New policy"
@@ -419,7 +419,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
     And I log out
     # Create new version of the policy document.
     And I log in as "admin"
-    And I navigate to "Manage policies" node in "Site administration > Privacy and policies"
+    And I navigate to "Manage policies" node in "Site administration > Users > Privacy and policies"
     When I follow "Actions"
     Then I should see "View"
     And I should see "Edit"
index 3af7d3a..ec7e17e 100644 (file)
@@ -1,6 +1,9 @@
 This files describes API changes in /admin/tool/* - plugins,
 information provided here is intended especially for developers.
 
+=== 3.6 ===
+
+The assignment upgrade tool has been removed. If you need to upgrade assignments from before Moodle 2.3, you will have to upgrade to any Moodle version from 2.3 to 3.5, upgrade the assignments and then upgrade to a later version.
 
 === 2.2 ===
 
index fe6244c..39ca032 100644 (file)
@@ -277,6 +277,32 @@ class auth_plugin_shibboleth extends auth_plugin_base {
             return;
         }
     }
+
+    /**
+     * Return a list of identity providers to display on the login page.
+     *
+     * @param string $wantsurl The requested URL.
+     * @return array List of arrays with keys url, iconurl and name.
+     */
+    public function loginpage_idp_list($wantsurl) {
+        $config = get_config('auth_shibboleth');
+        $result = [];
+
+        // Before displaying the button check that Shibboleth is set-up correctly.
+        if (empty($config->user_attribute)) {
+            return $result;
+        }
+
+        $url = new moodle_url('/auth/shibboleth/index.php');
+        $iconurl = moodle_url::make_pluginfile_url(context_system::instance()->id,
+                                                   'auth_shibboleth',
+                                                   'logo',
+                                                   null,
+                                                   '/',
+                                                   $config->auth_logo);
+        $result[] = ['url' => $url, 'iconurl' => $iconurl, 'name' => $config->login_name];
+        return $result;
+    }
 }
 
 
index 659e4d1..8ef9ec1 100644 (file)
@@ -25,6 +25,8 @@
 
 $string['auth_shib_auth_method'] = 'Authentication method name';
 $string['auth_shib_auth_method_description'] = 'Provide a name for the Shibboleth authentication method that is familiar to your users. This could be the name of your Shibboleth federation, e.g. <tt>SWITCHaai Login</tt> or <tt>InCommon Login</tt> or similar.';
+$string['auth_shib_auth_logo'] = 'Authentication method logo';
+$string['auth_shib_auth_logo_description'] = 'Provide a logo for the Shibboleth authentication method that is familiar to your users. This could be the logo of your Shibboleth federation, e.g. <tt>SWITCHaai Login</tt> or <tt>InCommon Login</tt> or similar.';
 $string['auth_shib_contact_administrator'] = 'In case you are not associated with the given organizations and you need access to a course on this server, please contact the <a href="mailto:{$a}">Moodle Administrator</a>.';
 $string['auth_shibbolethdescription'] = 'Using this method users are created and authenticated using <a href="http://shibboleth.internet2.edu/">Shibboleth</a>.<br />Be sure to read the <a href="../auth/shibboleth/README.txt">README</a> for Shibboleth on how to set up your Moodle with Shibboleth';
 $string['auth_shibboleth_errormsg'] = 'Please select the organization you are member of!';
diff --git a/auth/shibboleth/lib.php b/auth/shibboleth/lib.php
new file mode 100644 (file)
index 0000000..f8ac757
--- /dev/null
@@ -0,0 +1,64 @@
+<?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 hooks for the Shibboleth authentication module.
+ *
+ * @package auth_shibboleth
+ * @copyright 2018 Fabrice Ménard
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+/**
+ * Serves the logo file settings.
+ *
+ * @param stdClass $course course object
+ * @param stdClass $cm course module object
+ * @param stdClass $context context object
+ * @param string $filearea file area
+ * @param array $args extra arguments
+ * @param bool $forcedownload whether or not force download
+ * @param array $options additional options affecting the file serving
+ * @return bool false if file not found, does not return if found - justsend the file
+ */
+function auth_shibboleth_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
+    if ($context->contextlevel != CONTEXT_SYSTEM) {
+        return false;
+    }
+
+    if ($filearea !== 'logo' ) {
+        return false;
+    }
+
+    $itemid = 0;
+
+    $filename = array_pop($args);
+    if (!$args) {
+        $filepath = '/';
+    } else {
+        $filepath = '/'.implode('/', $args).'/';
+    }
+
+    $fs = get_file_storage();
+    $file = $fs->get_file($context->id, 'auth_shibboleth', $filearea, $itemid, $filepath, $filename);
+    if (!$file) {
+        return false;
+    }
+
+    send_stored_file($file, null, 0, $forcedownload, $options);
+}
index c901378..e4b4c3a 100644 (file)
@@ -63,6 +63,11 @@ if ($ADMIN->fulltree) {
             get_string('auth_shib_auth_method', 'auth_shibboleth'),
             get_string('auth_shib_auth_method_description', 'auth_shibboleth'), 'Shibboleth Login', PARAM_RAW_TRIMMED));
 
+    // Authentication method logo.
+    $settings->add(new admin_setting_configstoredfile('auth_shibboleth/auth_logo',
+                get_string('auth_shib_auth_logo', 'auth_shibboleth'),
+                get_string('auth_shib_auth_logo_description', 'auth_shibboleth'), 'logo', 0, ['accepted_types' => ['image']]));
+
     // Login directions.
     $settings->add(new admin_setting_configtextarea('auth_shibboleth/auth_instructions',
             get_string('auth_shib_instructions_key', 'auth_shibboleth'),
index 50b9ec6..4b6e2a9 100644 (file)
@@ -25,11 +25,11 @@ Feature: Test the 'showlogfailures' feature works.
     And I set the field "Password" to "teacher1"
     And I press "Log in"
     # Confirm the notices are displayed.
-    Then I should see "1 failed logins since your last login" in the "nav.navbar" "css_element"
+    Then I should see "1 failed logins since your last login" in the ".navbar" "css_element"
     And I should see "1 failed logins since your last login" in the "page-footer" "region"
     # Confirm the notices disappear when navigating to another page.
     And I am on homepage
-    And I should not see "1 failed logins since your last login" in the "nav.navbar" "css_element"
+    And I should not see "1 failed logins since your last login" in the ".navbar" "css_element"
     And I should not see "1 failed logins since your last login" in the "page-footer" "region"
 
   # Given the user has at least one failed login attempt, when they login, then they should see both header and footer notices.
@@ -46,10 +46,10 @@ Feature: Test the 'showlogfailures' feature works.
     And I set the field "Password" to "admin"
     And I press "Log in"
     # Confirm the notices are displayed.
-    Then I should see "1 failed logins since your last login" in the "nav.navbar" "css_element"
+    Then I should see "1 failed logins since your last login" in the ".navbar" "css_element"
     And I should see "1 failed logins since your last login (Logs)" in the "page-footer" "region"
     # Confirm that the link works and that the notices disappear when navigating to another page.
     And I click on "Logs" "link" in the "page-footer" "region"
     And I should see "User login failed" in the "table.reportlog" "css_element"
-    And I should not see "1 failed logins since your last login" in the "nav.navbar" "css_element"
+    And I should not see "1 failed logins since your last login" in the ".navbar" "css_element"
     And I should not see "1 failed logins since your last login (Logs)" in the "page-footer" "region"
index 9fe1753..7381991 100644 (file)
@@ -6,7 +6,7 @@ Feature: Test validation of 'Age of digital consent' setting.
 
   Background:
     Given I log in as "admin"
-    And I navigate to "Privacy settings" node in "Site administration > Privacy and policies"
+    And I navigate to "Privacy settings" node in "Site administration > Users > Privacy and policies"
 
   Scenario: Admin provides valid value for 'Age of digital consent'.
     Given I set the field "s__agedigitalconsentmap" to multiline:
index ccf6dd1..98d495f 100644 (file)
@@ -27,10 +27,10 @@ Feature: Import course's content's twice
     And I log in as "teacher1"
 
   Scenario: Import course's contents to another course
-    Given I am on "Course 2" course homepage with editing mode on
+    Given I am on "Course 2" course homepage
     And I should not see "Online users"
     And I should not see "Test quiz"
-    And  I import "Course 1" course into "Course 2" course using this options:
+    And I import "Course 1" course into "Course 2" course using this options:
     And I am on "Course 2" course homepage
     And I should see "Online users"
     And I should see "Test quiz"
index 6a46c36..0424b73 100644 (file)
@@ -228,16 +228,6 @@ class block_recent_activity extends block_base {
         return array('all' => true, 'my' => false, 'tag' => false);
     }
 
-    /**
-     * Remove old entries from table block_recent_activity
-     */
-    public function cron() {
-        global $DB;
-        // Those entries will never be displayed as RECENT anyway.
-        $DB->delete_records_select('block_recent_activity', 'timecreated < ?',
-                array(time() - COURSE_MAX_RECENT_PERIOD));
-    }
-
     /**
      * Migrates entries from table {log} into {block_recent_activity}
      *
diff --git a/blocks/recent_activity/classes/task/cleanup.php b/blocks/recent_activity/classes/task/cleanup.php
new file mode 100644 (file)
index 0000000..c3f34c7
--- /dev/null
@@ -0,0 +1,58 @@
+<?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/>.
+
+/**
+ * Task for updating RSS feeds for rss client block
+ *
+ * @package   block_recent_activity
+ * @author    Farhan Karmali <farhan6318@gmail.com>
+ * @copyright Farhan Karmali 2018
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace block_recent_activity\task;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Task for updating RSS feeds for rss client block
+ *
+ * @package   block_recent_activity
+ * @author    Farhan Karmali <farhan6318@gmail.com>
+ * @copyright Farhan Karmali 2018
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class cleanup extends \core\task\scheduled_task {
+
+    /**
+     * Name for this task.
+     *
+     * @return string
+     */
+    public function get_name() {
+        return get_string('cleanuptask', 'block_recent_activity');
+    }
+
+    /**
+     * Remove old entries from table block_recent_activity
+     */
+    public function execute() {
+        global $DB;
+        // Those entries will never be displayed as RECENT anyway.
+        $DB->delete_records_select('block_recent_activity', 'timecreated < ?',
+            array(time() - COURSE_MAX_RECENT_PERIOD));
+    }
+}
similarity index 60%
rename from mod/quiz/db/renamedclasses.php
rename to blocks/recent_activity/db/tasks.php
index 3cc07a1..0da9677 100644 (file)
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
- * Lists renamed classes so that the autoloader can make the old names still work.
- *
- * @package   mod_quiz
- * @copyright 2014 Tim Hunt
+ * Task definition for block_recent_activity.
+ * @author    Farhan Karmali <farhan6318@gmail.com>
+ * @copyright Farhan Karmali 2018
+ * @package   block_recent_activity
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 defined('MOODLE_INTERNAL') || die();
 
-// Array 'old_class_name' => 'new\class_name'.
-$renamedclasses = array(
-
-    // Changed in Moodle 2.8.
-    'quiz_question_bank_view'                 => 'mod_quiz\question\bank\custom_view',
-    'question_bank_add_to_quiz_action_column' => 'mod_quiz\question\bank\add_action_column',
-    'question_bank_question_name_text_column' => 'mod_quiz\question\bank\question_name_text_column',
+$tasks = array(
+    array(
+        'classname' => '\block_recent_activity\task\cleanup',
+        'blocking' => 0,
+        'minute' => 'R',
+        'hour' => 'R',
+        'day' => '*',
+        'month' => '*',
+        'dayofweek' => '*',
+        'disabled' => 0
+    )
 );
+
index defbc88..c77dca2 100644 (file)
@@ -23,6 +23,7 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['cleanuptask'] = 'Cleanup task for recent activity block';
 $string['pluginname'] = 'Recent activity';
 $string['privacy:metadata'] = 'The recent activity block contains a cache of data stored elsewhere in Moodle.';
 $string['privacy:metadata:block_recent_activity'] = 'Temporary log of recent teacher activity. Removed after two days';
index 1943157..48711ce 100644 (file)
@@ -24,7 +24,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2018051400;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2018052900;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2018050800;        // Requires this Moodle version
 $plugin->component = 'block_recent_activity'; // Full name of the plugin (used for diagnostics)
-$plugin->cron      = 24*3600;           // Cron interval 1 day.
\ No newline at end of file
index bc6d7c5..2a2fd78 100644 (file)
         }
     }
 
-    /**
-     * cron - goes through all the feeds. If the feed has a skipuntil value
-     * that is less than the current time cron will attempt to retrieve it
-     * with the cache duration set to 0 in order to force the retrieval of
-     * the item and refresh the cache.
-     *
-     * If a feed fails then the skipuntil time of that feed is set to be
-     * later than the next expected cron time. The amount of time will
-     * increase each time the fetch fails until the maximum is reached.
-     *
-     * If a feed that has been failing is successfully retrieved it will
-     * go back to being handled as though it had never failed.
-     *
-     * CRON should therefor process requests for permanently broken RSS
-     * feeds infrequently, and temporarily unavailable feeds will be tried
-     * less often until they become available again.
-     *
-     * @return boolean Always returns true
-     */
-    function cron() {
-        global $CFG, $DB;
-        require_once($CFG->libdir.'/simplepie/moodle_simplepie.php');
-
-        // Get the legacy cron time, strangely the cron property of block_base
-        // does not seem to get set. This means we must retrive it here.
-        $this->cron = $DB->get_field('block', 'cron', array('name' => 'rss_client'));
-
-        // We are going to measure execution times
-        $starttime =  microtime();
-        $starttimesec = time();
-
-        // Fetch all site feeds.
-        $rs = $DB->get_recordset('block_rss_client');
-        $counter = 0;
-        mtrace('');
-        foreach ($rs as $rec) {
-            mtrace('    ' . $rec->url . ' ', '');
-
-            // Skip feed if it failed recently.
-            if ($starttimesec < $rec->skipuntil) {
-                mtrace('skipping until ' . userdate($rec->skipuntil));
-                continue;
-            }
-
-            // Fetch the rss feed, using standard simplepie caching
-            // so feeds will be renewed only if cache has expired
-            core_php_time_limit::raise(60);
-
-            $feed =  new moodle_simplepie();
-            // set timeout for longer than normal to be agressive at
-            // fetching feeds if possible..
-            $feed->set_timeout(40);
-            $feed->set_cache_duration(0);
-            $feed->set_feed_url($rec->url);
-            $feed->init();
-
-            if ($feed->error()) {
-                // Skip this feed (for an ever-increasing time if it keeps failing).
-                $rec->skiptime = $this->calculate_skiptime($rec->skiptime);
-                $rec->skipuntil = time() + $rec->skiptime;
-                $DB->update_record('block_rss_client', $rec);
-                mtrace("Error: could not load/find the RSS feed - skipping for {$rec->skiptime} seconds.");
-            } else {
-                mtrace ('ok');
-                // It worked this time, so reset the skiptime.
-                if ($rec->skiptime > 0) {
-                    $rec->skiptime = 0;
-                    $rec->skipuntil = 0;
-                    $DB->update_record('block_rss_client', $rec);
-                }
-                // Only increase the counter when a feed is sucesfully refreshed.
-                $counter ++;
-            }
-        }
-        $rs->close();
-
-        // Show times
-        mtrace($counter . ' feeds refreshed (took ' . microtime_diff($starttime, microtime()) . ' seconds)');
-
-        return true;
-    }
-
     /**
      * Calculates a new skip time for a record based on the current skip time.
      *
      * @param int $currentskip The curreent skip time of a record.
      * @return int A new skip time that should be set.
      */
-    protected function calculate_skiptime($currentskip) {
+    public function calculate_skiptime($currentskip) {
         // The default time to skiptime.
         $newskiptime = $this->cron * 1.1;
         if ($currentskip > 0) {
diff --git a/blocks/rss_client/classes/task/refreshfeeds.php b/blocks/rss_client/classes/task/refreshfeeds.php
new file mode 100644 (file)
index 0000000..3e34e1b
--- /dev/null
@@ -0,0 +1,124 @@
+<?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/>.
+
+/**
+ * Task for updating RSS feeds for rss client block
+ *
+ * @package   block_rss_client
+ * @author    Farhan Karmali <farhan6318@gmail.com>
+ * @copyright Farhan Karmali 2018
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace block_rss_client\task;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Task for updating RSS feeds for rss client block
+ *
+ * @package   block_rss_client
+ * @author    Farhan Karmali <farhan6318@gmail.com>
+ * @copyright Farhan Karmali 2018
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class refreshfeeds extends \core\task\scheduled_task {
+
+    /**
+     * Name for this task.
+     *
+     * @return string
+     */
+    public function get_name() {
+        return get_string('refreshfeedstask', 'block_rss_client');
+    }
+
+    /**
+     * This task goes through all the feeds. If the feed has a skipuntil value
+     * that is less than the current time cron will attempt to retrieve it
+     * with the cache duration set to 0 in order to force the retrieval of
+     * the item and refresh the cache.
+     *
+     * If a feed fails then the skipuntil time of that feed is set to be
+     * later than the next expected task time. The amount of time will
+     * increase each time the fetch fails until the maximum is reached.
+     *
+     * If a feed that has been failing is successfully retrieved it will
+     * go back to being handled as though it had never failed.
+     *
+     * Task should therefore process requests for permanently broken RSS
+     * feeds infrequently, and temporarily unavailable feeds will be tried
+     * less often until they become available again.
+     */
+    public function execute() {
+        global $CFG, $DB;
+        require_once($CFG->libdir.'/simplepie/moodle_simplepie.php');
+
+        // We are going to measure execution times.
+        $starttime = microtime();
+        $starttimesec = time();
+
+        // Fetch all site feeds.
+        $rs = $DB->get_recordset('block_rss_client');
+        $counter = 0;
+        mtrace('');
+        foreach ($rs as $rec) {
+            mtrace('    ' . $rec->url . ' ', '');
+
+            // Skip feed if it failed recently.
+            if ($starttimesec < $rec->skipuntil) {
+                mtrace('skipping until ' . userdate($rec->skipuntil));
+                continue;
+            }
+
+            // Fetch the rss feed, using standard simplepie caching
+            // so feeds will be renewed only if cache has expired.
+            \core_php_time_limit::raise(60);
+
+            $feed = new \moodle_simplepie();
+            // Set timeout for longer than normal to be agressive at
+            // fetching feeds if possible..
+            $feed->set_timeout(40);
+            $feed->set_cache_duration(0);
+            $feed->set_feed_url($rec->url);
+            $feed->init();
+
+            if ($feed->error()) {
+                // Skip this feed (for an ever-increasing time if it keeps failing).
+                $block = new \block_rss_client();
+                $rec->skiptime = $block->calculate_skiptime($rec->skiptime);
+                $rec->skipuntil = time() + $rec->skiptime;
+                $DB->update_record('block_rss_client', $rec);
+                mtrace("Error: could not load/find the RSS feed - skipping for {$rec->skiptime} seconds.");
+            } else {
+                mtrace ('ok');
+                // It worked this time, so reset the skiptime.
+                if ($rec->skiptime > 0) {
+                    $rec->skiptime = 0;
+                    $rec->skipuntil = 0;
+                    $DB->update_record('block_rss_client', $rec);
+                }
+                // Only increase the counter when a feed is sucesfully refreshed.
+                $counter ++;
+            }
+        }
+        $rs->close();
+
+        // Show times.
+        mtrace($counter . ' feeds refreshed (took ' . microtime_diff($starttime, microtime()) . ' seconds)');
+
+    }
+}
similarity index 59%
rename from admin/tool/assignmentupgrade/version.php
rename to blocks/rss_client/db/tasks.php
index 63fd29d..254e8ae 100644 (file)
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
- * Version details.
- *
- * @package    tool_assignmentupgrade
- * @copyright  2012 NetSpot
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * Task definition for block_rss_client.
+ * @author    Farhan Karmali <farhan6318@gmail.com>
+ * @copyright Farhan Karmali 2018
+ * @package   block_rss_client
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2018051400;
-$plugin->requires  = 2018050800;
-$plugin->component = 'tool_assignmentupgrade';
-$plugin->dependencies = array('mod_assign' => 2018050800);
+$tasks = array(
+    array(
+        'classname' => '\block_rss_client\task\refreshfeeds',
+        'blocking' => 0,
+        'minute' => '*/5',
+        'hour' => '*',
+        'day' => '*',
+        'month' => '*',
+        'dayofweek' => '*',
+        'disabled' => 0
+    )
+);
+
index 3045074..19a9ca5 100644 (file)
@@ -72,6 +72,7 @@ $string['privacy:metadata:block_rss_client:title'] = 'The title of the RSS feed.
 $string['privacy:metadata:block_rss_client:url'] = 'The URL of the RSS feed.';
 $string['privacy:metadata:block_rss_client:userid'] = 'The ID of the user that added the RSS feed.';
 $string['remotenewsfeed'] = 'Remote news feed';
+$string['refreshfeedstask'] = 'Refresh RSS feeds task';
 $string['rss_client:addinstance'] = 'Add a new remote RSS feeds block';
 $string['rss_client:createprivatefeeds'] = 'Create private RSS feeds';
 $string['rss_client:createsharedfeeds'] = 'Create shared RSS feeds';
index 7f99275..bae4cde 100644 (file)
@@ -55,12 +55,12 @@ class block_rss_client_cron_testcase extends advanced_testcase {
         );
         $DB->insert_record('block_rss_client', $record);
 
-        $block = new block_rss_client();
+        $task = new \block_rss_client\task\refreshfeeds();
         ob_start();
 
         // Silence SimplePie php notices.
         $errorlevel = error_reporting($CFG->debug & ~E_USER_NOTICE);
-        $block->cron();
+        $task->execute();
         error_reporting($errorlevel);
 
         $cronoutput = ob_get_clean();
@@ -69,7 +69,7 @@ class block_rss_client_cron_testcase extends advanced_testcase {
     }
 
     /**
-     * Test that when a feed has an error the skip time is increaed correctly.
+     * Test that when a feed has an error the skip time is increased correctly.
      */
     public function test_error() {
         global $DB, $CFG;
@@ -114,20 +114,20 @@ class block_rss_client_cron_testcase extends advanced_testcase {
         );
         $record3->id = $DB->insert_record('block_rss_client', $record3);
 
-        // Run the cron.
-        $block = new block_rss_client();
+        // Run the scheduled task.
+        $task = new \block_rss_client\task\refreshfeeds();
         ob_start();
 
         // Silence SimplePie php notices.
         $errorlevel = error_reporting($CFG->debug & ~E_USER_NOTICE);
-        $block->cron();
+        $task->execute();
         error_reporting($errorlevel);
 
         $cronoutput = ob_get_clean();
         $skiptime1 = $record->skiptime * 2;
         $message1 = 'http://example.com/rss Error: could not load/find the RSS feed - skipping for ' . $skiptime1 . ' seconds.';
         $this->assertContains($message1, $cronoutput);
-        $skiptime2 = 330; // Assumes that the cron time in the version file is 300.
+        $skiptime2 = 0;
         $message2 = 'http://example.com/rss2 Error: could not load/find the RSS feed - skipping for ' . $skiptime2 . ' seconds.';
         $this->assertContains($message2, $cronoutput);
         $skiptime3 = block_rss_client::CLIENT_MAX_SKIPTIME;
index c0e9e59..6f9eac3 100644 (file)
@@ -24,7 +24,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2018051400;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2018052900;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2018050800;        // Requires this Moodle version
 $plugin->component = 'block_rss_client'; // Full name of the plugin (used for diagnostics)
-$plugin->cron      = 300;               // Set min time between cron executions to 300 secs (5 mins)
index 597eb70..0afc594 100644 (file)
@@ -81,6 +81,11 @@ class container {
      */
     protected static $modulecache = array();
 
+    /**
+     * @var int The requesting user. All capability checks are done against this user.
+     */
+    protected static $requestinguserid;
+
     /**
      * Initialises the dependency graph if it hasn't yet been.
      */
@@ -117,11 +122,13 @@ class container {
                 [self::class, 'apply_component_provide_event_action'],
                 [self::class, 'apply_component_is_event_visible'],
                 function ($dbrow) {
+                    $requestinguserid = self::get_requesting_user();
+
                     if (!empty($dbrow->categoryid)) {
                         // This is a category event. Check that the category is visible to this user.
-                        $category = \coursecat::get($dbrow->categoryid, IGNORE_MISSING, true);
+                        $category = \coursecat::get($dbrow->categoryid, IGNORE_MISSING, true, $requestinguserid);
 
-                        if (empty($category) || !$category->is_uservisible()) {
+                        if (empty($category) || !$category->is_uservisible($requestinguserid)) {
                             return true;
                         }
                     }
@@ -131,7 +138,7 @@ class container {
                         return false;
                     }
 
-                    $instances = get_fast_modinfo($dbrow->courseid)->instances;
+                    $instances = get_fast_modinfo($dbrow->courseid, $requestinguserid)->instances;
 
                     // If modinfo doesn't know about the module, we should ignore it.
                     if (!isset($instances[$dbrow->modulename]) || !isset($instances[$dbrow->modulename][$dbrow->instance])) {
@@ -156,11 +163,13 @@ class container {
                     }
 
                     $coursecontext = \context_course::instance($dbrow->courseid);
-                    if (!$cm->get_course()->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
+                    if (!$cm->get_course()->visible &&
+                            !has_capability('moodle/course:viewhiddencourses', $coursecontext, $requestinguserid)) {
                         return true;
                     }
 
-                    if (!has_capability('moodle/course:view', $coursecontext) && !is_enrolled($coursecontext)) {
+                    if (!has_capability('moodle/course:view', $coursecontext, $requestinguserid) &&
+                            !is_enrolled($coursecontext, $requestinguserid)) {
                         return true;
                     }
 
@@ -191,6 +200,7 @@ class container {
      * Reset all static caches, called between tests.
      */
     public static function reset_caches() {
+        self::$requestinguserid = null;
         self::$eventfactory = null;
         self::$eventmapper = null;
         self::$eventvault = null;
@@ -230,6 +240,31 @@ class container {
         return self::$eventvault;
     }
 
+    /**
+     * Sets the requesting user so that all capability checks are done against this user.
+     * Setting the requesting user (hence calling this function) is optional and if you do not so,
+     * $USER will be used as the requesting user. However, if you wish to set the requesting user yourself,
+     * you should call this function before any other function of the container class is called.
+     *
+     * @param int $userid The user id.
+     * @throws \coding_exception
+     */
+    public static function set_requesting_user($userid) {
+        self::$requestinguserid = $userid;
+    }
+
+    /**
+     * Returns the requesting user id.
+     * It usually is the current user unless it has been set explicitly using set_requesting_user.
+     *
+     * @return int
+     */
+    public static function get_requesting_user() {
+        global $USER;
+
+        return empty(self::$requestinguserid) ? $USER->id : self::$requestinguserid;
+    }
+
     /**
      * Calls callback 'core_calendar_provide_event_action' from the component responsible for the event
      *
@@ -245,14 +280,23 @@ class container {
         $mapper = self::$eventmapper;
         $action = null;
         if ($event->get_course_module()) {
+            $requestinguserid = self::get_requesting_user();
+            $legacyevent = $mapper->from_event_to_legacy_event($event);
+            // We know for a fact that the the requesting user might be different from the logged in user,
+            // but the event mapper is not aware of that.
+            if (empty($event->user) && !empty($legacyevent->userid)) {
+                $legacyevent->userid = $requestinguserid;
+            }
+
             // TODO MDL-58866 Only activity modules currently support this callback.
             // Any other event will not be displayed on the dashboard.
             $action = component_callback(
                 'mod_' . $event->get_course_module()->get('modname'),
                 'core_calendar_provide_event_action',
                 [
-                    $mapper->from_event_to_legacy_event($event),
-                    self::$actionfactory
+                    $legacyevent,
+                    self::$actionfactory,
+                    $requestinguserid
                 ]
             );
         }
@@ -279,12 +323,21 @@ class container {
         $mapper = self::$eventmapper;
         $eventvisible = null;
         if ($event->get_course_module()) {
+            $requestinguserid = self::get_requesting_user();
+            $legacyevent = $mapper->from_event_to_legacy_event($event);
+            // We know for a fact that the the requesting user might be different from the logged in user,
+            // but the event mapper is not aware of that.
+            if (empty($event->user) && !empty($legacyevent->userid)) {
+                $legacyevent->userid = $requestinguserid;
+            }
+
             // TODO MDL-58866 Only activity modules currently support this callback.
             $eventvisible = component_callback(
                 'mod_' . $event->get_course_module()->get('modname'),
                 'core_calendar_is_event_visible',
                 [
-                    $mapper->from_event_to_legacy_event($event)
+                    $legacyevent,
+                    $requestinguserid
                 ]
             );
         }
index 5b863b2..37d1a80 100644 (file)
@@ -96,11 +96,24 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
             return array();
         }
 
+        if (is_numeric($users)) {
+            $users = array($users);
+        }
+        if (is_numeric($groups)) {
+            $groups = array($groups);
+        }
+        if (is_numeric($courses)) {
+            $courses = array($courses);
+        }
+        if (is_numeric($categories)) {
+            $categories = array($categories);
+        }
+
         // Array of filter conditions. To be concatenated by the OR operator.
         $filters = [];
 
         // User filter.
-        if ((is_array($users) && !empty($users)) or is_numeric($users)) {
+        if (is_array($users) && !empty($users)) {
             // Events from a number of users.
             list($insqlusers, $inparamsusers) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED);
             $filters[] = "(e.userid $insqlusers AND e.courseid = 0 AND e.groupid = 0 AND e.categoryid = 0)";
@@ -112,7 +125,7 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
         // Boolean false (no users at all): We don't need to do anything.
 
         // Group filter.
-        if ((is_array($groups) && !empty($groups)) or is_numeric($groups)) {
+        if (is_array($groups) && !empty($groups)) {
             // Events from a number of groups.
             list($insqlgroups, $inparamsgroups) = $DB->get_in_or_equal($groups, SQL_PARAMS_NAMED);
             $filters[] = "e.groupid $insqlgroups";
@@ -124,7 +137,7 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
         // Boolean false (no groups at all): We don't need to do anything.
 
         // Course filter.
-        if ((is_array($courses) && !empty($courses)) or is_numeric($courses)) {
+        if (is_array($courses) && !empty($courses)) {
             list($insqlcourses, $inparamscourses) = $DB->get_in_or_equal($courses, SQL_PARAMS_NAMED);
             $filters[] = "(e.groupid = 0 AND e.courseid $insqlcourses)";
             $params = array_merge($params, $inparamscourses);
@@ -134,7 +147,7 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
         }
 
         // Category filter.
-        if ((is_array($categories) && !empty($categories)) or is_numeric($categories)) {
+        if (is_array($categories) && !empty($categories)) {
             list($insqlcategories, $inparamscategories) = $DB->get_in_or_equal($categories, SQL_PARAMS_NAMED);
             $filters[] = "(e.groupid = 0 AND e.courseid = 0 AND e.categoryid $insqlcategories)";
             $params = array_merge($params, $inparamscategories);
@@ -168,54 +181,81 @@ class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_inter
         // Build SQL subquery and conditions for filtered events based on priorities.
         $subquerywhere = '';
         $subqueryconditions = [];
-
-        // Get the user's courses. Otherwise, get the default courses being shown by the calendar.
-        $usercourses = calendar_get_default_courses(null, 'id, category, groupmode, groupmodeforce');
-
-        // Set calendar filters.
-        list($usercourses, $usergroups, $user) = calendar_set_filters($usercourses, true);
         $subqueryparams = [];
-
-        // Flag to indicate whether the query needs to exclude group overrides.
-        $viewgroupsonly = false;
-
-        if ($user) {
-            // Set filter condition for the user's events.
-            $subqueryconditions[] = "(ev.userid = :user AND ev.courseid = 0 AND ev.groupid = 0 AND ev.categoryid = 0)";
-            $subqueryparams['user'] = $user;
-
-            foreach ($usercourses as $courseid) {
-                if (has_capability('moodle/site:accessallgroups', \context_course::instance($courseid))) {
-                    $usergroupmembership = groups_get_all_groups($courseid, $user, 0, 'g.id');
-                    if (count($usergroupmembership) == 0) {
-                        $viewgroupsonly = true;
-                        break;
+        $allusercourses = [];
+
+        if (is_array($users) && !empty($users)) {
+            $userrecords = $DB->get_records_sql("SELECT * FROM {user} WHERE id $insqlusers", $inparamsusers);
+            foreach ($userrecords as $userrecord) {
+                // Get the user's courses. Otherwise, get the default courses being shown by the calendar.
+                $usercourses = calendar_get_default_courses(null, 'id, category, groupmode, groupmodeforce',
+                        false, $userrecord->id);
+
+                // Set calendar filters.
+                list($usercourses, $usergroups, $user) = calendar_set_filters($usercourses, true, $userrecord);
+
+                $allusercourses = array_merge($allusercourses, $usercourses);
+
+                // Flag to indicate whether the query needs to exclude group overrides.
+                $viewgroupsonly = false;
+
+                if ($user) {
+                    // Set filter condition for the user's events.
+                    // Even though $user is a single scalar, we still use get_in_or_equal() because we are inside a loop.
+                    list($inusers, $inuserparams) = $DB->get_in_or_equal($user, SQL_PARAMS_NAMED);
+                    $subqueryconditions[] = "(ev.userid $inusers AND ev.courseid = 0 AND ev.groupid = 0 AND ev.categoryid = 0)";
+                    $subqueryparams = array_merge($subqueryparams, $inuserparams);
+
+                    foreach ($usercourses as $courseid) {
+                        if (has_capability('moodle/site:accessallgroups', \context_course::instance($courseid), $userrecord)) {
+                            $usergroupmembership = groups_get_all_groups($courseid, $user, 0, 'g.id');
+                            if (count($usergroupmembership) == 0) {
+                                $viewgroupsonly = true;
+                                break;
+                            }
+                        }
                     }
                 }
+
+                // Set filter condition for the user's group events.
+                if ($usergroups === true || $viewgroupsonly) {
+                    // Fetch group events, but not group overrides.
+                    $subqueryconditions[] = "(ev.groupid != 0 AND ev.eventtype = 'group')";
+                } else if (!empty($usergroups)) {
+                    // Fetch group events and group overrides.
+                    list($inusergroups, $inusergroupparams) = $DB->get_in_or_equal($usergroups, SQL_PARAMS_NAMED);
+                    $subqueryconditions[] = "(ev.groupid $inusergroups)";
+                    $subqueryparams = array_merge($subqueryparams, $inusergroupparams);
+                }
+            }
+        } else if ($users === true) {
+            // Events from ALL users.
+            $subqueryconditions[] = "(ev.userid != 0 AND ev.courseid = 0 AND ev.groupid = 0 AND ev.categoryid = 0)";
+
+            if (is_array($groups)) {
+                // Events from a number of groups.
+                list($insqlgroups, $inparamsgroups) = $DB->get_in_or_equal($groups, SQL_PARAMS_NAMED);
+                $subqueryconditions[] = "ev.groupid $insqlgroups";
+                $subqueryparams = array_merge($subqueryparams, $inparamsgroups);
+            } else if ($groups === true) {
+                // Events from ALL groups.
+                $subqueryconditions[] = "ev.groupid != 0";
             }
-        }
 
-        // Set filter condition for the user's group events.
-        if ($usergroups === true || $viewgroupsonly) {
-            // Fetch group events, but not group overrides.
-            $subqueryconditions[] = "(ev.groupid != 0 AND ev.eventtype = 'group')";
-        } else if (!empty($usergroups)) {
-            // Fetch group events and group overrides.
-            list($inusergroups, $inusergroupparams) = $DB->get_in_or_equal($usergroups, SQL_PARAMS_NAMED);
-            $subqueryconditions[] = "(ev.groupid $inusergroups)";
-            $subqueryparams = array_merge($subqueryparams, $inusergroupparams);
+            if ($courses === true) {
+                // ALL course events. It's not needed to worry about users' access as $users = true.
+                $subqueryconditions[] = "(ev.groupid = 0 AND ev.courseid != 0 AND ev.categoryid = 0)";
+            }
         }
 
         // Get courses to be used for the subquery.
         $subquerycourses = [];
         if (is_array($courses)) {
             $subquerycourses = $courses;
-        } else if (is_numeric($courses)) {
-            $subquerycourses[] = $courses;
         }
         // Merge with user courses, if necessary.
-        if (!empty($usercourses)) {
-            $subquerycourses = array_merge($subquerycourses, $usercourses);
+        if (!empty($allusercourses)) {
+            $subquerycourses = array_merge($subquerycourses, $allusercourses);
             // Make sure we remove duplicate values.
             $subquerycourses = array_unique($subquerycourses);
         }
index 15dee2a..c3c7aac 100644 (file)
@@ -2039,34 +2039,29 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
  *
  * @param array $courseeventsfrom An array of courses to load calendar events for
  * @param bool $ignorefilters specify the use of filters, false is set as default
+ * @param stdClass $user The user object. This defaults to the global $USER object.
  * @return array An array of courses, groups, and user to load calendar events for based upon filters
  */
-function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) {
-    global $USER, $CFG;
+function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false, stdClass $user = null) {
+    global $CFG, $USER;
 
-    // For backwards compatability we have to check whether the courses array contains
-    // just id's in which case we need to load course objects.
-    $coursestoload = array();
-    foreach ($courseeventsfrom as $id => $something) {
-        if (!is_object($something)) {
-            $coursestoload[] = $id;
-            unset($courseeventsfrom[$id]);
-        }
+    if (is_null($user)) {
+        $user = $USER;
     }
 
     $courses = array();
-    $user = false;
+    $userid = false;
     $group = false;
 
     // Get the capabilities that allow seeing group events from all groups.
     $allgroupscaps = array('moodle/site:accessallgroups', 'moodle/calendar:manageentries');
 
-    $isloggedin = isloggedin();
+    $isvaliduser = !empty($user->id);
 
-    if ($ignorefilters || calendar_show_event_type(CALENDAR_EVENT_COURSE)) {
+    if ($ignorefilters || calendar_show_event_type(CALENDAR_EVENT_COURSE, $user)) {
         $courses = array_keys($courseeventsfrom);
     }
-    if ($ignorefilters || calendar_show_event_type(CALENDAR_EVENT_GLOBAL)) {
+    if ($ignorefilters || calendar_show_event_type(CALENDAR_EVENT_GLOBAL, $user)) {
         $courses[] = SITEID;
     }
     $courses = array_unique($courses);
@@ -2080,11 +2075,11 @@ function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) {
         $courses[] = SITEID;
     }
 
-    if ($ignorefilters || ($isloggedin && calendar_show_event_type(CALENDAR_EVENT_USER))) {
-        $user = $USER->id;
+    if ($ignorefilters || ($isvaliduser && calendar_show_event_type(CALENDAR_EVENT_USER, $user))) {
+        $userid = $user->id;
     }
 
-    if (!empty($courseeventsfrom) && (calendar_show_event_type(CALENDAR_EVENT_GROUP) || $ignorefilters)) {
+    if (!empty($courseeventsfrom) && (calendar_show_event_type(CALENDAR_EVENT_GROUP, $user) || $ignorefilters)) {
 
         if (count($courseeventsfrom) == 1) {
             $course = reset($courseeventsfrom);
@@ -2096,16 +2091,16 @@ function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) {
         if ($group === false) {
             if (!empty($CFG->calendar_adminseesall) && has_any_capability($allgroupscaps, \context_system::instance())) {
                 $group = true;
-            } else if ($isloggedin) {
+            } else if ($isvaliduser) {
                 $groupids = array();
                 foreach ($courseeventsfrom as $courseid => $course) {
                     // If the user is an editing teacher in there.
-                    if (!empty($USER->groupmember[$course->id])) {
+                    if (!empty($user->groupmember[$course->id])) {
                         // We've already cached the users groups for this course so we can just use that.
-                        $groupids = array_merge($groupids, $USER->groupmember[$course->id]);
+                        $groupids = array_merge($groupids, $user->groupmember[$course->id]);
                     } else if ($course->groupmode != NOGROUPS || !$course->groupmodeforce) {
                         // If this course has groups, show events from all of those related to the current user.
-                        $coursegroups = groups_get_user_groups($course->id, $USER->id);
+                        $coursegroups = groups_get_user_groups($course->id, $user->id);
                         $groupids = array_merge($groupids, $coursegroups['0']);
                     }
                 }
@@ -2119,7 +2114,7 @@ function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) {
         $courses = false;
     }
 
-    return array($courses, $group, $user);
+    return array($courses, $group, $userid);
 }
 
 /**
@@ -2317,20 +2312,25 @@ function calendar_delete_event_allowed($event) {
  *
  * @param int $courseid (optional) If passed, an additional course can be returned for admins (the current course).
  * @param string $fields Comma separated list of course fields to return.
- * @param bool $canmanage If true, this will return the list of courses the current user can create events in, rather
+ * @param bool $canmanage If true, this will return the list of courses the user can create events in, rather
  *                        than the list of courses they see events from (an admin can always add events in a course
  *                        calendar, even if they are not enrolled in the course).
+ * @param int $userid (optional) The user which this function returns the default courses for.
+ *                        By default the current user.
  * @return array $courses Array of courses to display
  */
-function calendar_get_default_courses($courseid = null, $fields = '*', $canmanage=false) {
-    global $CFG, $DB;
+function calendar_get_default_courses($courseid = null, $fields = '*', $canmanage = false, int $userid = null) {
+    global $CFG, $USER;
 
-    if (!isloggedin()) {
-        return array();
+    if (!$userid) {
+        if (!isloggedin()) {
+            return array();
+        }
+        $userid = $USER->id;
     }
 
-    if (has_capability('moodle/calendar:manageentries', context_system::instance()) &&
-            (!empty($CFG->calendar_adminseesall) || $canmanage)) {
+    if ((!empty($CFG->calendar_adminseesall) || $canmanage) &&
+            has_capability('moodle/calendar:manageentries', context_system::instance(), $userid)) {
 
         // Add a c. prefix to every field as expected by get_courses function.
         $fieldlist = explode(',', $fields);
@@ -2340,11 +2340,11 @@ function calendar_get_default_courses($courseid = null, $fields = '*', $canmanag
         }, $fieldlist);
         $courses = get_courses('all', 'c.shortname', implode(',', $prefixedfields));
     } else {
-        $courses = enrol_get_my_courses($fields);
+        $courses = enrol_get_users_courses($userid, true, $fields);
     }
 
     if ($courseid && $courseid != SITEID) {
-        if (empty($courses[$courseid]) && has_capability('moodle/calendar:manageentries', context_system::instance())) {
+        if (empty($courses[$courseid]) && has_capability('moodle/calendar:manageentries', context_system::instance(), $userid)) {
             // Allow a site admin to see calendars from courses he is not enrolled in.
             // This will come from $COURSE.
             $courses[$courseid] = get_course($courseid);
@@ -3258,6 +3258,11 @@ function calendar_get_legacy_events($tstart, $tend, $users, $groups, $courses,
         return $param;
     }, [$users, $groups, $courses, $categories]);
 
+    // If a single user is provided, we can use that for capability checks.
+    // Otherwise current logged in user is used - See MDL-58768.
+    if (is_array($userparam) && count($userparam) == 1) {
+        \core_calendar\local\event\container::set_requesting_user($userparam[0]);
+    }
     $mapper = \core_calendar\local\event\container::get_event_mapper();
     $events = \core_calendar\local\api::get_events(
         $tstart,
index e50e58c..35809ec 100644 (file)
@@ -472,6 +472,26 @@ class core_calendar_lib_testcase extends advanced_testcase {
         // Enrolled course only (ignore current).
         $this->assertCount(1, $courses);
 
+        // Now, log out and test again.
+        $this->setUser();
+
+        $CFG->calendar_adminseesall = false;
+
+        $courses = calendar_get_default_courses(null, '*', false, $teacher->id);
+        // Only enrolled in one course.
+        $this->assertCount(1, $courses);
+        $courses = calendar_get_default_courses($course2->id, '*', false, $teacher->id);
+        // Enrolled course only (ignore current).
+        $this->assertCount(1, $courses);
+        // This setting should not affect teachers.
+        $CFG->calendar_adminseesall = true;
+        $courses = calendar_get_default_courses(null, '*', false, $teacher->id);
+        // Only enrolled in one course.
+        $this->assertCount(1, $courses);
+        $courses = calendar_get_default_courses($course2->id, '*', false, $teacher->id);
+        // Enrolled course only (ignore current).
+        $this->assertCount(1, $courses);
+
     }
 
     /**
@@ -627,4 +647,129 @@ class core_calendar_lib_testcase extends advanced_testcase {
         $types = calendar_get_allowed_event_types($course->id);
         $this->assertTrue($types['group']);
     }
+
+    /**
+     * This is a setup helper function that create some users, courses, groups and group memberships.
+     * This is useful to prepare the environment for testing the calendar_set_filters function.
+     *
+     * @return array An array of ($users, $courses, $coursegroups)
+     */
+    protected function setup_test_calendar_set_filters() {
+        $generator = $this->getDataGenerator();
+
+        // Create some users.
+        $users = [];
+        $users[] = $generator->create_user();
+        $users[] = $generator->create_user();
+        $users[] = $generator->create_user();
+
+        // Create some courses.
+        $courses = [];
+        $courses[] = $generator->create_course();
+        $courses[] = $generator->create_course();
+        $courses[] = $generator->create_course();
+        $courses[] = $generator->create_course();
+
+        // Create some groups.
+        $coursegroups = [];
+        $coursegroups[$courses[0]->id] = [];
+        $coursegroups[$courses[0]->id][] = $generator->create_group(['courseid' => $courses[0]->id]);
+        $coursegroups[$courses[0]->id][] = $generator->create_group(['courseid' => $courses[0]->id]);
+        $coursegroups[$courses[2]->id] = [];
+        $coursegroups[$courses[2]->id][] = $generator->create_group(['courseid' => $courses[2]->id]);
+        $coursegroups[$courses[2]->id][] = $generator->create_group(['courseid' => $courses[2]->id]);
+        $coursegroups[$courses[3]->id] = [];
+        $coursegroups[$courses[3]->id][] = $generator->create_group(['courseid' => $courses[3]->id]);
+        $coursegroups[$courses[3]->id][] = $generator->create_group(['courseid' => $courses[3]->id]);
+
+        // Create some enrolments and group memberships.
+        $generator->enrol_user($users[0]->id, $courses[0]->id, 'student');
+        $generator->create_group_member(['groupid' => $coursegroups[$courses[0]->id][0]->id, 'userid' => $users[0]->id]);
+        $generator->enrol_user($users[1]->id, $courses[0]->id, 'student');
+        $generator->create_group_member(['groupid' => $coursegroups[$courses[0]->id][1]->id, 'userid' => $users[1]->id]);
+        $generator->enrol_user($users[0]->id, $courses[1]->id, 'student');
+        $generator->enrol_user($users[0]->id, $courses[2]->id, 'student');
+
+        return array($users, $courses, $coursegroups);
+    }
+
+    /**
+     * This function tests calendar_set_filters for the case when user is not logged in.
+     */
+    public function test_calendar_set_filters_not_logged_in() {
+        $this->resetAfterTest();
+
+        list($users, $courses, $coursegroups) = $this->setup_test_calendar_set_filters();
+
+        $defaultcourses = calendar_get_default_courses(null, '*', false, $users[0]->id);
+        list($courseids, $groupids, $userid) = calendar_set_filters($defaultcourses);
+
+        $this->assertEquals(
+                [$courses[0]->id, $courses[1]->id, $courses[2]->id, SITEID],
+                array_values($courseids),
+                '', 0.0, 10, true);
+        $this->assertFalse($groupids);
+        $this->assertFalse($userid);
+    }
+
+    /**
+     * This function tests calendar_set_filters for the case when no one is logged in, but a user id is provided.
+     */
+    public function test_calendar_set_filters_not_logged_in_with_user() {
+        $this->resetAfterTest();
+
+        list($users, $courses, $coursegroups) = $this->setup_test_calendar_set_filters();
+
+        $defaultcourses = calendar_get_default_courses(null, '*', false, $users[1]->id);
+        list($courseids, $groupids, $userid) = calendar_set_filters($defaultcourses, false, $users[1]);
+
+        $this->assertEquals(array($courses[0]->id, SITEID), array_values($courseids));
+        $this->assertEquals(array($coursegroups[$courses[0]->id][1]->id), $groupids);
+        $this->assertEquals($users[1]->id, $userid);
+
+        $defaultcourses = calendar_get_default_courses(null, '*', false, $users[0]->id);
+        list($courseids, $groupids, $userid) = calendar_set_filters($defaultcourses, false, $users[0]);
+
+        $this->assertEquals(
+                [$courses[0]->id, $courses[1]->id, $courses[2]->id, SITEID],
+                array_values($courseids),
+                '', 0.0, 10, true);
+        $this->assertEquals(array($coursegroups[$courses[0]->id][0]->id), $groupids);
+        $this->assertEquals($users[0]->id, $userid);
+
+    }
+
+    /**
+     * This function tests calendar_set_filters for the case when user is logged in, but no user id is provided.
+     */
+    public function test_calendar_set_filters_logged_in_no_user() {
+        $this->resetAfterTest();
+
+        list($users, $courses, $coursegroups) = $this->setup_test_calendar_set_filters();
+
+        $this->setUser($users[0]);
+        $defaultcourses = calendar_get_default_courses(null, '*', false, $users[0]->id);
+        list($courseids, $groupids, $userid) = calendar_set_filters($defaultcourses, false);
+        $this->assertEquals([$courses[0]->id, $courses[1]->id, $courses[2]->id, SITEID], array_values($courseids), '', 0.0, 10,
+                true);
+        $this->assertEquals(array($coursegroups[$courses[0]->id][0]->id), $groupids);
+        $this->assertEquals($users[0]->id, $userid);
+    }
+
+    /**
+     * This function tests calendar_set_filters for the case when a user is logged in, but another user id is provided.
+     */
+    public function test_calendar_set_filters_logged_in_another_user() {
+        $this->resetAfterTest();
+
+        list($users, $courses, $coursegroups) = $this->setup_test_calendar_set_filters();
+
+        $this->setUser($users[0]);
+        $defaultcourses = calendar_get_default_courses(null, '*', false, $users[1]->id);
+        list($courseids, $groupids, $userid) = calendar_set_filters($defaultcourses, false, $users[1]);
+
+        $this->assertEquals(array($courses[0]->id, SITEID), array_values($courseids));
+        $this->assertEquals(array($coursegroups[$courses[0]->id][1]->id), $groupids);
+        $this->assertEquals($users[1]->id, $userid);
+    }
 }
index 1a927c2..82cd7a8 100644 (file)
@@ -90,15 +90,29 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc
         $this->assertCount(2, $events);
 
         // Disable the lesson module.
-        $modulerecord = $DB->get_record('modules', ['name' => 'lesson']);
-        $modulerecord->visible = 0;
-        $DB->update_record('modules', $modulerecord);
+        $DB->set_field('modules', 'visible', 0, ['name' => 'lesson']);
 
         // Check that we only return the assign event.
         $events = $retrievalstrategy->get_raw_events(null, [0], null);
         $this->assertCount(1, $events);
         $event = reset($events);
         $this->assertEquals('assign', $event->modulename);
+
+        // Now, log out and repeat the above test in the reverse order.
+        $this->setUser();
+
+        // Check that we only return the assign event (given that the lesson module is still disabled).
+        $events = $retrievalstrategy->get_raw_events([$student->id], [0], null);
+        $this->assertCount(1, $events);
+        $event = reset($events);
+        $this->assertEquals('assign', $event->modulename);
+
+        // Enable the lesson module.
+        $DB->set_field('modules', 'visible', 1, ['name' => 'lesson']);
+
+        // Get all events.
+        $events = $retrievalstrategy->get_raw_events(null, [0], null);
+        $this->assertCount(2, $events);
     }
 
     /**
@@ -209,37 +223,37 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc
             calendar_event::create($event, false);
         }
 
-        $timestart = $now - 100;
-        $timeend = $now + (3 * 86400);
         $groups = [$group1->id, $group2->id];
 
-        // Get user override events.
-        $this->setUser($useroverridestudent);
-        $events = $retrievalstrategy->get_raw_events([$useroverridestudent->id], $groups, [$course->id]);
-        $this->assertCount(1, $events);
-        $event = reset($events);
-        $this->assertEquals('Assignment 1 due date - User override', $event->name);
-
-        // Get events for user that does not belong to any group and has no user override events.
-        $this->setUser($nogroupstudent);
-        $events = $retrievalstrategy->get_raw_events([$nogroupstudent->id], $groups, [$course->id]);
-        $this->assertCount(1, $events);
-        $event = reset($events);
-        $this->assertEquals('Assignment 1 due date', $event->name);
-
-        // Get events for user that belongs to groups A and B and has no user override events.
-        $this->setUser($group12student);
-        $events = $retrievalstrategy->get_raw_events([$group12student->id], $groups, [$course->id]);
-        $this->assertCount(1, $events);
-        $event = reset($events);
-        $this->assertEquals('Assignment 1 due date - Group A override', $event->name);
-
-        // Get events for user that belongs to group A and has no user override events.
-        $this->setUser($group1student);
-        $events = $retrievalstrategy->get_raw_events([$group1student->id], $groups, [$course->id]);
-        $this->assertCount(1, $events);
-        $event = reset($events);
-        $this->assertEquals('Assignment 1 due date - Group A override', $event->name);
+        // Do the following tests multiple times when logged in with different users. Also run the whole set when logged out.
+        // In any cases, the tests should not depend on the logged-in user.
+        foreach ([$useroverridestudent, $nogroupstudent, $group12student, $group1student, null] as $login) {
+            $this->setUser($login);
+
+            // Get user override events.
+            $events = $retrievalstrategy->get_raw_events([$useroverridestudent->id], $groups, [$course->id]);
+            $this->assertCount(1, $events);
+            $event = reset($events);
+            $this->assertEquals('Assignment 1 due date - User override', $event->name);
+
+            // Get events for user that does not belong to any group and has no user override events.
+            $events = $retrievalstrategy->get_raw_events([$nogroupstudent->id], $groups, [$course->id]);
+            $this->assertCount(1, $events);
+            $event = reset($events);
+            $this->assertEquals('Assignment 1 due date', $event->name);
+
+            // Get events for user that belongs to groups A and B and has no user override events.
+            $events = $retrievalstrategy->get_raw_events([$group12student->id], $groups, [$course->id]);
+            $this->assertCount(1, $events);
+            $event = reset($events);
+            $this->assertEquals('Assignment 1 due date - Group A override', $event->name);
+
+            // Get events for user that belongs to group A and has no user override events.
+            $events = $retrievalstrategy->get_raw_events([$group1student->id], $groups, [$course->id]);
+            $this->assertCount(1, $events);
+            $event = reset($events);
+            $this->assertEquals('Assignment 1 due date - Group A override', $event->name);
+        }
 
         // Add repeating events.
         $repeatingevents = [
@@ -290,8 +304,6 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc
      * Test retrieval strategy with category specifications.
      */
     public function test_get_raw_events_category() {
-        global $DB;
-
         $this->resetAfterTest();
         $retrievalstrategy = new raw_event_retrieval_strategy();
         $generator = $this->getDataGenerator();
@@ -351,4 +363,88 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc
         $events = $retrievalstrategy->get_raw_events(null, null, null, [$category1->id, $category2->id]);
         $this->assertCount(2, $events);
     }
+
+    public function test_get_raw_events_for_multiple_users() {
+        $this->resetAfterTest();
+
+        $generator = $this->getDataGenerator();
+
+        // Create users.
+        $user1 = $generator->create_user();
+        $user2 = $generator->create_user();
+        $user3 = $generator->create_user();
+
+        // Create user events.
+        $events = [
+            [
+                'name' => 'User1 Event',
+                'eventtype' => 'user',
+                'userid' => $user1->id,
+                'timestart' => time(),
+            ], [
+                'name' => 'User2 Event',
+                'eventtype' => 'user',
+                'userid' => $user2->id,
+                'timestart' => time(),
+            ], [
+                'name' => 'User3 Event',
+                'eventtype' => 'user',
+                'userid' => $user3->id,
+                'timestart' => time(),
+            ]
+        ];
+        foreach ($events as $event) {
+            calendar_event::create($event, false);
+        }
+
+        $retrievalstrategy = new raw_event_retrieval_strategy();
+
+        // Get all events.
+        $events = $retrievalstrategy->get_raw_events([$user1->id, $user2->id]);
+        $this->assertCount(2, $events);
+        $this->assertEquals(
+                ['User1 Event', 'User2 Event'],
+                array_column($events, 'name'),
+                '', 0.0, 10, true);
+    }
+
+    public function test_get_raw_events_for_groups_with_no_members() {
+        $this->resetAfterTest();
+
+        $generator = $this->getDataGenerator();
+
+        $course = $generator->create_course();
+
+        // Create groups.
+        $group1 = $generator->create_group(['courseid' => $course->id, 'name' => 'Group 1']);
+        $group2 = $generator->create_group(['courseid' => $course->id, 'name' => 'Group 2']);
+
+        // Create group events.
+        $events = [
+            [
+                'name' => 'Group 1 Event',
+                'eventtype' => 'group',
+                'groupid' => $group1->id,
+                'timestart' => time(),
+            ], [
+                'name' => 'Group 2 Event',
+                'eventtype' => 'group',
+                'groupid' => $group2->id,
+                'timestart' => time(),
+            ]
+        ];
+        foreach ($events as $event) {
+            calendar_event::create($event, false);
+        }
+
+        $retrievalstrategy = new raw_event_retrieval_strategy;
+
+        // Get group eventsl.
+        $events = $retrievalstrategy->get_raw_events(null, [$group1->id, $group2->id]);
+        $this->assertCount(2, $events);
+        $this->assertEquals(
+                ['Group 1 Event', 'Group 2 Event'],
+                array_column($events, 'name'),
+                '', 0.0, 10, true);
+    }
 }
index 359ee3e..6d3489e 100644 (file)
@@ -1,6 +1,12 @@
 This files describes API changes in /calendar/* ,
 information provided here is intended especially for developers.
 
+=== 3.6 ===
+* calendar_get_default_courses() function now has optional $userid parameter.
+* calendar_set_filters() function now has optional $user parameter.
+* The core_calendar\local\event\container class now provides two new helper methods for getting and setting the requesting user:
+  set_requesting_user() and get_requesting_user().
+
 === 3.5 ===
 * core_calendar_external::get_calendar_events now returns the categoryid for category events.
 
index b07db9a..2ac2247 100644 (file)
@@ -50,7 +50,7 @@ class core_competency_privacy_testcase extends provider_testcase {
         global $PAGE;
         $this->resetAfterTest();
 
-        // We need this or exporters (core_competency\external\exporter) do not receive the right renderer.
+        // We need this or exporters (core\external\exporter) do not receive the right renderer.
         $PAGE->get_renderer('core');
     }
 
index a686f13..388b9b7 100644 (file)
@@ -35,7 +35,6 @@ define('NO_DEBUG_DISPLAY', true);
 // @codingStandardsIgnoreLine This script does not require login.
 require("../../config.php");
 require_once("lib.php");
-require_once($CFG->libdir.'/eventslib.php');
 require_once($CFG->libdir.'/enrollib.php');
 require_once($CFG->libdir . '/filelib.php');
 
index 2e3280d..dbb69cd 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 
     require('../config.php');
-    require_once($CFG->libdir.'/eventslib.php');
 
     // Form submitted, do not check referer (original page unknown).
     if ($form = data_submitted()) {
index 393afe4..dedd4bf 100644 (file)
@@ -141,7 +141,7 @@ if (!$edit) {
         if (!$admin and empty($data->override)) {
             $records = $DB->get_records('grade_letters', array('contextid' => $context->id));
             foreach ($records as $record) {
-                $DB->delete_record('grade_letters', array('id' => $record->id));
+                $DB->delete_records('grade_letters', array('id' => $record->id));
                 // Trigger the letter grade deleted event.
                 $event = \core\event\grade_letter_deleted::create(array(
                     'objectid' => $record->id,
index c3e39cd..4b909cf 100644 (file)
@@ -234,9 +234,6 @@ function uninstall_plugin($type, $name) {
     // delete the capabilities that were defined by this module
     capabilities_cleanup($component);
 
-    // remove event handlers and dequeue pending events
-    events_uninstall($component);
-
     // Delete all remaining files in the filepool owned by the component.
     $fs = get_file_storage();
     $fs->delete_component_files($component);
@@ -7971,9 +7968,7 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
  * @return object admin_root object
  */
 function admin_get_root($reload=false, $requirefulltree=true) {
-    global $CFG, $DB, $OUTPUT;
-
-    static $ADMIN = NULL;
+    global $CFG, $DB, $OUTPUT, $ADMIN;
 
     if (is_null($ADMIN)) {
     // create the admin tree!
index 27f74c0..0d7831f 100644 (file)
@@ -834,10 +834,6 @@ abstract class base implements \IteratorAggregate {
         \core\event\manager::dispatch($this);
 
         $this->dispatched = true;
-
-        if ($legacyeventname = static::get_legacy_eventname()) {
-            events_trigger_legacy($legacyeventname, $this->get_legacy_eventdata());
-        }
     }
 
     /**
index 4931121..7f9665d 100644 (file)
@@ -1652,7 +1652,7 @@ class core_plugin_manager {
             'report' => array('search'),
             'repository' => array('alfresco'),
             'tinymce' => array('dragmath'),
-            'tool' => array('bloglevelupgrade', 'qeupgradehelper', 'timezoneimport'),
+            'tool' => array('bloglevelupgrade', 'qeupgradehelper', 'timezoneimport', 'assignmentupgrade'),
             'theme' => array('afterburner', 'anomaly', 'arialist', 'base', 'binarius', 'boxxie', 'brick', 'canvas',
                 'formal_white', 'formfactor', 'fusion', 'leatherbound', 'magazine', 'mymobile', 'nimble', 'nonzero',
                 'overlay', 'serenity', 'sky_high', 'splash', 'standard', 'standardold'),
@@ -1904,7 +1904,7 @@ class core_plugin_manager {
             ),
 
             'tool' => array(
-                'analytics', 'assignmentupgrade', 'availabilityconditions', 'behat', 'capability', 'cohortroles', 'customlang',
+                'analytics', 'availabilityconditions', 'behat', 'capability', 'cohortroles', 'customlang',
                 'dataprivacy', 'dbtransfer', 'filetypes', 'generator', 'health', 'httpsreplace', 'innodb', 'installaddon',
                 'langimport', 'log', 'lp', 'lpimportcsv', 'lpmigrate', 'messageinbound', 'mobile', 'multilangupgrade',
                 'monitor', 'oauth2', 'phpunit', 'policy', 'profiling', 'recyclebin', 'replace', 'spamcleaner', 'task',
index f617cc2..6568e4b 100644 (file)
@@ -712,6 +712,7 @@ class manager {
      * @param \stdClass $user record
      */
     public static function set_user(\stdClass $user) {
+        global $ADMIN;
         $GLOBALS['USER'] = $user;
         unset($GLOBALS['USER']->description); // Conserve memory.
         unset($GLOBALS['USER']->password);    // Improve security.
@@ -723,6 +724,9 @@ class manager {
         // Relink session with global $USER just in case it got unlinked somehow.
         $_SESSION['USER'] =& $GLOBALS['USER'];
 
+        // Nullify the $ADMIN tree global. If we're changing users, then this is now stale and must be generated again if needed.
+        $ADMIN = null;
+
         // Init session key.
         sesskey();
     }
diff --git a/lib/classes/task/events_cron_task.php b/lib/classes/task/events_cron_task.php
deleted file mode 100644 (file)
index 07f8bae..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?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/>.
-
-/**
- * A scheduled task.
- *
- * @package    core
- * @copyright  2013 onwards Martin Dougiamas  http://dougiamas.com
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-namespace core\task;
-
-/**
- * Simple task to run the events cron.
- */
-class events_cron_task extends scheduled_task {
-
-    /**
-     * Get a descriptive name for this task (shown to admins).
-     *
-     * @return string
-     */
-    public function get_name() {
-        return get_string('taskeventscron', 'admin');
-    }
-
-    /**
-     * Do the job.
-     * Throw exceptions on errors (the job will be retried).
-     */
-    public function execute() {
-        events_cron();
-    }
-
-}
index 5ad20b7..8833387 100644 (file)
@@ -212,7 +212,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
     /**
      * Returns coursecat object for requested category
      *
-     * If category is not visible to user it is treated as non existing
+     * If category is not visible to the given user, it is treated as non existing
      * unless $alwaysreturnhidden is set to true
      *
      * If id is 0, the pseudo object for root category is returned (convenient
@@ -226,10 +226,11 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
      *     returned even if this category is not visible to the current user
      *     (category is hidden and user does not have
      *     'moodle/category:viewhiddencategories' capability). Use with care!
+     * @param int|stdClass $user The user id or object. By default (null) checks the visibility to the current user.
      * @return null|coursecat
      * @throws moodle_exception
      */
-    public static function get($id, $strictness = MUST_EXIST, $alwaysreturnhidden = false) {
+    public static function get($id, $strictness = MUST_EXIST, $alwaysreturnhidden = false, $user = null) {
         if (!$id) {
             if (!isset(self::$coursecat0)) {
                 $record = new stdClass();
@@ -251,7 +252,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
                 $coursecatrecordcache->set($id, $coursecat);
             }
         }
-        if ($coursecat && ($alwaysreturnhidden || $coursecat->is_uservisible())) {
+        if ($coursecat && ($alwaysreturnhidden || $coursecat->is_uservisible($user))) {
             return $coursecat;
         } else {
             if ($strictness == MUST_EXIST) {
@@ -580,17 +581,18 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
     }
 
     /**
-     * Checks if this course category is visible to current user
+     * Checks if this course category is visible to a user.
      *
      * Please note that methods coursecat::get (without 3rd argumet),
      * coursecat::get_children(), etc. return only visible categories so it is
      * usually not needed to call this function outside of this class
      *
+     * @param int|stdClass $user The user id or object. By default (null) checks the visibility to the current user.
      * @return bool
      */
-    public function is_uservisible() {
+    public function is_uservisible($user = null) {
         return !$this->id || $this->visible ||
-                has_capability('moodle/category:viewhiddencategories', $this->get_context());
+                has_capability('moodle/category:viewhiddencategories', $this->get_context(), $user);
     }
 
     /**
index 30d4b42..9ccba77 100644 (file)
@@ -35,15 +35,5 @@ defined('MOODLE_INTERNAL') || die();
 // Like other files in the db directory this file uses an array.
 // The old class name is the key, the new class name is the value.
 // The array must be called $renamedclasses.
-// TODO MDL-57244 These renamed classes will be removed in 3.6
 $renamedclasses = array(
-    'core\progress\null' => 'core\progress\none',
-    'core_search\area\base' => 'core_search\base',
-    'core_search\area\base_mod' => 'core_search\base_mod',
-    'core_search\area\base_activity' => 'core_search\base_activity',
-    'core_competency\\external\\exporter' => 'core\\external\\exporter',
-    'core_competency\\external\\persistent_exporter' => 'core\\external\\persistent_exporter',
-    'core_competency\\external\\comment_area_exporter' => 'core_comment\\external\\comment_area_exporter',
-    'core_competency\\external\\stored_file_exporter' => 'core_files\\external\\stored_file_exporter',
-    'core_competency\\external\\user_summary_exporter' => 'core_user\\external\\user_summary_exporter'
 );
index 6873e42..38e8d85 100644 (file)
@@ -149,15 +149,6 @@ $tasks = array(
         'dayofweek' => '*',
         'month' => '*'
     ),
-    array(
-        'classname' => 'core\task\events_cron_task',
-        'blocking' => 0,
-        'minute' => '*',
-        'hour' => '*',
-        'day' => '*',
-        'dayofweek' => '*',
-        'month' => '*'
-    ),
     array(
         'classname' => 'core\task\completion_regular_task',
         'blocking' => 0,
index 9cf7394..8fbb66a 100644 (file)
@@ -2293,5 +2293,13 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2018072500.00);
     }
 
+    if ($oldversion < 2018073000.00) {
+        // Main savepoint reached.
+        if (!file_exists($CFG->dirroot . '/admin/tool/assignmentupgrade/version.php')) {
+            unset_all_config_for_plugin('tool_assignmentupgrade');
+        }
+        upgrade_main_savepoint(true, 2018073000.00);
+    }
+
     return true;
 }
index daf12c4..38c5f08 100644 (file)
@@ -58,17 +58,10 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
 }
 
 /**
- * Function to call all event handlers when triggering an event
- *
  * @deprecated since 2.6
- *
- * @param string $eventname name of the event
- * @param mixed $eventdata event data object
- * @return int number of failed events
  */
-function events_trigger($eventname, $eventdata) {
-    debugging('events_trigger() is deprecated, please use new events instead', DEBUG_DEVELOPER);
-    return events_trigger_legacy($eventname, $eventdata);
+function events_trigger() {
+    throw new coding_exception('events_trigger() has been deprecated along with all Events 1 API in favour of Events 2 API.');
 }
 
 /**
@@ -274,84 +267,56 @@ function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE
 /* === End of long term deprecated api list === */
 
 /**
- * Adds a file upload to the log table so that clam can resolve the filename to the user later if necessary
- *
  * @deprecated since 2.7 - use new file picker instead
- *
  */
-function clam_log_upload($newfilepath, $course=null, $nourl=false) {
+function clam_log_upload() {
     throw new coding_exception('clam_log_upload() can not be used any more, please use file picker instead');
 }
 
 /**
- * This function logs to error_log and to the log table that an infected file has been found and what's happened to it.
- *
  * @deprecated since 2.7 - use new file picker instead
- *
  */
-function clam_log_infected($oldfilepath='', $newfilepath='', $userid=0) {
+function clam_log_infected() {
     throw new coding_exception('clam_log_infected() can not be used any more, please use file picker instead');
 }
 
 /**
- * Some of the modules allow moving attachments (glossary), in which case we need to hunt down an original log and change the path.
- *
  * @deprecated since 2.7 - use new file picker instead
- *
  */
-function clam_change_log($oldpath, $newpath, $update=true) {
+function clam_change_log() {
     throw new coding_exception('clam_change_log() can not be used any more, please use file picker instead');
 }
 
 /**
- * Replaces the given file with a string.
- *
  * @deprecated since 2.7 - infected files are now deleted in file picker
- *
  */
-function clam_replace_infected_file($file) {
+function clam_replace_infected_file() {
     throw new coding_exception('clam_replace_infected_file() can not be used any more, please use file picker instead');
 }
 
 /**
- * Deals with an infected file - either moves it to a quarantinedir
- * (specified in CFG->quarantinedir) or deletes it.
- *
- * If moving it fails, it deletes it.
- *
  * @deprecated since 2.7
  */
-function clam_handle_infected_file($file, $userid=0, $basiconly=false) {
+function clam_handle_infected_file() {
     throw new coding_exception('clam_handle_infected_file() can not be used any more, please use file picker instead');
 }
 
 /**
- * If $CFG->runclamonupload is set, we scan a given file. (called from {@link preprocess_files()})
- *
  * @deprecated since 2.7
  */
-function clam_scan_moodle_file(&$file, $course) {
+function clam_scan_moodle_file() {
     throw new coding_exception('clam_scan_moodle_file() can not be used any more, please use file picker instead');
 }
 
 
 /**
- * Checks whether the password compatibility library will work with the current
- * version of PHP. This cannot be done using PHP version numbers since the fix
- * has been backported to earlier versions in some distributions.
- *
- * See https://github.com/ircmaxell/password_compat/issues/10 for more details.
- *
  * @deprecated since 2.7 PHP 5.4.x should be always compatible.
- *
  */
 function password_compat_not_supported() {
     throw new coding_exception('Do not use password_compat_not_supported() - bcrypt is now always available');
 }
 
 /**
- * Factory method that was returning moodle_session object.
- *
  * @deprecated since 2.6
  */
 function session_get_instance() {
@@ -359,8 +324,6 @@ function session_get_instance() {
 }
 
 /**
- * Returns true if legacy session used.
- *
  * @deprecated since 2.6
  */
 function session_is_legacy() {
@@ -368,8 +331,6 @@ function session_is_legacy() {
 }
 
 /**
- * Terminates all sessions, auth hooks are not executed.
- *
  * @deprecated since 2.6
  */
 function session_kill_all() {
@@ -377,45 +338,34 @@ function session_kill_all() {
 }
 
 /**
- * Mark session as accessed, prevents timeouts.
- *
  * @deprecated since 2.6
  */
-function session_touch($sid) {
+function session_touch() {
     throw new coding_exception('session_touch() is removed, use \core\session\manager::touch_session() instead');
 }
 
 /**
- * Terminates one sessions, auth hooks are not executed.
- *
  * @deprecated since 2.6
  */
-function session_kill($sid) {
+function session_kill() {
     throw new coding_exception('session_kill() is removed, use \core\session\manager::kill_session() instead');
 }
 
 /**
- * Terminates all sessions of one user, auth hooks are not executed.
- *
  * @deprecated since 2.6
  */
-function session_kill_user($userid) {
+function session_kill_user() {
     throw new coding_exception('session_kill_user() is removed, use \core\session\manager::kill_user_sessions() instead');
 }
 
 /**
- * Setup $USER object - called during login, loginas, etc.
- *
- * Call sync_user_enrolments() manually after log-in, or log-in-as.
- *
  * @deprecated since 2.6
  */
-function session_set_user($user) {
+function session_set_user() {
     throw new coding_exception('session_set_user() is removed, use \core\session\manager::set_user() instead');
 }
 
 /**
- * Is current $USER logged-in-as somebody else?
  * @deprecated since 2.6
  */
 function session_is_loggedinas() {
@@ -423,7 +373,6 @@ function session_is_loggedinas() {
 }
 
 /**
- * Returns the $USER object ignoring current login-as session
  * @deprecated since 2.6
  */
 function session_get_realuser() {
@@ -431,36 +380,29 @@ function session_get_realuser() {
 }
 
 /**
- * Login as another user - no security checks here.
  * @deprecated since 2.6
  */
-function session_loginas($userid, $context) {
+function session_loginas() {
     throw new coding_exception('session_loginas() is removed, use \core\session\manager::loginas() instead');
 }
 
 /**
- * Minify JavaScript files.
- *
  * @deprecated since 2.6
  */
-function js_minify($files) {
+function js_minify() {
     throw new coding_exception('js_minify() is removed, use core_minify::js_files() or core_minify::js() instead.');
 }
 
 /**
- * Minify CSS files.
- *
  * @deprecated since 2.6
  */
-function css_minify_css($files) {
+function css_minify_css() {
     throw new coding_exception('css_minify_css() is removed, use core_minify::css_files() or core_minify::css() instead.');
 }
 
 // === Deprecated before 2.6.0 ===
 
 /**
- * Hack to find out the GD version by parsing phpinfo output
- *
  * @deprecated
  */
 function check_gd_version() {
@@ -468,8 +410,6 @@ function check_gd_version() {
 }
 
 /**
- * Not used any more, the account lockout handling is now
- * part of authenticate_user_login().
  * @deprecated
  */
 function update_login_count() {
@@ -477,7 +417,6 @@ function update_login_count() {
 }
 
 /**
- * Not used any more, replaced by proper account lockout.
  * @deprecated
  */
 function reset_login_count() {
@@ -487,7 +426,7 @@ function reset_login_count() {
 /**
  * @deprecated
  */
-function update_log_display_entry($module, $action, $mtable, $field) {
+function update_log_display_entry() {
 
     throw new coding_exception('The update_log_display_entry() is removed, please use db/log.php description file instead.');
 }
@@ -496,7 +435,7 @@ function update_log_display_entry($module, $action, $mtable, $field) {
  * @deprecated use the text formatting in a standard way instead (http://docs.moodle.org/dev/Output_functions)
  *             this was abused mostly for embedding of attachments
  */
-function filter_text($text, $courseid = NULL) {
+function filter_text() {
     throw new coding_exception('filter_text() can not be used anymore, use format_text(), format_string() etc instead.');
 }
 
@@ -508,89 +447,40 @@ function httpsrequired() {
 }
 
 /**
- * Given a physical path to a file, returns the URL through which it can be reached in Moodle.
- *
  * @deprecated since 3.1 - replacement legacy file API methods can be found on the moodle_url class, for example:
  * The moodle_url::make_legacyfile_url() method can be used to generate a legacy course file url. To generate
  * course module file.php url the moodle_url::make_file_url() should be used.
- *
- * @param string $path Physical path to a file
- * @param array $options associative array of GET variables to append to the URL
- * @param string $type (questionfile|rssfile|httpscoursefile|coursefile)
- * @return string URL to file
  */
-function get_file_url($path, $options=null, $type='coursefile') {
-    debugging('Function get_file_url() is deprecated, please use moodle_url factory methods instead.', DEBUG_DEVELOPER);
-    global $CFG;
-
-    $path = str_replace('//', '/', $path);
-    $path = trim($path, '/'); // no leading and trailing slashes
-
-    // type of file
-    switch ($type) {
-       case 'questionfile':
-            $url = $CFG->wwwroot."/question/exportfile.php";
-            break;
-       case 'rssfile':
-            $url = $CFG->wwwroot."/rss/file.php";
-            break;
-         case 'coursefile':
-        default:
-            $url = $CFG->wwwroot."/file.php";
-    }
-
-    if ($CFG->slasharguments) {
-        $parts = explode('/', $path);
-        foreach ($parts as $key => $part) {
-        /// anchor dash character should not be encoded
-            $subparts = explode('#', $part);
-            $subparts = array_map('rawurlencode', $subparts);
-            $parts[$key] = implode('#', $subparts);
-        }
-        $path  = implode('/', $parts);
-        $ffurl = $url.'/'.$path;
-        $separator = '?';
-    } else {
-        $path = rawurlencode('/'.$path);
-        $ffurl = $url.'?file='.$path;
-        $separator = '&amp;';
-    }
-
-    if ($options) {
-        foreach ($options as $name=>$value) {
-            $ffurl = $ffurl.$separator.$name.'='.$value;
-            $separator = '&amp;';
-        }
-    }
-
-    return $ffurl;
+function get_file_url() {
+    throw new coding_exception('get_file_url() can not be used anymore. Please use ' .
+        'moodle_url factory methods instead.');
 }
 
 /**
  * @deprecated use get_enrolled_users($context) instead.
  */
-function get_course_participants($courseid) {
+function get_course_participants() {
     throw new coding_exception('get_course_participants() can not be used any more, use get_enrolled_users() instead.');
 }
 
 /**
  * @deprecated use is_enrolled($context, $userid) instead.
  */
-function is_course_participant($userid, $courseid) {
+function is_course_participant() {
     throw new coding_exception('is_course_participant() can not be used any more, use is_enrolled() instead.');
 }
 
 /**
  * @deprecated
  */
-function get_recent_enrolments($courseid, $timestart) {
+function get_recent_enrolments() {
     throw new coding_exception('get_recent_enrolments() is removed as it returned inaccurate results.');
 }
 
 /**
  * @deprecated use clean_param($string, PARAM_FILE) instead.
  */
-function detect_munged_arguments($string, $allowdots=1) {
+function detect_munged_arguments() {
     throw new coding_exception('detect_munged_arguments() can not be used any more, please use clean_param(,PARAM_FILE) instead.');
 }
 
@@ -744,35 +634,35 @@ function zip_files($originalfiles, $destination) {
 /**
  * @deprecated use groups_get_all_groups() instead.
  */
-function mygroupid($courseid) {
+function mygroupid() {
     throw new coding_exception('mygroupid() can not be used any more, please use groups_get_all_groups() instead.');
 }
 
 /**
  * @deprecated since Moodle 2.0 MDL-14617 - please do not use this function any more.
  */
-function groupmode($course, $cm=null) {
+function groupmode() {
     throw new coding_exception('groupmode() can not be used any more, please use groups_get_* instead.');
 }
 
 /**
  * @deprecated Since year 2006 - please do not use this function any more.
  */
-function set_current_group($courseid, $groupid) {
+function set_current_group() {
     throw new coding_exception('set_current_group() can not be used anymore, please use $SESSION->currentgroup[$courseid] instead');
 }
 
 /**
  * @deprecated Since year 2006 - please do not use this function any more.
  */
-function get_current_group($courseid, $full = false) {
+function get_current_group() {
     throw new coding_exception('get_current_group() can not be used any more, please use groups_get_* instead');
 }
 
 /**
  * @deprecated Since Moodle 2.8
  */
-function groups_filter_users_by_course_module_visible($cm, $users) {
+function groups_filter_users_by_course_module_visible() {
     throw new coding_exception('groups_filter_users_by_course_module_visible() is removed. ' .
             'Replace with a call to \core_availability\info_module::filter_user_list(), ' .
             'which does basically the same thing but includes other restrictions such ' .
@@ -782,7 +672,7 @@ function groups_filter_users_by_course_module_visible($cm, $users) {
 /**
  * @deprecated Since Moodle 2.8
  */
-function groups_course_module_visible($cm, $userid=null) {
+function groups_course_module_visible() {
     throw new coding_exception('groups_course_module_visible() is removed, use $cm->uservisible to decide whether the current
         user can ' . 'access an activity.', DEBUG_DEVELOPER);
 }
@@ -790,7 +680,7 @@ function groups_course_module_visible($cm, $userid=null) {
 /**
  * @deprecated since 2.0
  */
-function error($message, $link='') {
+function error() {
     throw new coding_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a removed, please call
             print_error() instead of error()');
 }
@@ -806,7 +696,7 @@ function current_theme() {
 /**
  * @deprecated
  */
-function formerr($error) {
+function formerr() {
     throw new coding_exception('formerr() is removed. Please change your code to use $OUTPUT->error_text($string).');
 }
 
@@ -820,21 +710,21 @@ function skip_main_destination() {
 /**
  * @deprecated use $OUTPUT->container() instead.
  */
-function print_container($message, $clearfix=false, $classes='', $idbase='', $return=false) {
+function print_container() {
     throw new coding_exception('print_container() can not be used any more. Please use $OUTPUT->container() instead.');
 }
 
 /**
  * @deprecated use $OUTPUT->container_start() instead.
  */
-function print_container_start($clearfix=false, $classes='', $idbase='', $return=false) {
+function print_container_start() {
     throw new coding_exception('print_container_start() can not be used any more. Please use $OUTPUT->container_start() instead.');
 }
 
 /**
  * @deprecated use $OUTPUT->container_end() instead.
  */
-function print_container_end($return=false) {
+function print_container_end() {
     throw new coding_exception('print_container_end() can not be used any more. Please use $OUTPUT->container_end() instead.');
 }
 
@@ -848,16 +738,14 @@ function notify() {
 /**
  * @deprecated use $OUTPUT->continue_button() instead.
  */
-function print_continue($link, $return = false) {
+function print_continue() {
     throw new coding_exception('print_continue() can not be used any more. Please use $OUTPUT->continue_button() instead.');
 }
 
 /**
  * @deprecated use $PAGE methods instead.
  */
-function print_header($title='', $heading='', $navigation='', $focus='',
-                      $meta='', $cache=true, $button='&nbsp;', $menu=null,
-                      $usexml=false, $bodytags='', $return=false) {
+function print_header() {
 
     throw new coding_exception('print_header() can not be used any more. Please use $PAGE methods instead.');
 }
@@ -865,8 +753,7 @@ function print_header($title='', $heading='', $navigation='', $focus='',
 /**
  * @deprecated use $PAGE methods instead.
  */
-function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',
-                       $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='', $return=false) {
+function print_header_simple() {
 
     throw new coding_exception('print_header_simple() can not be used any more. Please use $PAGE methods instead.');
 }
@@ -874,7 +761,7 @@ function print_header_simple($title='', $heading='', $navigation='', $focus='',
 /**
  * @deprecated use $OUTPUT->block() instead.
  */
-function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') {
+function print_side_block() {
     throw new coding_exception('print_side_block() can not be used any more, please use $OUTPUT->block() instead.');
 }
 
@@ -997,17 +884,14 @@ function print_arrow($direction='up', $strsort=null, $return=false) {
 /**
  * @deprecated since Moodle 2.0
  */
-function choose_from_menu ($options, $name, $selected='', $nothing='choose', $script='',
-                           $nothingvalue='0', $return=false, $disabled=false, $tabindex=0,
-                           $id='', $listbox=false, $multiple=false, $class='') {
+function choose_from_menu() {
     throw new coding_exception('choose_from_menu() is removed. Please change your code to use html_writer::select().');
-
 }
 
 /**
  * @deprecated use $OUTPUT->help_icon_scale($courseid, $scale) instead.
  */
-function print_scale_menu_helpbutton($courseid, $scale, $return=false) {
+function print_scale_menu_helpbutton() {
     throw new coding_exception('print_scale_menu_helpbutton() can not be used any more. '.
         'Please use $OUTPUT->help_icon_scale($courseid, $scale) instead.');
 }
@@ -1015,7 +899,7 @@ function print_scale_menu_helpbutton($courseid, $scale, $return=false) {
 /**
  * @deprecated use html_writer::checkbox() instead.
  */
-function print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script='', $return=false) {
+function print_checkbox() {
     throw new coding_exception('print_checkbox() can not be used any more. Please use html_writer::checkbox() instead.');
 }
 
@@ -1049,21 +933,21 @@ function update_module_button($cmid, $ignored, $string) {
 /**
  * @deprecated use $OUTPUT->navbar() instead
  */
-function print_navigation ($navigation, $separator=0, $return=false) {
+function print_navigation () {
     throw new coding_exception('print_navigation() can not be used any more, please update use $OUTPUT->navbar() instead.');
 }
 
 /**
  * @deprecated Please use $PAGE->navabar methods instead.
  */
-function build_navigation($extranavlinks, $cm = null) {
+function build_navigation() {
     throw new coding_exception('build_navigation() can not be used any more, please use $PAGE->navbar methods instead.');
 }
 
 /**
  * @deprecated not relevant with global navigation in Moodle 2.x+
  */
-function navmenu($course, $cm=NULL, $targetwindow='self') {
+function navmenu() {
     throw new coding_exception('navmenu() can not be used any more, it is no longer relevant with global navigation.');
 }
 
@@ -1073,21 +957,21 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
 /**
  * @deprecated please use calendar_event::create() instead.
  */
-function add_event($event) {
+function add_event() {
     throw new coding_exception('add_event() can not be used any more, please use calendar_event::create() instead.');
 }
 
 /**
  * @deprecated please calendar_event->update() instead.
  */
-function update_event($event) {
+function update_event() {
     throw new coding_exception('update_event() is removed, please use calendar_event->update() instead.');
 }
 
 /**
  * @deprecated please use calendar_event->delete() instead.
  */
-function delete_event($id) {
+function delete_event() {
     throw new coding_exception('delete_event() can not be used any more, please use '.
         'calendar_event->delete() instead.');
 }
@@ -1095,7 +979,7 @@ function delete_event($id) {
 /**
  * @deprecated please use calendar_event->toggle_visibility(false) instead.
  */
-function hide_event($event) {
+function hide_event() {
     throw new coding_exception('hide_event() can not be used any more, please use '.
         'calendar_event->toggle_visibility(false) instead.');
 }
@@ -1103,14 +987,13 @@ function hide_event($event) {
 /**
  * @deprecated please use calendar_event->toggle_visibility(true) instead.
  */
-function show_event($event) {
+function show_event() {
     throw new coding_exception('show_event() can not be used any more, please use '.
         'calendar_event->toggle_visibility(true) instead.');
 }
 
 /**
  * @deprecated since Moodle 2.2 use core_text::xxxx() instead.
- * @see core_text
  */
 function textlib_get_instance() {
     throw new coding_exception('textlib_get_instance() can not be used any more, please use '.
@@ -1119,156 +1002,78 @@ function textlib_get_instance() {
 
 /**
  * @deprecated since 2.4
- * @see get_section_name()
- * @see format_base::get_section_name()
-
  */
-function get_generic_section_name($format, stdClass $section) {
+function get_generic_section_name() {
     throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality from class format_base');
 }
 
 /**
- * Returns an array of sections for the requested course id
- *
- * It is usually not recommended to display the list of sections used
- * in course because the course format may have it's own way to do it.
- *
- * If you need to just display the name of the section please call:
- * get_section_name($course, $section)
- * {@link get_section_name()}
- * from 2.4 $section may also be just the field course_sections.section
- *
- * If you need the list of all sections it is more efficient to get this data by calling
- * $modinfo = get_fast_modinfo($courseorid);
- * $sections = $modinfo->get_section_info_all()
- * {@link get_fast_modinfo()}
- * {@link course_modinfo::get_section_info_all()}
- *
- * Information about one section (instance of section_info):
- * get_fast_modinfo($courseorid)->get_sections_info($section)
- * {@link course_modinfo::get_section_info()}
- *
  * @deprecated since 2.4
  */
-function get_all_sections($courseid) {
-
+function get_all_sections() {
     throw new coding_exception('get_all_sections() is removed. See phpdocs for this function');
 }
 
 /**
- * This function is deprecated, please use {@link course_add_cm_to_section()}
- * Note that course_add_cm_to_section() also updates field course_modules.section and
- * calls rebuild_course_cache()
- *
  * @deprecated since 2.4
  */
-function add_mod_to_section($mod, $beforemod = null) {
+function add_mod_to_section() {
     throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()');
 }
 
 /**
- * Returns a number of useful structures for course displays
- *
- * Function get_all_mods() is deprecated in 2.4
- * Instead of:
- * <code>
- * get_all_mods($courseid, $mods, $modnames, $modnamesplural, $modnamesused);
- * </code>
- * please use:
- * <code>
- * $mods = get_fast_modinfo($courseorid)->get_cms();
- * $modnames = get_module_types_names();
- * $modnamesplural = get_module_types_names(true);
- * $modnamesused = get_fast_modinfo($courseorid)->get_used_module_names();
- * </code>
- *
  * @deprecated since 2.4
  */
-function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused) {
+function get_all_mods() {
     throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details');
 }
 
 /**
- * Returns course section - creates new if does not exist yet
- *
- * This function is deprecated. To create a course section call:
- * course_create_sections_if_missing($courseorid, $sections);
- * to get the section call:
- * get_fast_modinfo($courseorid)->get_section_info($sectionnum);
- *
- * @see course_create_sections_if_missing()
- * @see get_fast_modinfo()
  * @deprecated since 2.4
  */
-function get_course_section($section, $courseid) {
+function get_course_section() {
     throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.');
 }
 
 /**
  * @deprecated since 2.4
- * @see format_weeks::get_section_dates()
  */
-function format_weeks_get_section_dates($section, $course) {
+function format_weeks_get_section_dates() {
     throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'.
             ' use it outside of format_weeks plugin');
 }
 
 /**
- * Deprecated. Instead of:
- * list($content, $name) = get_print_section_cm_text($cm, $course);
- * use:
- * $content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
- * $name = $cm->get_formatted_name();
- *
  * @deprecated since 2.5
- * @see cm_info::get_formatted_content()
- * @see cm_info::get_formatted_name()
  */
-function get_print_section_cm_text(cm_info $cm, $course) {
+function get_print_section_cm_text() {
     throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '.
             'cm_info::get_formatted_content() and cm_info::get_formatted_name()');
 }
 
 /**
- * Deprecated. Please use:
- * $courserenderer = $PAGE->get_renderer('core', 'course');
- * $output = $courserenderer->course_section_add_cm_control($course, $section, $sectionreturn,
- *    array('inblock' => $vertical));
- * echo $output;
- *
  * @deprecated since 2.5
- * @see core_course_renderer::course_section_add_cm_control()
  */
-function print_section_add_menus($course, $section, $modnames = null, $vertical=false, $return=false, $sectionreturn=null) {
+function print_section_add_menus() {
     throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '.
             'function course_section_add_cm_control()');
 }
 
 /**
- * Deprecated. Please use:
+ * @deprecated since 2.5. Please use:
  * $courserenderer = $PAGE->get_renderer('core', 'course');
  * $actions = course_get_cm_edit_actions($mod, $indent, $section);
  * return ' ' . $courserenderer->course_section_cm_edit_actions($actions);
- *
- * @deprecated since 2.5
- * @see course_get_cm_edit_actions()
- * @see core_course_renderer->course_section_cm_edit_actions()
  */
-function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $moveselect = true, $indent=-1, $section=null) {
+function make_editing_buttons() {
     throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '.
             'lib/deprecatedlib.php on how to replace it');
 }
 
 /**
- * Deprecated. Please use:
- * $courserenderer = $PAGE->get_renderer('core', 'course');
- * echo $courserenderer->course_section_cm_list($course, $section, $sectionreturn,
- *     array('hidecompletion' => $hidecompletion));
- *
  * @deprecated since 2.5
- * @see core_course_renderer::course_section_cm_list()
  */
-function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%", $hidecompletion=false, $sectionreturn=null) {
+function print_section() {
     throw new coding_exception('Function print_section() is removed. Please use course renderer function '.
             'course_section_cm_list() instead.');
 }
@@ -1276,14 +1081,14 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
 /**
  * @deprecated since 2.5
  */
-function print_overview($courses, array $remote_courses=array()) {
+function print_overview() {
     throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information');
 }
 
 /**
  * @deprecated since 2.5
  */
-function print_recent_activity($course) {
+function print_recent_activity() {
     throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'.
             ' use it outside of block_recent_activity');
 }
@@ -1291,28 +1096,22 @@ function print_recent_activity($course) {
 /**
  * @deprecated since 2.5
  */
-function delete_course_module($id) {
+function delete_course_module() {
     throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.');
 }
 
 /**
  * @deprecated since 2.5
  */
-function update_category_button($categoryid = 0) {
+function update_category_button() {
     throw new coding_exception('Function update_category_button() is removed. Pages to view '.
             'and edit courses are now separate and no longer depend on editing mode.');
 }
 
 /**
- * This function is deprecated! For list of categories use
- * coursecat::make_all_categories($requiredcapability, $excludeid, $separator)
- * For parents of one particular category use
- * coursecat::get($id)->get_parents()
- *
  * @deprecated since 2.5
  */
-function make_categories_list(&$list, &$parents, $requiredcapability = '',
-        $excludeid = 0, $category = NULL, $path = "") {
+function make_categories_list() {
     throw new coding_exception('Global function make_categories_list() is removed. Please use '.
             'coursecat::make_categories_list() and coursecat::get_parents()');
 }
@@ -1320,329 +1119,179 @@ function make_categories_list(&$list, &$parents, $requiredcapability = '',
 /**
  * @deprecated since 2.5
  */
-function category_delete_move($category, $newparentid, $showfeedback=true) {
+function category_delete_move() {
     throw new coding_exception('Function category_delete_move() is removed. Please use coursecat::delete_move() instead.');
 }
 
 /**
  * @deprecated since 2.5
  */
-function category_delete_full($category, $showfeedback=true) {
+function category_delete_full() {
     throw new coding_exception('Function category_delete_full() is removed. Please use coursecat::delete_full() instead.');
 }
 
 /**
- * This function is deprecated. Please use
- * $coursecat = coursecat::get($category->id);
- * if ($coursecat->can_change_parent($newparentcat->id)) {
- *     $coursecat->change_parent($newparentcat->id);
- * }
- *
- * Alternatively you can use
- * $coursecat->update(array('parent' => $newparentcat->id));
- *
- * @see coursecat::change_parent()
- * @see coursecat::update()
  * @deprecated since 2.5
  */
-function move_category($category, $newparentcat) {
+function move_category() {
     throw new coding_exception('Function move_category() is removed. Please use coursecat::change_parent() instead.');
 }
 
 /**
- * This function is deprecated. Please use
- * coursecat::get($category->id)->hide();
- *
- * @see coursecat::hide()
  * @deprecated since 2.5
  */
-function course_category_hide($category) {
+function course_category_hide() {
     throw new coding_exception('Function course_category_hide() is removed. Please use coursecat::hide() instead.');
 }
 
 /**
- * This function is deprecated. Please use
- * coursecat::get($category->id)->show();
- *
- * @see coursecat::show()
  * @deprecated since 2.5
  */
-function course_category_show($category) {
+function course_category_show() {
     throw new coding_exception('Function course_category_show() is removed. Please use coursecat::show() instead.');
 }
 
 /**
- * This function is deprecated.
- * To get the category with the specified it please use:
- * coursecat::get($catid, IGNORE_MISSING);
- * or
- * coursecat::get($catid, MUST_EXIST);
- *
- * To get the first available category please use
- * coursecat::get_default();
- *
- * @deprecated since 2.5
+ * @deprecated since 2.5. Please use coursecat::get($catid, IGNORE_MISSING) or coursecat::get($catid, MUST_EXIST).
  */
-function get_course_category($catid=0) {
+function get_course_category() {
     throw new coding_exception('Function get_course_category() is removed. Please use coursecat::get(), see phpdocs for more details');
 }
 
 /**
- * This function is deprecated. It is replaced with the method create() in class coursecat.
- * {@link coursecat::create()} also verifies the data, fixes sortorder and logs the action
- *
  * @deprecated since 2.5
  */
-function create_course_category($category) {
-    throw new coding_exception('Function create_course_category() is removed. Please use coursecat::create(), see phpdocs for more details');
+function create_course_category() {
+    throw new coding_exception('Function create_course_category() is removed. Please use coursecat::create()');
 }
 
 /**
- * This function is deprecated.
- *
- * To get visible children categories of the given category use:
- * coursecat::get($categoryid)->get_children();
- * This function will return the array or coursecat objects, on each of them
- * you can call get_children() again
- *
- * @see coursecat::get()
- * @see coursecat::get_children()
- *
- * @deprecated since 2.5
+ * @deprecated since 2.5. Please use coursecat::get() and coursecat::get_children()
  */
-function get_all_subcategories($catid) {
-    throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() of coursecat
-            class. See phpdocs for more details');
+function get_all_subcategories() {
+    throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() ' .
+            'of coursecat class.');
 }
 
 /**
- * This function is deprecated. Please use functions in class coursecat:
- * - coursecat::get($parentid)->has_children()
- * tells if the category has children (visible or not to the current user)
- *
- * - coursecat::get($parentid)->get_children()
- * returns an array of coursecat objects, each of them represents a children category visible
- * to the current user (i.e. visible=1 or user has capability to view hidden categories)
- *
- * - coursecat::get($parentid)->get_children_count()
- * returns number of children categories visible to the current user
- *
- * - coursecat::count_all()
- * returns total count of all categories in the system (both visible and not)
- *
- * - coursecat::get_default()
- * returns the first category (usually to be used if count_all() == 1)
- *
- * @deprecated since 2.5
+ * @deprecated since 2.5. Please use coursecat::get($parentid)->get_children().
  */
-function get_child_categories($parentid) {
-    throw new coding_exception('Function get_child_categories() is removed. Use coursecat::get_children() or see phpdocs for
-            more details.');
+function get_child_categories() {
+    throw new coding_exception('Function get_child_categories() is removed. Use coursecat::get_children().');
 }
 
 /**
- *
  * @deprecated since 2.5
- *
- * This function is deprecated. Use appropriate functions from class coursecat.
- * Examples:
- *
- * coursecat::get($categoryid)->get_children()
- * - returns all children of the specified category as instances of class
- * coursecat, which means on each of them method get_children() can be called again.
- * Only categories visible to the current user are returned.
- *
- * coursecat::get(0)->get_children()
- * - returns all top-level categories visible to the current user.
- *
- * Sort fields can be specified, see phpdocs to {@link coursecat::get_children()}
- *
- * coursecat::make_categories_list()
- * - returns an array of all categories id/names in the system.
- * Also only returns categories visible to current user and can additionally be
- * filetered by capability, see phpdocs to {@link coursecat::make_categories_list()}
- *
- * make_categories_options()
- * - Returns full course categories tree to be used in html_writer::select()
- *
- * Also see functions {@link coursecat::get_children_count()}, {@link coursecat::count_all()},
- * {@link coursecat::get_default()}
  */
-function get_categories($parent='none', $sort=NULL, $shallow=true) {
-    throw new coding_exception('Function get_categories() is removed. Please use coursecat::get_children() or see phpdocs for other alternatives');
+function get_categories() {
+    throw new coding_exception('Function get_categories() is removed. Please use ' .
+            'appropriate functions from class coursecat');
 }
 
 /**
-* This function is deprecated, please use course renderer:
-* $renderer = $PAGE->get_renderer('core', 'course');
-* echo $renderer->course_search_form($value, $format);
-*
 * @deprecated since 2.5
 */
-function print_course_search($value="", $return=false, $format="plain") {
+function print_course_search() {
     throw new coding_exception('Function print_course_search() is removed, please use course renderer');
 }
 
 /**
- * This function is deprecated, please use:
- * $renderer = $PAGE->get_renderer('core', 'course');
- * echo $renderer->frontpage_my_courses()
- *
  * @deprecated since 2.5
  */
 function print_my_moodle() {
-    throw new coding_exception('Function print_my_moodle() is removed, please use course renderer function frontpage_my_courses()');
+    throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' .
+            'function frontpage_my_courses()');
 }
 
 /**
- * This function is deprecated, it is replaced with protected function
- * {@link core_course_renderer::frontpage_remote_course()}
- * It is only used from function {@link core_course_renderer::frontpage_my_courses()}
- *
  * @deprecated since 2.5
  */
-function print_remote_course($course, $width="100%") {
+function print_remote_course() {
     throw new coding_exception('Function print_remote_course() is removed, please use course renderer');
 }
 
 /**
- * This function is deprecated, it is replaced with protected function
- * {@link core_course_renderer::frontpage_remote_host()}
- * It is only used from function {@link core_course_renderer::frontpage_my_courses()}
- *
  * @deprecated since 2.5
  */
-function print_remote_host($host, $width="100%") {
+function print_remote_host() {
     throw new coding_exception('Function print_remote_host() is removed, please use course renderer');
 }
 
 /**
  * @deprecated since 2.5
- *
- * See http://docs.moodle.org/dev/Courses_lists_upgrade_to_2.5
  */
-function print_whole_category_list($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1, $showcourses = true, $categorycourses=NULL) {
+function print_whole_category_list() {
     throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer');
 }
 
 /**
  * @deprecated since 2.5
  */
-function print_category_info($category, $depth = 0, $showcourses = false, array $courses = null) {
+function print_category_info() {
     throw new coding_exception('Function print_category_info() is removed, please use course renderer');
 }
 
 /**
  * @deprecated since 2.5
- *
- * This function is not used any more in moodle core and course renderer does not have render function for it.
- * Combo list on the front page is displayed as:
- * $renderer = $PAGE->get_renderer('core', 'course');
- * echo $renderer->frontpage_combo_list()
- *
- * The new class {@link coursecat} stores the information about course category tree
- * To get children categories use:
- * coursecat::get($id)->get_children()
- * To get list of courses use:
- * coursecat::get($id)->get_courses()
- *
- * See http://docs.moodle.org/dev/Courses_lists_upgrade_to_2.5
  */
-function get_course_category_tree($id = 0, $depth = 0) {
-    throw new coding_exception('Function get_course_category_tree() is removed, please use course renderer or coursecat class,
-            see function phpdocs for more info');
+function get_course_category_tree() {
+    throw new coding_exception('Function get_course_category_tree() is removed, please use course ' .
+            'renderer or coursecat class, see function phpdocs for more info');
 }
 
 /**
  * @deprecated since 2.5
- *
- * To print a generic list of courses use:
- * $renderer = $PAGE->get_renderer('core', 'course');
- * echo $renderer->courses_list($courses);
- *
- * To print list of all courses:
- * $renderer = $PAGE->get_renderer('core', 'course');
- * echo $renderer->frontpage_available_courses();
- *
- * To print list of courses inside category:
- * $renderer = $PAGE->get_renderer('core', 'course');
- * echo $renderer->course_category($category); // this will also print subcategories
  */
-function print_courses($category) {
+function print_courses() {
     throw new coding_exception('Function print_courses() is removed, please use course renderer');
 }
 
 /**
  * @deprecated since 2.5
- *
- * Please use course renderer to display a course information box.
- * $renderer = $PAGE->get_renderer('core', 'course');
- * echo $renderer->courses_list($courses); // will print list of courses
- * echo $renderer->course_info_box($course); // will print one course wrapped in div.generalbox
  */
-function print_course($course, $highlightterms = '') {
+function print_course() {
     throw new coding_exception('Function print_course() is removed, please use course renderer');
 }
 
 /**
  * @deprecated since 2.5
- *
- * This function is not used any more in moodle core and course renderer does not have render function for it.
- * Combo list on the front page is displayed as:
- * $renderer = $PAGE->get_renderer('core', 'course');
- * echo $renderer->frontpage_combo_list()
- *
- * The new class {@link coursecat} stores the information about course category tree
- * To get children categories use:
- * coursecat::get($id)->get_children()
- * To get list of courses use:
- * coursecat::get($id)->get_courses()
  */
-function get_category_courses_array($categoryid = 0) {
+function get_category_courses_array() {
     throw new coding_exception('Function get_category_courses_array() is removed, please use methods of coursecat class');
 }
 
 /**
  * @deprecated since 2.5
  */
-function get_category_courses_array_recursively(array &$flattened, $category) {
+function get_category_courses_array_recursively() {
     throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use methods of coursecat class', DEBUG_DEVELOPER);
 }
 
 /**
  * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
  */
-function blog_get_context_url($context=null) {
+function blog_get_context_url() {
     throw new coding_exception('Function  blog_get_context_url() is removed, getting params from context is not reliable for blogs.');
 }
 
 /**
  * @deprecated since 2.5
- *
- * To get list of all courses with course contacts ('managers') use
- * coursecat::get(0)->get_courses(array('recursive' => true, 'coursecontacts' => true));
- *
- * To get list of courses inside particular category use
- * coursecat::get($id)->get_courses(array('coursecontacts' => true));
- *
- * Additionally you can specify sort order, offset and maximum number of courses,
- * see {@link coursecat::get_courses()}
  */
-function get_courses_wmanagers($categoryid=0, $sort="c.sortorder ASC", $fields=array()) {
+function get_courses_wmanagers() {
     throw new coding_exception('Function get_courses_wmanagers() is removed, please use coursecat::get_courses()');
 }
 
 /**
  * @deprecated since 2.5
  */
-function convert_tree_to_html($tree, $row=0) {
+function convert_tree_to_html() {
     throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()');
 }
 
 /**
  * @deprecated since 2.5
  */
-function convert_tabrows_to_tree($tabrows, $selected, $inactive, $activated) {
+function convert_tabrows_to_tree() {
     throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree');
 }
 
@@ -1655,9 +1304,8 @@ function can_use_rotated_text() {
 
 /**
  * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
- * @see context::instance_by_id($id)
  */
-function get_context_instance_by_id($id, $strictness = IGNORE_MISSING) {
+function get_context_instance_by_id() {
     throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.');
 }
 
@@ -1675,39 +1323,34 @@ function get_system_context($cache = true) {
 }
 
 /**
- * @see context::get_parent_context_ids()
  * @deprecated since 2.2, use $context->get_parent_context_ids() instead
  */
-function get_parent_contexts(context $context, $includeself = false) {
+function get_parent_contexts() {
     throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.');
 }
 
 /**
  * @deprecated since Moodle 2.2
- * @see context::get_parent_context()
  */
-function get_parent_contextid(context $context) {
+function get_parent_contextid() {
     throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.');
 }
 
 /**
- * @see context::get_child_contexts()
  * @deprecated since 2.2
  */
-function get_child_contexts(context $context) {
+function get_child_contexts() {
     throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.');
 }
 
 /**
- * @see context_helper::create_instances()
  * @deprecated since 2.2
  */
-function create_contexts($contextlevel = null, $buildpaths = true) {
+function create_contexts() {
     throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.');
 }
 
 /**
- * @see context_helper::cleanup_instances()
  * @deprecated since 2.2
  */
 function cleanup_contexts() {
@@ -1715,178 +1358,143 @@ function cleanup_contexts() {
 }
 
 /**
- * Populate context.path and context.depth where missing.
- *
  * @deprecated since 2.2
  */
-function build_context_path($force = false) {
+function build_context_path() {
     throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.');
 }
 
 /**
  * @deprecated since 2.2
  */
-function rebuild_contexts(array $fixcontexts) {
+function rebuild_contexts() {
     throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.');
 }
 
 /**
  * @deprecated since Moodle 2.2
- * @see context_helper::preload_course()
  */
-function preload_course_contexts($courseid) {
+function preload_course_contexts() {
     throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.');
 }
 
 /**
  * @deprecated since Moodle 2.2
- * @see context::update_moved()
  */
-function context_moved(context $context, context $newparent) {
+function context_moved() {
     throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.');
 }
 
 /**
- * @see context::get_capabilities()
  * @deprecated since 2.2
  */
-function fetch_context_capabilities(context $context) {
+function fetch_context_capabilities() {
     throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.');
 }
 
 /**
  * @deprecated since 2.2
- * @see context_helper::preload_from_record()
  */
-function context_instance_preload(stdClass $rec) {
+function context_instance_preload() {
     throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.');
 }
 
 /**
- * Returns context level name
- *
  * @deprecated since 2.2
- * @see context_helper::get_level_name()
  */
-function get_contextlevel_name($contextlevel) {
+function get_contextlevel_name() {
     throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.');
 }
 
 /**
  * @deprecated since 2.2
- * @see context::get_context_name()
  */
-function print_context_name(context $context, $withprefix = true, $short = false) {
+function print_context_name() {
     throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.');
 }
 
 /**
  * @deprecated since 2.2, use $context->mark_dirty() instead
- * @see context::mark_dirty()
  */
-function mark_context_dirty($path) {
+function mark_context_dirty() {
     throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.');
 }
 
 /**
  * @deprecated since Moodle 2.2
- * @see context_helper::delete_instance() or context::delete_content()
  */
-function delete_context($contextlevel, $instanceid, $deleterecord = true) {
-    if ($deleterecord) {
-        throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() instead.');
-    } else {
-        throw new coding_exception('delete_context() is removed, please use $context->delete_content() instead.');
-    }
+function delete_context() {
+    throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' .
+            'or $context->delete_content() instead.');
 }
 
 /**
  * @deprecated since 2.2
- * @see context::get_url()
  */
-function get_context_url(context $context) {
+function get_context_url() {
     throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.');
 }
 
 /**
  * @deprecated since 2.2
- * @see context::get_course_context()
  */
-function get_course_context(context $context) {
+function get_course_context() {
     throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.');
 }
 
 /**
  * @deprecated since 2.2
- * @see enrol_get_users_courses()
  */
-function get_user_courses_bycap($userid, $cap, $accessdata_ignored, $doanything_ignored, $sort = 'c.sortorder ASC', $fields = null, $limit_ignored = 0) {
-
+function get_user_courses_bycap() {
     throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.');
 }
 
 /**
  * @deprecated since Moodle 2.2
  */
-function get_role_context_caps($roleid, context $context) {
+function get_role_context_caps() {
     throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.');
 }
 
 /**
- * @see context::get_course_context()
  * @deprecated since 2.2
  */
-function get_courseid_from_context(context $context) {
+function get_courseid_from_context() {
     throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.');
 }
 
 /**
- * If you are using this methid, you should have something like this:
- *
- *    list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
- *
- * To prevent the use of this deprecated function, replace the line above with something similar to this:
- *
- *    $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
- *                                                                        ^
- *    $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
- *                                    ^       ^                ^        ^
- *    $params = array('contextlevel' => CONTEXT_COURSE);
- *                                      ^
- * @see context_helper:;get_preload_record_columns_sql()
  * @deprecated since 2.2
  */
-function context_instance_preload_sql($joinon, $contextlevel, $tablealias) {
+function context_instance_preload_sql() {
     throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.');
 }
 
 /**
  * @deprecated since 2.2
- * @see context::get_parent_context_ids()
  */
-function get_related_contexts_string(context $context) {
+function get_related_contexts_string() {
     throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.');
 }
 
 /**
  * @deprecated since 2.6
- * @see core_component::get_plugin_list_with_file()
  */
-function get_plugin_list_with_file($plugintype, $file, $include = false) {
+function get_plugin_list_with_file() {
     throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.');
 }
 
 /**
  * @deprecated since 2.6
  */
-function check_browser_operating_system($brand) {
+function check_browser_operating_system() {
     throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.');
 }
 
 /**
  * @deprecated since 2.6
  */
-function check_browser_version($brand, $version = null) {
+function check_browser_version() {
     throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.');
 }
 
@@ -1900,28 +1508,28 @@ function get_device_type() {
 /**
  * @deprecated since 2.6
  */
-function get_device_type_list($incusertypes = true) {
+function get_device_type_list() {
     throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.');
 }
 
 /**
  * @deprecated since 2.6
  */
-function get_selected_theme_for_device_type($devicetype = null) {
+function get_selected_theme_for_device_type() {
     throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.');
 }
 
 /**
  * @deprecated since 2.6
  */
-function get_device_cfg_var_name($devicetype = null) {
+function get_device_cfg_var_name() {
     throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.');
 }
 
 /**
  * @deprecated since 2.6
  */
-function set_user_device_type($newdevice) {
+function set_user_device_type() {
     throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.');
 }
 
@@ -1941,7 +1549,6 @@ function get_browser_version_classes() {
 
 /**
  * @deprecated since Moodle 2.6
- * @see core_user::get_support_user()
  */
 function generate_email_supportuser() {
     throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user');
@@ -1950,7 +1557,7 @@ function generate_email_supportuser() {
 /**
  * @deprecated since Moodle 2.6
  */
-function badges_get_issued_badge_info($hash) {
+function badges_get_issued_badge_info() {
     throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.');
 }
 
@@ -1965,21 +1572,21 @@ function can_use_html_editor() {
 /**
  * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
  */
-function count_login_failures($mode, $username, $lastlogin) {
+function count_login_failures() {
     throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
 }
 
 /**
  * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more.
  */
-function ajaxenabled(array $browsers = null) {
+function ajaxenabled() {
     throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.');
 }
 
 /**
  * @deprecated Since Moodle 2.7 MDL-44070
  */
-function coursemodule_visible_for_user($cm, $userid=0) {
+function coursemodule_visible_for_user() {
     throw new coding_exception('coursemodule_visible_for_user() can not be used any more,
             please use \core_availability\info_module::is_user_visible()');
 }
@@ -1987,27 +1594,22 @@ function coursemodule_visible_for_user($cm, $userid=0) {
 /**
  * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed
  */
-function enrol_cohort_get_cohorts(course_enrolment_manager $manager) {
-    throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use enrol_cohort_search_cohorts() or '.
+function enrol_cohort_get_cohorts() {
+    throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '.
         'cohort_get_available_cohorts() instead');
 }
 
 /**
- * This function is deprecated, use {@link cohort_can_view_cohort()} instead since it also
- * takes into account current context
- *
  * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
  */
-function enrol_cohort_can_view_cohort($cohortid) {
+function enrol_cohort_can_view_cohort() {
     throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead');
 }
 
 /**
- * It is advisable to use {@link cohort_get_available_cohorts()} instead.
- *
  * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead
  */
-function cohort_get_visible_list($course, $onlyenrolled=true) {
+function cohort_get_visible_list() {
     throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ".
         "that correctly checks capabilities.');
 }
@@ -2015,78 +1617,64 @@ function cohort_get_visible_list($course, $onlyenrolled=true) {
 /**
  * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
  */
-function enrol_cohort_enrol_all_users(course_enrolment_manager $manager, $cohortid, $roleid) {
+function enrol_cohort_enrol_all_users() {
     throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.');
 }
 
 /**
  * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
  */
-function enrol_cohort_search_cohorts(course_enrolment_manager $manager, $offset = 0, $limit = 25, $search = '') {
+function enrol_cohort_search_cohorts() {
     throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.');
 }
 
 /* === Apis deprecated in since Moodle 2.9 === */
 
 /**
- * Is $USER one of the supplied users?
- *
- * $user2 will be null if viewing a user's recent conversations
- *
  * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more.
  */
-function message_current_user_is_involved($user1, $user2) {
+function message_current_user_is_involved() {
     throw new coding_exception('message_current_user_is_involved() can not be used any more.');
 }
 
 /**
- * Print badges on user profile page.
- *
  * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
  */
-function profile_display_badges($userid, $courseid = 0) {
+function profile_display_badges() {
     throw new coding_exception('profile_display_badges() can not be used any more.');
 }
 
 /**
- * Adds user preferences elements to user edit form.
- *
  * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more.
  */
-function useredit_shared_definition_preferences($user, &$mform, $editoroptions = null, $filemanageroptions = null) {
+function useredit_shared_definition_preferences() {
     throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.');
 }
 
 
 /**
- * Convert region timezone to php supported timezone
- *
  * @deprecated since Moodle 2.9
  */
-function calendar_normalize_tz($tz) {
+function calendar_normalize_tz() {
     throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.');
 }
 
 /**
- * Returns a float which represents the user's timezone difference from GMT in hours
- * Checks various settings and picks the most dominant of those which have a value
  * @deprecated since Moodle 2.9
  */
-function get_user_timezone_offset($tz = 99) {
+function get_user_timezone_offset() {
     throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
 
 }
 
 /**
- * Returns an int which represents the systems's timezone difference from GMT in seconds
  * @deprecated since Moodle 2.9
  */
-function get_timezone_offset($tz) {
+function get_timezone_offset() {
     throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
 }
 
 /**
- * Returns a list of timezones in the current language.
  * @deprecated since Moodle 2.9
  */
 function get_list_of_timezones() {
@@ -2094,34 +1682,30 @@ function get_list_of_timezones() {
 }
 
 /**
- * Previous internal API, it was not supposed to be used anywhere.
  * @deprecated since Moodle 2.9
  */
-function update_timezone_records($timezones) {
+function update_timezone_records() {
     throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead');
 }
 
 /**
- * Previous internal API, it was not supposed to be used anywhere.
  * @deprecated since Moodle 2.9
  */
-function calculate_user_dst_table($fromyear = null, $toyear = null, $strtimezone = null) {
+function calculate_user_dst_table() {
     throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead');
 }
 
 /**
- * Previous internal API, it was not supposed to be used anywhere.
  * @deprecated since Moodle 2.9
  */
-function dst_changes_for_year($year, $timezone) {
+function dst_changes_for_year() {
     throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead');
 }
 
 /**
- * Previous internal API, it was not supposed to be used anywhere.
  * @deprecated since Moodle 2.9
  */
-function get_timezone_record($timezonename) {
+function get_timezone_record() {
     throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead');
 }
 
@@ -2129,7 +1713,7 @@ function get_timezone_record($timezonename) {
 /**
  * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more.
  */
-function get_referer($stripquery = true) {
+function get_referer() {
     throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.');
 }
 
@@ -2150,15 +1734,17 @@ function completion_cron() {
 /**
  * @deprecated since 3.0
  */
-function coursetag_get_tags($courseid, $userid=0, $tagtype='', $numtags=0, $unused = '') {
-    throw new coding_exception('Function coursetag_get_tags() can not be used any more. Userid is no longer used for tagging courses.');
+function coursetag_get_tags() {
+    throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' .
+            'Userid is no longer used for tagging courses.');
 }
 
 /**
  * @deprecated since 3.0
  */
-function coursetag_get_all_tags($unused='', $numtags=0) {
-    throw new coding_exception('Function coursetag_get_all_tag() can not be used any more. Userid is no longer used for tagging courses.');
+function coursetag_get_all_tags() {
+    throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' .
+        'longer used for tagging courses.');
 }
 
 /**
@@ -2171,1969 +1757,520 @@ function coursetag_get_jscript() {
 /**
  * @deprecated since 3.0
  */
-function coursetag_get_jscript_links($elementid, $coursetagslinks) {
+function coursetag_get_jscript_links() {
     throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.');
 }
 
 /**
  * @deprecated since 3.0
  */
-function coursetag_get_records($courseid, $userid) {
-    throw new coding_exception('Function coursetag_get_records() can not be used any more. Userid is no longer used for tagging courses.');
+function coursetag_get_records() {
+    throw new coding_exception('Function coursetag_get_records() can not be used any more. ' .
+            'Userid is no longer used for tagging courses.');
 }
 
 /**
  * @deprecated since 3.0
  */
-function coursetag_store_keywords($tags, $courseid, $userid=0, $tagtype='official', $myurl='') {
-    throw new coding_exception('Function coursetag_store_keywords() can not be used any more. Userid is no longer used for tagging courses.');
+function coursetag_store_keywords() {
+    throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' .
+            'Userid is no longer used for tagging courses.');
 }
 
 /**
  * @deprecated since 3.0
  */
-function coursetag_delete_keyword($tagid, $userid, $courseid) {
-    throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. Userid is no longer used for tagging courses.');
+function coursetag_delete_keyword() {
+    throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' .
+            'Userid is no longer used for tagging courses.');
 }
 
 /**
  * @deprecated since 3.0
  */
-function coursetag_get_tagged_courses($tagid) {
-    throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. Userid is no longer used for tagging courses.');
+function coursetag_get_tagged_courses() {
+    throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' .
+            'Userid is no longer used for tagging courses.');
 }
 
 /**
  * @deprecated since 3.0
  */
-function coursetag_delete_course_tags($courseid, $showfeedback=false) {
-    throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. Use core_tag_tag::remove_all_item_tags().');
+function coursetag_delete_course_tags() {
+    throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' .
+            'Use core_tag_tag::remove_all_item_tags().');
 }
 
 /**
- * Set the type of a tag.  At this time (version 2.2) the possible values are 'default' or 'official'.  Official tags will be
- * displayed separately "at tagging time" (while selecting the tags to apply to a record).
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    string   $tagid tagid to modify
- * @param    string   $type either 'default' or 'official'
- * @return   bool     true on success, false otherwise
+ * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
  */
-function tag_type_set($tagid, $type) {
-    debugging('Function tag_type_set() is deprecated and can be replaced with use core_tag_tag::get($tagid)->update().', DEBUG_DEVELOPER);
-    if ($tag = core_tag_tag::get($tagid, '*')) {
-        return $tag->update(array('isstandard' => ($type === 'official') ? 1 : 0));
-    }
-    return false;
+function tag_type_set() {
+    throw new coding_exception('tag_type_set() can not be used anymore. Please use ' .
+        'core_tag_tag::get($tagid)->update().');
 }
 
 /**
- * Set the description of a tag
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    int      $tagid the id of the tag
- * @param    string   $description the tag's description string to be set
- * @param    int      $descriptionformat the moodle text format of the description
- *                    {@link http://docs.moodle.org/dev/Text_formats_2.0#Database_structure}
- * @return   bool     true on success, false otherwise
+ * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
  */
-function tag_description_set($tagid, $description, $descriptionformat) {
-    debugging('Function tag_type_set() is deprecated and can be replaced with core_tag_tag::get($tagid)->update().', DEBUG_DEVELOPER);
-    if ($tag = core_tag_tag::get($tagid, '*')) {
-        return $tag->update(array('description' => $description, 'descriptionformat' => $descriptionformat));
-    }
-    return false;
+function tag_description_set() {
+    throw new coding_exception('tag_description_set() can not be used anymore. Please use ' .
+        'core_tag_tag::get($tagid)->update().');
 }
 
 /**
- * Get the array of db record of tags associated to a record (instances).
- *
- * @package core_tag
- * @deprecated since 3.1
- * @param string $record_type the record type for which we want to get the tags
- * @param int $record_id the record id for which we want to get the tags
- * @param string $type the tag type (either 'default' or 'official'). By default, all tags are returned.
- * @param int $userid (optional) only required for course tagging
- * @return array the array of tags
+ * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
  */
-function tag_get_tags($record_type, $record_id, $type=null, $userid=0) {
-    debugging('Method tag_get_tags() is deprecated and replaced with core_tag_tag::get_item_tags(). ' .
-        'Component is now required when retrieving tag instances.', DEBUG_DEVELOPER);
-    $standardonly = ($type === 'official' ? core_tag_tag::STANDARD_ONLY :
-        (!empty($type) ? core_tag_tag::NOT_STANDARD_ONLY : core_tag_tag::BOTH_STANDARD_AND_NOT));
-    $tags = core_tag_tag::get_item_tags(null, $record_type, $record_id, $standardonly, $userid);
-    $rv = array();
-    foreach ($tags as $id => $t) {
-        $rv[$id] = $t->to_object();
-    }
-    return $rv;
+function tag_get_tags() {
+    throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' .
+        'core_tag_tag::get_item_tags().');
 }
 
 /**
- * Get the array of tags display names, indexed by id.
- *
- * @package  core_tag
  * @deprecated since 3.1
- * @param    string $record_type the record type for which we want to get the tags
- * @param    int    $record_id   the record id for which we want to get the tags
- * @param    string $type        the tag type (either 'default' or 'official'). By default, all tags are returned.
- * @return   array  the array of tags (with the value returned by core_tag_tag::make_display_name), indexed by id
  */
-function tag_get_tags_array($record_type, $record_id, $type=null) {
-    debugging('Method tag_get_tags_array() is deprecated and replaced with core_tag_tag::get_item_tags_array(). ' .
-        'Component is now required when retrieving tag instances.', DEBUG_DEVELOPER);
-    $standardonly = ($type === 'official' ? core_tag_tag::STANDARD_ONLY :
-        (!empty($type) ? core_tag_tag::NOT_STANDARD_ONLY : core_tag_tag::BOTH_STANDARD_AND_NOT));
-    return core_tag_tag::get_item_tags_array('', $record_type, $record_id, $standardonly);
+function tag_get_tags_array() {
+    throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' .
+        'core_tag_tag::get_item_tags_array().');
 }
 
 /**
- * Get a comma-separated string of tags associated to a record.
- *
- * Use {@link tag_get_tags()} to get the same information in an array.
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    string   $record_type the record type for which we want to get the tags
- * @param    int      $record_id   the record id for which we want to get the tags
- * @param    int      $html        either TAG_RETURN_HTML or TAG_RETURN_TEXT, depending on the type of output desired
- * @param    string   $type        either 'official' or 'default', if null, all tags are returned
- * @return   string   the comma-separated list of tags.
+ * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags())
  */
-function tag_get_tags_csv($record_type, $record_id, $html=null, $type=null) {
-    global $CFG, $OUTPUT;
-    debugging('Method tag_get_tags_csv() is deprecated. Instead you should use either ' .
-            'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()). ' .
-        'Component is now required when retrieving tag instances.', DEBUG_DEVELOPER);
-    $standardonly = ($type === 'official' ? core_tag_tag::STANDARD_ONLY :
-        (!empty($type) ? core_tag_tag::NOT_STANDARD_ONLY : core_tag_tag::BOTH_STANDARD_AND_NOT));
-    if ($html != TAG_RETURN_TEXT) {
-        return $OUTPUT->tag_list(core_tag_tag::get_item_tags('', $record_type, $record_id, $standardonly), '');
-    } else {
-        return join(', ', core_tag_tag::get_item_tags_array('', $record_type, $record_id, $standardonly, 0, false));
-    }
+function tag_get_tags_csv() {
+    throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' .
+        'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
 }
 
 /**
- * Get an array of tag ids associated to a record.
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    string    $record_type the record type for which we want to get the tags
- * @param    int       $record_id the record id for which we want to get the tags
- * @return   array     tag ids, indexed and sorted by 'ordering'
- */
-function tag_get_tags_ids($record_type, $record_id) {
-    debugging('Method tag_get_tags_ids() is deprecated. Please consider using core_tag_tag::get_item_tags() or similar methods.', DEBUG_DEVELOPER);
-    $tag_ids = array();
-    $tagobjects = core_tag_tag::get_item_tags(null, $record_type, $record_id);
-    foreach ($tagobjects as $tagobject) {
-        $tag = $tagobject->to_object();
-        if ( array_key_exists($tag->ordering, $tag_ids) ) {
-            $tag->ordering++;
-        }
-        $tag_ids[$tag->ordering] = $tag->id;
-    }
-    ksort($tag_ids);
-    return $tag_ids;
+ * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
+ */
+function tag_get_tags_ids() {
+    throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' .
+        'core_tag_tag::get_item_tags() or similar methods.');
 }
 
 /**
- * Returns the database ID of a set of tags.
- *
- * @deprecated since 3.1
- * @param    mixed $tags one tag, or array of tags, to look for.
- * @param    bool  $return_value specify the type of the returned value. Either TAG_RETURN_OBJECT, or TAG_RETURN_ARRAY (default).
- *                               If TAG_RETURN_ARRAY is specified, an array will be returned even if only one tag was passed in $tags.
- * @return   mixed tag-indexed array of ids (or objects, if second parameter is TAG_RETURN_OBJECT), or only an int, if only one tag
- *                 is given *and* the second parameter is null. No value for a key means the tag wasn't found.
+ * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()
  */
-function tag_get_id($tags, $return_value = null) {
-    global $CFG, $DB;
-    debugging('Method tag_get_id() is deprecated and can be replaced with core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk(). ' .
-        'You need to specify tag collection when retrieving tag by name', DEBUG_DEVELOPER);
-
-    if (!is_array($tags)) {
-        if(is_null($return_value) || $return_value == TAG_RETURN_OBJECT) {
-            if ($tagobject = core_tag_tag::get_by_name(core_tag_collection::get_default(), $tags)) {
-                return $tagobject->id;
-            } else {
-                return 0;
-            }
-        }
-        $tags = array($tags);
-    }
-
-    $records = core_tag_tag::get_by_name_bulk(core_tag_collection::get_default(), $tags,
-        $return_value == TAG_RETURN_OBJECT ? '*' : 'id, name');
-    foreach ($records as $name => $record) {
-        if ($return_value != TAG_RETURN_OBJECT) {
-            $records[$name] = $record->id ? $record->id : null;
-        } else {
-            $records[$name] = $record->to_object();
-        }
-    }
-    return $records;
+function tag_get_id() {
+    throw new coding_exception('tag_get_id() can not be used anymore. Please use ' .
+        'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()');
 }
 
 /**
- * Change the "value" of a tag, and update the associated 'name'.
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    int      $tagid  the id of the tag to modify
- * @param    string   $newrawname the new rawname
- * @return   bool     true on success, false otherwise
+ * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
  */
-function tag_rename($tagid, $newrawname) {
-    debugging('Function tag_rename() is deprecated and may be replaced with core_tag_tag::get($tagid)->update().', DEBUG_DEVELOPER);
-    if ($tag = core_tag_tag::get($tagid, '*')) {
-        return $tag->update(array('rawname' => $newrawname));
-    }
-    return false;
+function tag_rename() {
+    throw new coding_exception('tag_rename() can not be used anymore. Please use ' .
+        'core_tag_tag::get($tagid)->update()');
 }
 
 /**
- * Delete one instance of a tag.  If the last instance was deleted, it will also delete the tag, unless its type is 'official'.
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    string $record_type the type of the record for which to remove the instance
- * @param    int    $record_id   the id of the record for which to remove the instance
- * @param    int    $tagid       the tagid that needs to be removed
- * @param    int    $userid      (optional) the userid
- * @return   bool   true on success, false otherwise
+ * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead
  */
-function tag_delete_instance($record_type, $record_id, $tagid, $userid = null) {
-    debugging('Function tag_delete_instance() is deprecated and replaced with core_tag_tag::remove_item_tag() instead. ' .
-        'Component is required for retrieving instances', DEBUG_DEVELOPER);
-    $tag = core_tag_tag::get($tagid);
-    core_tag_tag::remove_item_tag('', $record_type, $record_id, $tag->rawname, $userid);
+function tag_delete_instance() {
+    throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' .
+        'core_tag_tag::remove_item_tag()');
 }
 
 /**
- * Find all records tagged with a tag of a given type ('post', 'user', etc.)
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @category tag
- * @param    string   $tag       tag to look for
- * @param    string   $type      type to restrict search to.  If null, every matching record will be returned
- * @param    int      $limitfrom (optional, required if $limitnum is set) return a subset of records, starting at this point.
- * @param    int      $limitnum  (optional, required if $limitfrom is set) return a subset comprising this many records.
- * @return   array of matching objects, indexed by record id, from the table containing the type requested
+ * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead
  */
-function tag_find_records($tag, $type, $limitfrom='', $limitnum='') {
-    debugging('Function tag_find_records() is deprecated and replaced with core_tag_tag::get_by_name()->get_tagged_items(). '.
-        'You need to specify tag collection when retrieving tag by name', DEBUG_DEVELOPER);
-
-    if (!$tag || !$type) {
-        return array();
-    }
-
-    $tagobject = core_tag_tag::get_by_name(core_tag_area::get_collection('', $type), $tag);
-    return $tagobject->get_tagged_items('', $type, $limitfrom, $limitnum);
+function tag_find_records() {
+    throw new coding_exception('tag_find_records() can not be used anymore. Please use ' .
+        'core_tag_tag::get_by_name()->get_tagged_items()');
 }
 
 /**
- * Adds one or more tag in the database.  This function should not be called directly : you should
- * use tag_set.
- *
- * @package core_tag
  * @deprecated since 3.1
- * @param   mixed    $tags     one tag, or an array of tags, to be created
- * @param   string   $type     type of tag to be created ("default" is the default value and "official" is the only other supported
- *                             value at this time). An official tag is kept even if there are no records tagged with it.
- * @return array     $tags ids indexed by their lowercase normalized names. Any boolean false in the array indicates an error while
- *                             adding the tag.
- */
-function tag_add($tags, $type="default") {
-    debugging('Function tag_add() is deprecated. You can use core_tag_tag::create_if_missing(), however it should not be necessary ' .
-        'since tags are created automatically when assigned to items', DEBUG_DEVELOPER);
-    if (!is_array($tags)) {
-        $tags = array($tags);
-    }
-    $objects = core_tag_tag::create_if_missing(core_tag_collection::get_default(), $tags,
-            $type === 'official');
-
-    // New function returns the tags in different format, for BC we keep the format that this function used to have.
-    $rv = array();
-    foreach ($objects as $name => $tagobject) {
-        if (isset($tagobject->id)) {
-            $rv[$tagobject->name] = $tagobject->id;
-        } else {
-            $rv[$name] = false;
-        }
-    }
-    return $rv;
+ */
+function tag_add() {
+    throw new coding_exception('tag_add() can not be used anymore. You can use ' .
+        'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' .
+        'created automatically when assigned to items');
 }
 
 /**
- * Assigns a tag to a record; if the record already exists, the time and ordering will be updated.
- *
- * @package core_tag
- * @deprecated since 3.1
- * @param string $record_type the type of the record that will be tagged
- * @param int $record_id the id of the record that will be tagged
- * @param string $tagid the tag id to set on the record.
- * @param int $ordering the order of the instance for this record
- * @param int $userid (optional) only required for course tagging
- * @param string|null $component the component that was tagged
- * @param int|null $contextid the context id of where this tag was assigned
- * @return bool true on success, false otherwise
- */
-function tag_assign($record_type, $record_id, $tagid, $ordering, $userid = 0, $component = null, $contextid = null) {
-    global $DB;
-    $message = 'Function tag_assign() is deprecated. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. ' .
-        'Tag instance ordering should not be set manually';
-    if ($component === null || $contextid === null) {
-        $message .= '. You should specify the component and contextid of the item being tagged in your call to tag_assign.';
-    }
-    debugging($message, DEBUG_DEVELOPER);
+ * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead
+ */
+function tag_assign() {
+    throw new coding_exception('tag_assign() can not be used anymore. Please use ' .
+        'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' .
+        'ordering should not be set manually');
+}
 
-    if ($contextid) {
-        $context = context::instance_by_id($contextid);
-    } else {
-        $context = context_system::instance();
-    }
+/**
+ * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead
+ */
+function tag_record_count() {
+    throw new coding_exception('tag_record_count() can not be used anymore. Please use ' .
+        'core_tag_tag::get($tagid)->count_tagged_items().');
+}
 
-    // Get the tag.
-    $tag = $DB->get_record('tag', array('id' => $tagid), 'name, rawname', MUST_EXIST);
+/**
+ * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead
+ */
+function tag_record_tagged_with() {
+    throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' .
+        'core_tag_tag::get($tagid)->is_item_tagged_with().');
+}
 
-    $taginstanceid = core_tag_tag::add_item_tag($component, $record_type, $record_id, $context, $tag->rawname, $userid);
+/**
+ * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead
+ */
+function tag_set_flag() {
+    throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' .
+        'core_tag_tag::get($tagid)->flag()');
+}
 
-    // Alter the "ordering" of tag_instance. This should never be done manually and only remains here for the backward compatibility.
-    $taginstance = new stdClass();
-    $taginstance->id = $taginstanceid;
-    $taginstance->ordering     = $ordering;
-    $taginstance->timemodified = time();
+/**
+ * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead
+ */
+function tag_unset_flag() {
+    throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' .
+        'core_tag_tag::get($tagid)->reset_flag()');
+}
 
-    $DB->update_record('tag_instance', $taginstance);
+/**
+ * @deprecated since 3.1
+ */
+function tag_print_cloud() {
+    throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' .
+        'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' .
+        'template core_tag/tagcloud.');
+}
 
-    return true;
+/**
+ * @deprecated since 3.0
+ */
+function tag_autocomplete() {
+    throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' .
+        'element "tags" does proper autocomplete.');
 }
 
 /**
- * Count how many records are tagged with a specific tag.
- *
- * @package core_tag
  * @deprecated since 3.1
- * @param   string   $record_type record to look for ('post', 'user', etc.)
- * @param   int      $tagid       is a single tag id
- * @return  int      number of mathing tags.
  */
-function tag_record_count($record_type, $tagid) {
-    debugging('Method tag_record_count() is deprecated and replaced with core_tag_tag::get($tagid)->count_tagged_items(). '.
-        'Component is now required when retrieving tag instances.', DEBUG_DEVELOPER);
-    return core_tag_tag::get($tagid)->count_tagged_items('', $record_type);
+function tag_print_description_box() {
+    throw new coding_exception('tag_print_description_box() can not be used anymore. ' .
+        'See core_tag_renderer for similar code');
 }
 
 /**
- * Determine if a record is tagged with a specific tag
- *
- * @package core_tag
  * @deprecated since 3.1
- * @param   string   $record_type the record type to look for
- * @param   int      $record_id   the record id to look for
- * @param   string   $tag         a tag name
- * @return  bool/int true if it is tagged, 0 (false) otherwise
  */
-function tag_record_tagged_with($record_type, $record_id, $tag) {
-    debugging('Method tag_record_tagged_with() is deprecated and replaced with core_tag_tag::get($tagid)->is_item_tagged_with(). '.
-        'Component is now required when retrieving tag instances.', DEBUG_DEVELOPER);
-    return core_tag_tag::is_item_tagged_with('', $record_type, $record_id, $tag);
+function tag_print_management_box() {
+    throw new coding_exception('tag_print_management_box() can not be used anymore. ' .
+        'See core_tag_renderer for similar code');
 }
 
 /**
- * Flag a tag as inappropriate.
- *
  * @deprecated since 3.1
- * @param int|array $tagids a single tagid, or an array of tagids
- */
-function tag_set_flag($tagids) {
-    debugging('Function tag_set_flag() is deprecated and replaced with core_tag_tag::get($tagid)->flag().', DEBUG_DEVELOPER);
-    $tagids = (array) $tagids;
-    foreach ($tagids as $tagid) {
-        if ($tag = core_tag_tag::get($tagid, '*')) {
-            $tag->flag();
-        }
-    }
+ */
+function tag_print_search_box() {
+    throw new coding_exception('tag_print_search_box() can not be used anymore. ' .
+        'See core_tag_renderer for similar code');
 }
 
 /**
- * Remove the inappropriate flag on a tag.
- *
  * @deprecated since 3.1
- * @param int|array $tagids a single tagid, or an array of tagids
- */
-function tag_unset_flag($tagids) {
-    debugging('Function tag_unset_flag() is deprecated and replaced with core_tag_tag::get($tagid)->reset_flag().', DEBUG_DEVELOPER);
-    $tagids = (array) $tagids;
-    foreach ($tagids as $tagid) {
-        if ($tag = core_tag_tag::get($tagid, '*')) {
-            $tag->reset_flag();
-        }
-    }
+ */
+function tag_print_search_results() {
+    throw new coding_exception('tag_print_search_results() can not be used anymore. ' .
+        'In /tag/search.php the search results are printed using the core_tag/tagcloud template.');
 }
 
 /**
- * Prints or returns a HTML tag cloud with varying classes styles depending on the popularity and type of each tag.
- *
  * @deprecated since 3.1
- *
- * @param    array     $tagset Array of tags to display
- * @param    int       $nr_of_tags Limit for the number of tags to return/display, used if $tagset is null
- * @param    bool      $return     if true the function will return the generated tag cloud instead of displaying it.
- * @param    string    $sort (optional) selected sorting, default is alpha sort (name) also timemodified or popularity
- * @return string|null a HTML string or null if this function does the output
  */
-function tag_print_cloud($tagset=null, $nr_of_tags=150, $return=false, $sort='') {
-    global $OUTPUT;
-
-    debugging('Function tag_print_cloud() is deprecated and replaced with function core_tag_collection::get_tag_cloud(), '
-            . 'templateable core_tag\output\tagcloud and template core_tag/tagcloud.', DEBUG_DEVELOPER);
+function tag_print_tagged_users_table() {
+    throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' .
+        'See core_user_renderer for similar code');
+}
 
-    // Set up sort global - used to pass sort type into core_tag_collection::cloud_sort through usort() avoiding multiple sort functions.
-    if ($sort == 'popularity') {
-        $sort = 'count';
-    } else if ($sort == 'date') {
-        $sort = 'timemodified';
-    } else {
-        $sort = 'name';
-    }
+/**
+ * @deprecated since 3.1
+ */
+function tag_print_user_box() {
+    throw new coding_exception('tag_print_user_box() can not be used anymore. ' .
+        'See core_user_renderer for similar code');
+}
 
-    if (is_null($tagset)) {
-        // No tag set received, so fetch tags from database.
-        // Always add query by tagcollid even when it's not known to make use of the table index.
-        $tagcloud = core_tag_collection::get_tag_cloud(0, false, $nr_of_tags, $sort);
-    } else {
-        $tagsincloud = $tagset;
+/**
+ * @deprecated since 3.1
+ */
+function tag_print_user_list() {
+    throw new coding_exception('tag_print_user_list() can not be used anymore. ' .
+        'See core_user_renderer for similar code');
+}
 
-        $etags = array();
-        foreach ($tagsincloud as $tag) {
-            $etags[] = $tag;
-        }
+/**
+ * @deprecated since 3.1
+ */
+function tag_display_name() {
+    throw new coding_exception('tag_display_name() can not be used anymore. Please use ' .
+        'core_tag_tag::make_display_name().');
 
-        core_tag_collection::$cloudsortfield = $sort;
-        usort($tagsincloud, "core_tag_collection::cloud_sort");
+}
 
-        $tagcloud = new \core_tag\output\tagcloud($tagsincloud);
-    }
+/**
+ * @deprecated since 3.1
+ */
+function tag_normalize() {
+    throw new coding_exception('tag_normalize() can not be used anymore. Please use ' .
+        'core_tag_tag::normalize().');
+}
 
-    $output = $OUTPUT->render_from_template('core_tag/tagcloud', $tagcloud->export_for_template($OUTPUT));
-    if ($return) {
-        return $output;
-    } else {
-        echo $output;
-    }
+/**
+ * @deprecated since 3.1
+ */
+function tag_get_related_tags_csv() {
+    throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' .
+        'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
 }
 
 /**
- * Function that returns tags that start with some text, for use by the autocomplete feature
- *
- * @package core_tag
- * @deprecated since 3.0
- * @access  private
- * @param   string   $text string that the tag names will be matched against
- * @return  mixed    an array of objects, or false if no records were found or an error occured.
+ * @deprecated since 3.1
  */
-function tag_autocomplete($text) {
-    debugging('Function tag_autocomplete() is deprecated without replacement. ' .
-            'New form element "tags" does proper autocomplete.', DEBUG_DEVELOPER);
-    global $DB;
-    return $DB->get_records_sql("SELECT tg.id, tg.name, tg.rawname
-                                   FROM {tag} tg
-                                  WHERE tg.name LIKE ?", array(core_text::strtolower($text)."%"));
+function tag_set() {
+    throw new coding_exception('tag_set() can not be used anymore. Please use ' .
+        'core_tag_tag::set_item_tags().');
 }
 
 /**
- * Prints a box with the description of a tag and its related tags
- *
- * @package core_tag
  * @deprecated since 3.1
- * @param   stdClass    $tag_object
- * @param   bool        $return     if true the function will return the generated tag cloud instead of displaying it.
- * @return  string/null a HTML box showing a description of the tag object and it's relationsips or null if output is done directly
- *                      in the function.
  */
-function tag_print_description_box($tag_object, $return=false) {
-    global $USER, $CFG, $OUTPUT;
-    require_once($CFG->libdir.'/filelib.php');
-
-    debugging('Function tag_print_description_box() is deprecated without replacement. ' .
-            'See core_tag_renderer for similar code.', DEBUG_DEVELOPER);
-
-    $relatedtags = array();
-    if ($tag = core_tag_tag::get($tag_object->id)) {
-        $relatedtags = $tag->get_related_tags();
-    }
-
-    $content = !empty($tag_object->description);
-    $output = '';
-
-    if ($content) {
-        $output .= $OUTPUT->box_start('generalbox tag-description');
-    }
-
-    if (!empty($tag_object->description)) {
-        $options = new stdClass();
-        $options->para = false;
-        $options->overflowdiv = true;
-        $tag_object->description = file_rewrite_pluginfile_urls($tag_object->description, 'pluginfile.php', context_system::instance()->id, 'tag', 'description', $tag_object->id);
-        $output .= format_text($tag_object->description, $tag_object->descriptionformat, $options);
-    }
-
-    if ($content) {
-        $output .= $OUTPUT->box_end();
-    }
-
-    if ($relatedtags) {
-        $output .= $OUTPUT->tag_list($relatedtags, get_string('relatedtags', 'tag'), 'tag-relatedtags');
-    }
-
-    if ($return) {
-        return $output;
-    } else {
-        echo $output;
-    }
-}
+function tag_set_add() {
+    throw new coding_exception('tag_set_add() can not be used anymore. Please use ' .
+        'core_tag_tag::add_item_tag().');
+}
 
 /**
- * Prints a box that contains the management links of a tag
- *
  * @deprecated since 3.1
- * @param  core_tag_tag|stdClass    $tag_object
- * @param  bool        $return     if true the function will return the generated tag cloud instead of displaying it.
- * @return string|null a HTML string or null if this function does the output
- */
-function tag_print_management_box($tag_object, $return=false) {
-    global $USER, $CFG, $OUTPUT;
-
-    debugging('Function tag_print_description_box() is deprecated without replacement. ' .
-            'See core_tag_renderer for similar code.', DEBUG_DEVELOPER);
-
-    $tagname  = core_tag_tag::make_display_name($tag_object);
-    $output = '';
-
-    if (!isguestuser()) {
-        $output .= $OUTPUT->box_start('box','tag-management-box');
-        $systemcontext   = context_system::instance();
-        $links = array();
-
-        // Add a link for users to add/remove this from their interests
-        if (core_tag_tag::is_enabled('core', 'user') && core_tag_area::get_collection('core', 'user') == $tag_object->tagcollid) {
-            if (core_tag_tag::is_item_tagged_with('core', 'user', $USER->id, $tag_object->name)) {
-                $links[] = '<a href="'. $CFG->wwwroot .'/tag/user.php?action=removeinterest&amp;sesskey='. sesskey() .
-                        '&amp;tag='. rawurlencode($tag_object->name) .'">'.
-                        get_string('removetagfrommyinterests', 'tag', $tagname) .'</a>';
-            } else {
-                $links[] = '<a href="'. $CFG->wwwroot .'/tag/user.php?action=addinterest&amp;sesskey='. sesskey() .
-                        '&amp;tag='. rawurlencode($tag_object->name) .'">'.
-                        get_string('addtagtomyinterests', 'tag', $tagname) .'</a>';
-            }
-        }
-
-        // Flag as inappropriate link.  Only people with moodle/tag:flag capability.
-        if (has_capability('moodle/tag:flag', $systemcontext)) {
-            $links[] = '<a href="'. $CFG->wwwroot .'/tag/user.php?action=flaginappropriate&amp;sesskey='.
-                    sesskey() . '&amp;id='. $tag_object->id . '">'. get_string('flagasinappropriate',
-                            'tag', rawurlencode($tagname)) .'</a>';
-        }
-
-        // Edit tag: Only people with moodle/tag:edit capability who either have it as an interest or can manage tags
-        if (has_capability('moodle/tag:edit', $systemcontext) ||
-            has_capability('moodle/tag:manage', $systemcontext)) {
-            $links[] = '<a href="' . $CFG->wwwroot . '/tag/edit.php?id=' . $tag_object->id . '">' .
-                    get_string('edittag', 'tag') . '</a>';
-        }
-
-        $output .= implode(' | ', $links);
-        $output .= $OUTPUT->box_end();
-    }
-
-    if ($return) {
-        return $output;
-    } else {
-        echo $output;
-    }
-}
-
-/**
- * Prints the tag search box
- *
- * @deprecated since 3.1
- * @param  bool        $return if true return html string
- * @return string|null a HTML string or null if this function does the output
  */
-function tag_print_search_box($return=false) {
-    global $CFG, $OUTPUT;
-
-    debugging('Function tag_print_search_box() is deprecated without replacement. ' .
-            'See core_tag_renderer for similar code.', DEBUG_DEVELOPER);
-
-    $query = optional_param('query', '', PARAM_RAW);
-
-    $output = $OUTPUT->box_start('','tag-search-box');
-    $output .= '<form action="'.$CFG->wwwroot.'/tag/search.php" style="display:inline">';
-    $output .= '<div>';
-    $output .= '<label class="accesshide" for="searchform_search">'.get_string('searchtags', 'tag').'</label>';
-    $output .= '<input id="searchform_search" name="query" type="text" size="40" value="'.s($query).'" />';
-    $output .= '<button id="searchform_button" type="submit">'. get_string('search', 'tag') .'</button><br />';
-    $output .= '</div>';
-    $output .= '</form>';
-    $output .= $OUTPUT->box_end();
-
-    if ($return) {
-        return $output;
-    }
-    else {
-        echo $output;
-    }
+function tag_set_delete() {
+    throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' .
+        'core_tag_tag::remove_item_tag().');
 }
 
 /**
- * Prints the tag search results
- *
  * @deprecated since 3.1
- * @param string       $query text that tag names will be matched against
- * @param int          $page current page
- * @param int          $perpage nr of users displayed per page
- * @param bool         $return if true return html string
- * @return string|null a HTML string or null if this function does the output
  */
-function tag_print_search_results($query,  $page, $perpage, $return=false) {
-    global $CFG, $USER, $OUTPUT;
-
-    debugging('Function tag_print_search_results() is deprecated without replacement. ' .
-            'In /tag/search.php the search results are printed using the core_tag/tagcloud template.', DEBUG_DEVELOPER);
-
-    $query = clean_param($query, PARAM_TAG);
-
-    $count = count(tag_find_tags($query, false));
-    $tags = array();
-
-    if ( $found_tags = tag_find_tags($query, true,  $page * $perpage, $perpage) ) {
-        $tags = array_values($found_tags);
-    }
-
-    $baseurl = $CFG->wwwroot.'/tag/search.php?query='. rawurlencode($query);
-    $output = '';
-
-    // link "Add $query to my interests"
-    $addtaglink = '';
-    if (core_tag_tag::is_enabled('core', 'user') && !core_tag_tag::is_item_tagged_with('core', 'user', $USER->id, $query)) {
-        $addtaglink = html_writer::link(new moodle_url('/tag/user.php', array('action' => 'addinterest', 'sesskey' => sesskey(),
-            'tag' => $query)), get_string('addtagtomyinterests', 'tag', s($query)));
-    }
-
-    if ( !empty($tags) ) { // there are results to display!!
-        $output .= $OUTPUT->heading(get_string('searchresultsfor', 'tag', htmlspecialchars($query)) ." : {$count}", 3, 'main');
-
-        //print a link "Add $query to my interests"
-        if (!empty($addtaglink)) {
-            $output .= $OUTPUT->box($addtaglink, 'box', 'tag-management-box');
-        }
-
-        $nr_of_lis_per_ul = 6;
-        $nr_of_uls = ceil( sizeof($tags) / $nr_of_lis_per_ul );
-
-        $output .= '<ul id="tag-search-results">';
-        for($i = 0; $i < $nr_of_uls; $i++) {
-            foreach (array_slice($tags, $i * $nr_of_lis_per_ul, $nr_of_lis_per_ul) as $tag) {
-                $output .= '<li>';
-                $tag_link = html_writer::link(core_tag_tag::make_url($tag->tagcollid, $tag->rawname),
-                    core_tag_tag::make_display_name($tag));
-                $output .= $tag_link;
-                $output .= '</li>';
-            }
-        }
-        $output .= '</ul>';
-        $output .= '<div>&nbsp;</div>'; // <-- small layout hack in order to look good in Firefox
-
-        $output .= $OUTPUT->paging_bar($count, $page, $perpage, $baseurl);
-    }
-    else { //no results were found!!
-        $output .= $OUTPUT->heading(get_string('noresultsfor', 'tag', htmlspecialchars($query)), 3, 'main');
-
-        //print a link "Add $query to my interests"
-        if (!empty($addtaglink)) {
-            $output .= $OUTPUT->box($addtaglink, 'box', 'tag-management-box');
-        }
-    }
-
-    if ($return) {
-        return $output;
-    }
-    else {
-        echo $output;
-    }
+function tag_get() {
+    throw new coding_exception('tag_get() can not be used anymore. Please use ' .
+        'core_tag_tag::get() or core_tag_tag::get_by_name().');
 }
 
 /**
- * Prints a table of the users tagged with the tag passed as argument
- *
  * @deprecated since 3.1
- * @param  stdClass    $tagobject the tag we wish to return data for
- * @param  int         $limitfrom (optional, required if $limitnum is set) prints users starting at this point.
- * @param  int         $limitnum (optional, required if $limitfrom is set) prints this many users.
- * @param  bool        $return if true return html string
- * @return string|null a HTML string or null if this function does the output
  */
-function tag_print_tagged_users_table($tagobject, $limitfrom='', $limitnum='', $return=false) {
-
-    debugging('Function tag_print_tagged_users_table() is deprecated without replacement. ' .
-            'See core_user_renderer for similar code.', DEBUG_DEVELOPER);
-
-    //List of users with this tag
-    $tagobject = core_tag_tag::get($tagobject->id);
-    $userlist = $tagobject->get_tagged_items('core', 'user', $limitfrom, $limitnum);
-
-    $output = tag_print_user_list($userlist, true);
-
-    if ($return) {
-        return $output;
-    }
-    else {
-        echo $output;
-    }
-}
-
-/**
- * Prints an individual user box
- *
- * @deprecated since 3.1
- * @param user_object  $user  (contains the following fields: id, firstname, lastname and picture)
- * @param bool         $return if true return html string
- * @return string|null a HTML string or null if this function does the output
- */
-function tag_print_user_box($user, $return=false) {
-    global $CFG, $OUTPUT;
-
-    debugging('Function tag_print_user_box() is deprecated without replacement. ' .
-            'See core_user_renderer for similar code.', DEBUG_DEVELOPER);
-
-    $usercontext = context_user::instance($user->id);
-    $profilelink = '';
-
-    if ($usercontext and (has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($user->id))) {
-        $profilelink = $CFG->wwwroot .'/user/view.php?id='. $user->id;
-    }
-
-    $output = $OUTPUT->box_start('user-box', 'user'. $user->id);
-    $fullname = fullname($user);
-    $alt = '';
-
-    if (!empty($profilelink)) {
-        $output .= '<a href="'. $profilelink .'">';
-        $alt = $fullname;
-    }
-
-    $output .= $OUTPUT->user_picture($user, array('size'=>100));
-    $output .= '<br />';
-
-    if (!empty($profilelink)) {
-        $output .= '</a>';
-    }
-
-    //truncate name if it's too big
-    if (core_text::strlen($fullname) > 26) {
-        $fullname = core_text::substr($fullname, 0, 26) .'...';
-    }
-
-    $output .= '<strong>'. $fullname .'</strong>';
-    $output .= $OUTPUT->box_end();
-
-    if ($return) {
-        return $output;
-    }
-    else {
-        echo $output;
-    }
-}
-
-/**
- * Prints a list of users
- *
- * @deprecated since 3.1
- * @param  array       $userlist an array of user objects
- * @param  bool        $return if true return html string, otherwise output the result
- * @return string|null a HTML string or null if this function does the output
- */
-function tag_print_user_list($userlist, $return=false) {
-
-    debugging('Function tag_print_user_list() is deprecated without replacement. ' .
-            'See core_user_renderer for similar code.', DEBUG_DEVELOPER);
-
-    $output = '<div><ul class="inline-list">';
-
-    foreach ($userlist as $user){
-        $output .= '<li>'. tag_print_user_box($user, true) ."</li>\n";
-    }
-    $output .= "</ul></div>\n";
-
-    if ($return) {
-        return $output;
-    }
-    else {
-        echo $output;
-    }
+function tag_get_related_tags() {
+    throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' .
+        'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' .
+        'core_tag_tag::get_manual_related_tags().');
 }
 
 /**
- * Function that returns the name that should be displayed for a specific tag
- *
- * @package  core_tag
- * @category tag
  * @deprecated since 3.1
- * @param    stdClass|core_tag_tag   $tagobject a line out of tag table, as returned by the adobd functions
- * @param    int      $html TAG_RETURN_HTML (default) will return htmlspecialchars encoded string, TAG_RETURN_TEXT will not encode.
- * @return   string
  */
-function tag_display_name($tagobject, $html=TAG_RETURN_HTML) {
-    debugging('Function tag_display_name() is deprecated. Use core_tag_tag::make_display_name().', DEBUG_DEVELOPER);
-    if (!isset($tagobject->name)) {
-        return '';
-    }
-    return core_tag_tag::make_display_name($tagobject, $html != TAG_RETURN_TEXT);
+function tag_delete() {
+    throw new coding_exception('tag_delete() can not be used anymore. Please use ' .
+        'core_tag_tag::delete_tags().');
 }
 
 /**
- * Function that normalizes a list of tag names.
- *
- * @package core_tag
  * @deprecated since 3.1
- * @param   array/string $rawtags array of tags, or a single tag.
- * @param   int          $case    case to use for returned value (default: lower case). Either TAG_CASE_LOWER (default) or TAG_CASE_ORIGINAL
- * @return  array        lowercased normalized tags, indexed by the normalized tag, in the same order as the original array.
- *                       (Eg: 'Banana' => 'banana').
  */
-function tag_normalize($rawtags, $case = TAG_CASE_LOWER) {
-    debugging('Function tag_normalize() is deprecated. Use core_tag_tag::normalize().', DEBUG_DEVELOPER);
-
-    if ( !is_array($rawtags) ) {
-        $rawtags = array($rawtags);
-    }
-
-    return core_tag_tag::normalize($rawtags, $case == TAG_CASE_LOWER);
-}
-
-/**
- * Get a comma-separated list of tags related to another tag.
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    array    $related_tags the array returned by tag_get_related_tags
- * @param    int      $html    either TAG_RETURN_HTML (default) or TAG_RETURN_TEXT : return html links, or just text.
- * @return   string   comma-separated list
- */
-function tag_get_related_tags_csv($related_tags, $html=TAG_RETURN_HTML) {
-    global $OUTPUT;
-    debugging('Method tag_get_related_tags_csv() is deprecated. Consider '
-            . 'looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags())',
-        DEBUG_DEVELOPER);
-    if ($html != TAG_RETURN_TEXT) {
-        return $OUTPUT->tag_list($related_tags, '');
-    }
-
-    $tagsnames = array();
-    foreach ($related_tags as $tag) {
-        $tagsnames[] = core_tag_tag::make_display_name($tag, false);
-    }
-    return implode(', ', $tagsnames);
+function tag_delete_instances() {
+    throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' .
+        'core_tag_tag::delete_instances().');
 }
 
 /**
- * Used to require that the return value from a function is an array.
- * Only used in the deprecated function {@link tag_get_id()}
- * @deprecated since 3.1
- */
-define('TAG_RETURN_ARRAY', 0);
-/**
- * Used to require that the return value from a function is an object.
- * Only used in the deprecated function {@link tag_get_id()}
- * @deprecated since 3.1
- */
-define('TAG_RETURN_OBJECT', 1);
-/**
- * Use to specify that HTML free text is expected to be returned from a function.
- * Only used in deprecated functions {@link tag_get_tags_csv()}, {@link tag_display_name()},
- * {@link tag_get_related_tags_csv()}
- * @deprecated since 3.1
- */
-define('TAG_RETURN_TEXT', 2);
-/**
- * Use to specify that encoded HTML is expected to be returned from a function.
- * Only used in deprecated functions {@link tag_get_tags_csv()}, {@link tag_display_name()},
- * {@link tag_get_related_tags_csv()}
- * @deprecated since 3.1
- */
-define('TAG_RETURN_HTML', 3);
-
-/**
- * Used to specify that we wish a lowercased string to be returned
- * Only used in deprecated function {@link tag_normalize()}
- * @deprecated since 3.1
- */
-define('TAG_CASE_LOWER', 0);
-/**
- * Used to specify that we do not wish the case of the returned string to change
- * Only used in deprecated function {@link tag_normalize()}
- * @deprecated since 3.1
- */
-define('TAG_CASE_ORIGINAL', 1);
-
-/**
- * Used to specify that we want all related tags returned, no matter how they are related.
- * Only used in deprecated function {@link tag_get_related_tags()}
- * @deprecated since 3.1
- */
-define('TAG_RELATED_ALL', 0);
-/**
- * Used to specify that we only want back tags that were manually related.
- * Only used in deprecated function {@link tag_get_related_tags()}
- * @deprecated since 3.1
- */
-define('TAG_RELATED_MANUAL', 1);
-/**
- * Used to specify that we only want back tags where the relationship was automatically correlated.
- * Only used in deprecated function {@link tag_get_related_tags()}
- * @deprecated since 3.1
- */
-define('TAG_RELATED_CORRELATED', 2);
-
-/**
- * Set the tags assigned to a record.  This overwrites the current tags.
- *
- * This function is meant to be fed the string coming up from the user interface, which contains all tags assigned to a record.
- *
- * Due to API change $component and $contextid are now required. Instead of
- * calling  this function you can use {@link core_tag_tag::set_item_tags()} or
- * {@link core_tag_tag::set_related_tags()}
- *
- * @package core_tag
- * @deprecated since 3.1
- * @param string $itemtype the type of record to tag ('post' for blogs, 'user' for users, 'tag' for tags, etc.)
- * @param int $itemid the id of the record to tag
- * @param array $tags the array of tags to set on the record. If given an empty array, all tags will be removed.
- * @param string|null $component the component that was tagged
- * @param int|null $contextid the context id of where this tag was assigned
- * @return bool|null
- */
-function tag_set($itemtype, $itemid, $tags, $component = null, $contextid = null) {
-    debugging('Function tag_set() is deprecated. Use ' .
-        ' core_tag_tag::set_item_tags() instead', DEBUG_DEVELOPER);
-
-    if ($itemtype === 'tag') {
-        return core_tag_tag::get($itemid, '*', MUST_EXIST)->set_related_tags($tags);
-    } else {
-        $context = $contextid ? context::instance_by_id($contextid) : context_system::instance();
-        return core_tag_tag::set_item_tags($component, $itemtype, $itemid, $context, $tags);
-    }
-}
-
-/**
- * Adds a tag to a record, without overwriting the current tags.
- *
- * This function remains here for backward compatiblity. It is recommended to use
- * {@link core_tag_tag::add_item_tag()} or {@link core_tag_tag::add_related_tags()} instead
- *
- * @package core_tag
- * @deprecated since 3.1
- * @param string $itemtype the type of record to tag ('post' for blogs, 'user' for users, etc.)
- * @param int $itemid the id of the record to tag
- * @param string $tag the tag to add
- * @param string|null $component the component that was tagged
- * @param int|null $contextid the context id of where this tag was assigned
- * @return bool|null
- */
-function tag_set_add($itemtype, $itemid, $tag, $component = null, $contextid = null) {
-    debugging('Function tag_set_add() is deprecated. Use ' .
-        ' core_tag_tag::add_item_tag() instead', DEBUG_DEVELOPER);
-
-    if ($itemtype === 'tag') {
-        return core_tag_tag::get($itemid, '*', MUST_EXIST)->add_related_tags(array($tag));
-    } else {
-        $context = $contextid ? context::instance_by_id($contextid) : context_system::instance();
-        return core_tag_tag::add_item_tag($component, $itemtype, $itemid, $context, $tag);
-    }
-}
-
-/**
- * Removes a tag from a record, without overwriting other current tags.
- *
- * This function remains here for backward compatiblity. It is recommended to use
- * {@link core_tag_tag::remove_item_tag()} instead
- *
- * @package core_tag
- * @deprecated since 3.1
- * @param string $itemtype the type of record to tag ('post' for blogs, 'user' for users, etc.)
- * @param int $itemid the id of the record to tag
- * @param string $tag the tag to delete
- * @param string|null $component the component that was tagged
- * @param int|null $contextid the context id of where this tag was assigned
- * @return bool|null
- */
-function tag_set_delete($itemtype, $itemid, $tag, $component = null, $contextid = null) {
-    debugging('Function tag_set_delete() is deprecated. Use ' .
-        ' core_tag_tag::remove_item_tag() instead', DEBUG_DEVELOPER);
-    return core_tag_tag::remove_item_tag($component, $itemtype, $itemid, $tag);
-}
-
-/**
- * Simple function to just return a single tag object when you know the name or something
- *
- * See also {@link core_tag_tag::get()} and {@link core_tag_tag::get_by_name()}
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    string $field        which field do we use to identify the tag: id, name or rawname
- * @param    string $value        the required value of the aforementioned field
- * @param    string $returnfields which fields do we want returned. This is a comma seperated string containing any combination of
- *                                'id', 'name', 'rawname' or '*' to include all fields.
- * @return   mixed  tag object
- */
-function tag_get($field, $value, $returnfields='id, name, rawname, tagcollid') {
-    global $DB;
-    debugging('Function tag_get() is deprecated. Use ' .
-        ' core_tag_tag::get() or core_tag_tag::get_by_name()',
-        DEBUG_DEVELOPER);
-    if ($field === 'id') {
-        $tag = core_tag_tag::get((int)$value, $returnfields);
-    } else if ($field === 'name') {
-        $tag = core_tag_tag::get_by_name(0, $value, $returnfields);
-    } else {
-        $params = array($field => $value);
-        return $DB->get_record('tag', $params, $returnfields);
-    }
-    if ($tag) {
-        return $tag->to_object();
-    }
-    return null;
-}
-
-/**
- * Returns tags related to a tag
- *
- * Related tags of a tag come from two sources:
- *   - manually added related tags, which are tag_instance entries for that tag
- *   - correlated tags, which are calculated
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    string   $tagid          is a single **normalized** tag name or the id of a tag
- * @param    int      $type           the function will return either manually (TAG_RELATED_MANUAL) related tags or correlated
- *                                    (TAG_RELATED_CORRELATED) tags. Default is TAG_RELATED_ALL, which returns everything.
- * @param    int      $limitnum       (optional) return a subset comprising this many records, the default is 10
- * @return   array    an array of tag objects
- */
-function tag_get_related_tags($tagid, $type=TAG_RELATED_ALL, $limitnum=10) {
-    debugging('Method tag_get_related_tags() is deprecated, '
-        . 'use core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or '
-        . 'core_tag_tag::get_manual_related_tags()', DEBUG_DEVELOPER);
-    $result = array();
-    if ($tag = core_tag_tag::get($tagid)) {
-        if ($type == TAG_RELATED_CORRELATED) {
-            $tags = $tag->get_correlated_tags();
-        } else if ($type == TAG_RELATED_MANUAL) {
-            $tags = $tag->get_manual_related_tags();
-        } else {
-            $tags = $tag->get_related_tags();
-        }
-        $tags = array_slice($tags, 0, $limitnum);
-        foreach ($tags as $id => $tag) {
-            $result[$id] = $tag->to_object();
-        }
-    }
-    return $result;
-}
-
-/**
- * Delete one or more tag, and all their instances if there are any left.
- *
- * @package  core_tag
- * @deprecated since 3.1
- * @param    mixed    $tagids one tagid (int), or one array of tagids to delete
- * @return   bool     true on success, false otherwise
- */
-function tag_delete($tagids) {
-    debugging('Method tag_delete() is deprecated, use core_tag_tag::delete_tags()',
-        DEBUG_DEVELOPER);
-    return core_tag_tag::delete_tags($tagids);
-}
-
-/**
- * Deletes all the tag instances given a component and an optional contextid.
- *
- * @deprecated since 3.1
- * @param string $component
- * @param int $contextid if null, then we delete all tag instances for the $component
- */
-function tag_delete_instances($component, $contextid = null) {
-    debugging('Method tag_delete() is deprecated, use core_tag_tag::delete_instances()',
-        DEBUG_DEVELOPER);
-    core_tag_tag::delete_instances($component, null, $contextid);
-}
-
-/**
- * Clean up the tag tables, making sure all tagged object still exists.
- *
- * This should normally not be necessary, but in case related tags are not deleted when the tagged record is removed, this should be
- * done once in a while, perhaps on an occasional cron run.  On a site with lots of tags, this could become an expensive function to
- * call: don't run at peak time.
- *
- * @package core_tag
  * @deprecated since 3.1
  */
 function tag_cleanup() {
-    debugging('Method tag_cleanup() is deprecated, use \core\task\tag_cron_task::cleanup()',
-        DEBUG_DEVELOPER);
-
-    $task = new \core\task\tag_cron_task();
-    return $task->cleanup();
+    throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' .
+        '\core\task\tag_cron_task::cleanup().');
 }
 
 /**
- * This function will delete numerous tag instances efficiently.
- * This removes tag instances only. It doesn't check to see if it is the last use of a tag.
- *
  * @deprecated since 3.1
- * @param array $instances An array of tag instance objects with the addition of the tagname and tagrawname
- *        (used for recording a delete event).
  */
-function tag_bulk_delete_instances($instances) {
-    debugging('Method tag_bulk_delete_instances() is deprecated, '
-        . 'use \core\task\tag_cron_task::bulk_delete_instances()',
-        DEBUG_DEVELOPER);
+function tag_bulk_delete_instances() {
+    throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' .
+        '\core\task\tag_cron_task::bulk_delete_instances().');
 
-    $task = new \core\task\tag_cron_task();
-    return $task->bulk_delete_instances($instances);
 }
 
 /**
- * Calculates and stores the correlated tags of all tags. The correlations are stored in the 'tag_correlation' table.
- *
- * Two tags are correlated if they appear together a lot. Ex.: Users tagged with "computers" will probably also be tagged with "algorithms".
- *
- * The rationale for the 'tag_correlation' table is performance. It works as a cache for a potentially heavy load query done at the
- * 'tag_instance' table. So, the 'tag_correlation' table stores redundant information derived from the 'tag_instance' table.
- *
- * @package core_tag
  * @deprecated since 3.1
- * @param   int      $mincorrelation Only tags with more than $mincorrelation correlations will be identified.
  */
-function tag_compute_correlations($mincorrelation = 2) {
-    debugging('Method tag_compute_correlations() is deprecated, '
-        . 'use \core\task\tag_cron_task::compute_correlations()',
-        DEBUG_DEVELOPER);
-
-    $task = new \core\task\tag_cron_task();
-    return $task->compute_correlations($mincorrelation);
+function tag_compute_correlations() {
+    throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' .
+        'use \core\task\tag_cron_task::compute_correlations().');
 }
 
 /**
- * This function processes a tag correlation and makes changes in the database as required.
- *
- * The tag correlation object needs have both a tagid property and a correlatedtags property that is an array.
- *
- * @package core_tag
  * @deprecated since 3.1
- * @param   stdClass $tagcorrelation
- * @return  int/bool The id of the tag correlation that was just processed or false.
  */
-function tag_process_computed_correlation(stdClass $tagcorrelation) {
-    debugging('Method tag_process_computed_correlation() is deprecated, '
-        . 'use \core\task\tag_cron_task::process_computed_correlation()',
-        DEBUG_DEVELOPER);
-
-    $task = new \core\task\tag_cron_task();
-    return $task->process_computed_correlation($tagcorrelation);
+function tag_process_computed_correlation() {
+    throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' .
+        'use \core\task\tag_cron_task::process_computed_correlation().');
 }
 
 /**
- * Tasks that should be performed at cron time
- *
- * @package core_tag
  * @deprecated since 3.1
  */
 function tag_cron() {
-    debugging('Method tag_cron() is deprecated, use \core\task\tag_cron_task::execute()',
-        DEBUG_DEVELOPER);
-
-    $task = new \core\task\tag_cron_task();
-    $task->execute();
-}
-
-/**
- * Search for tags with names that match some text
- *
- * @package core_tag
- * @deprecated since 3.1
- * @param   string        $text      escaped string that the tag names will be matched against
- * @param   bool          $ordered   If true, tags are ordered by their popularity. If false, no ordering.
- * @param   int/string    $limitfrom (optional, required if $limitnum is set) return a subset of records, starting at this point.
- * @param   int/string    $limitnum  (optional, required if $limitfrom is set) return a subset comprising this many records.
- * @param   int           $tagcollid
- * @return  array/boolean an array of objects, or false if no records were found or an error occured.
- */
-function tag_find_tags($text, $ordered=true, $limitfrom='', $limitnum='', $tagcollid = null) {
-    debugging('Method tag_find_tags() is deprecated without replacement', DEBUG_DEVELOPER);
-    global $DB;
-
-    $text = core_text::strtolower(clean_param($text, PARAM_TAG));
-
-    list($sql, $params) = $DB->get_in_or_equal($tagcollid ? array($tagcollid) :
-        array_keys(core_tag_collection::get_collections(true)));
-    array_unshift($params, "%{$text}%");
-
-    if ($ordered) {
-        $query = "SELECT tg.id, tg.name, tg.rawname, tg.tagcollid, COUNT(ti.id) AS count
-                    FROM {tag} tg LEFT JOIN {tag_instance} ti ON tg.id = ti.tagid
-                   WHERE tg.name LIKE ? AND tg.tagcollid $sql
-                GROUP BY tg.id, tg.name, tg.rawname
-                ORDER BY count DESC";
-    } else {
-        $query = "SELECT tg.id, tg.name, tg.rawname, tg.tagcollid
-                    FROM {tag} tg
-                   WHERE tg.name LIKE ? AND tg.tagcollid $sql";
-    }
-    return $DB->get_records_sql($query, $params, $limitfrom , $limitnum);
-}
-
-/**
- * Get the name of a tag
- *
- * @package core_tag
- * @deprecated since 3.1
- * @param   mixed    $tagids the id of the tag, or an array of ids
- * @return  mixed    string name of one tag, or id-indexed array of strings
- */
-function tag_get_name($tagids) {
-    debugging('Method tag_get_name() is deprecated without replacement', DEBUG_DEVELOPER);
-    global $DB;
-
-    if (!is_array($tagids)) {
-        if ($tag = $DB->get_record('tag', array('id'=>$tagids))) {
-            return $tag->name;
-        }
-        return false;
-    }
-
-    $tag_names = array();
-    foreach($DB->get_records_list('tag', 'id', $tagids) as $tag) {
-        $tag_names[$tag->id] = $tag->name;
-    }
-
-    return $tag_names;
-}
-
-/**
- * Returns the correlated tags of a tag, retrieved from the tag_correlation table. Make sure cron runs, otherwise the table will be
- * empty and this function won't return anything.
- *
- * Correlated tags are calculated in cron based on existing tag instances.
- *
- * @package core_tag
- * @deprecated since 3.1
- * @param   int      $tagid   is a single tag id
- * @param   int      $notused  this argument is no longer used
- * @return  array    an array of tag objects or an empty if no correlated tags are found
- */
-function tag_get_correlated($tagid, $notused = null) {
-    debugging('Method tag_get_correlated() is deprecated, '
-        . 'use core_tag_tag::get_correlated_tags()', DEBUG_DEVELOPER);
-    $result = array();
-    if ($tag = core_tag_tag::get($tagid)) {
-        $tags = $tag->get_correlated_tags(true);
-        // Convert to objects for backward-compatibility.
-        foreach ($tags as $id => $tag) {
-            $result[$id] = $tag->to_object();
-        }
-    }
-    return $result;
+    throw new coding_exception('tag_cron() can not be used anymore. Please use ' .
+        'use \core\task\tag_cron_task::execute().');
 }
 
 /**
- * This function is used by print_tag_cloud, to usort() the tags in the cloud. See php.net/usort for the parameters documentation.
- * This was originally in blocks/blog_tags/block_blog_tags.php, named blog_tags_sort().
- *
- * @package core_tag
  * @deprecated since 3.1
- * @param   string $a Tag name to compare against $b
- * @param   string $b Tag name to compare against $a
- * @return  int    The result of the comparison/validation 1, 0 or -1
- */
-function tag_cloud_sort($a, $b) {
-    debugging('Method tag_cloud_sort() is deprecated, similar method can be found in core_tag_collection::cloud_sort()', DEBUG_DEVELOPER);
-    global $CFG;
-
-    if (empty($CFG->tagsort)) {
-        $tagsort = 'name'; // by default, sort by name
-    } else {
-        $tagsort = $CFG->tagsort;
-    }
-
-    if (is_numeric($a->$tagsort)) {
-        return ($a->$tagsort == $b->$tagsort) ? 0 : ($a->$tagsort > $b->$tagsort) ? 1 : -1;
-    } elseif (is_string($a->$tagsort)) {
-        return strcmp($a->$tagsort, $b->$tagsort);
-    } else {
-        return 0;
-    }
-}
-
-/**
- * Loads the events definitions for the component (from file). If no
- * events are defined for the component, we simply return an empty array.
- *
- * @access protected To be used from eventslib only
- * @deprecated since Moodle 3.1
- * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
- * @return array Array of capabilities or empty array if not exists
- */
-function events_load_def($component) {
-    global $CFG;
-    if ($component === 'unittest') {
-        $defpath = $CFG->dirroot.'/lib/tests/fixtures/events.php';
-    } else {
-        $defpath = core_component::get_component_directory($component).'/db/events.php';
-    }
-
-    $handlers = array();
-
-    if (file_exists($defpath)) {
-        require($defpath);
-    }
-
-    // make sure the definitions are valid and complete; tell devs what is wrong
-    foreach ($handlers as $eventname => $handler) {
-        if ($eventname === 'reset') {
-            debugging("'reset' can not be used as event name.");
-            unset($handlers['reset']);
-            continue;
-        }
-        if (!is_array($handler)) {
-            debugging("Handler of '$eventname' must be specified as array'");
-            unset($handlers[$eventname]);
-            continue;
-        }
-        if (!isset($handler['handlerfile'])) {
-            debugging("Handler of '$eventname' must include 'handlerfile' key'");
-            unset($handlers[$eventname]);
-            continue;
-        }
-        if (!isset($handler['handlerfunction'])) {
-            debugging("Handler of '$eventname' must include 'handlerfunction' key'");
-            unset($handlers[$eventname]);
-            continue;
-        }
-        if (!isset($handler['schedule'])) {
-            $handler['schedule'] = 'instant';
-        }
-        if ($handler['schedule'] !== 'instant' and $handler['schedule'] !== 'cron') {
-            debugging("Handler of '$eventname' must include valid 'schedule' type (instant or cron)'");
-            unset($handlers[$eventname]);
-            continue;
-        }
-        if (!isset($handler['internal'])) {
-            $handler['internal'] = 1;
-        }
-        $handlers[$eventname] = $handler;
-    }
-
-    return $handlers;
+ */
+function tag_find_tags() {
+    throw new coding_exception('tag_find_tags() can not be used anymore.');
 }
 
 /**
- * Puts a handler on queue
- *
- * @access protected To be used from eventslib only
- * @deprecated since Moodle 3.1
- * @param stdClass $handler event handler object from db
- * @param stdClass $event event data object
- * @param string $errormessage The error message indicating the problem
- * @return int id number of new queue handler
+ * @deprecated since 3.1
  */
-function events_queue_handler($handler, $event, $errormessage) {
-    global $DB;
+function tag_get_name() {
+    throw new coding_exception('tag_get_name() can not be used anymore.');
+}
 
-    if ($qhandler = $DB->get_record('events_queue_handlers', array('queuedeventid'=>$event->id, 'handlerid'=>$handler->id))) {
-        debugging("Please check code: Event id $event->id is already queued in handler id $qhandler->id");
-        return $qhandler->id;
-    }
+/**
+ * @deprecated since 3.1
+ */
+function tag_get_correlated() {
+    throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' .
+        'use core_tag_tag::get_correlated_tags().');
 
-    // make a new queue handler
-    $qhandler = new stdClass();
-    $qhandler->queuedeventid  = $event->id;
-    $qhandler->handlerid      = $handler->id;
-    $qhandler->errormessage   = $errormessage;
-    $qhandler->timemodified   = time();
-    if ($handler->schedule === 'instant' and $handler->status == 1) {
-        $qhandler->status     = 1; //already one failed attempt to dispatch this event
-    } else {
-        $qhandler->status     = 0;
-    }
+}
 
-    return $DB->insert_record('events_queue_handlers', $qhandler);
+/**
+ * @deprecated since 3.1
+ */
+function tag_cloud_sort() {
+    throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' .
+        'be found in core_tag_collection::cloud_sort().');
 }
 
 /**
- * trigger a single event with a specified handler
- *
- * @access protected To be used from eventslib only
  * @deprecated since Moodle 3.1
- * @param stdClass $handler This shoudl be a row from the events_handlers table.
- * @param stdClass $eventdata An object containing information about the event
- * @param string $errormessage error message indicating problem
- * @return bool|null True means event processed, false means retry event later; may throw exception, NULL means internal error
  */
-function events_dispatch($handler, $eventdata, &$errormessage) {
-    global $CFG;
-
-    debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.', DEBUG_DEVELOPER);
-
-    $function = unserialize($handler->handlerfunction);
-
-    if (is_callable($function)) {
-        // oki, no need for includes
-
-    } else if (file_exists($CFG->dirroot.$handler->handlerfile)) {
-        include_once($CFG->dirroot.$handler->handlerfile);
-
-    } else {
-        $errormessage = "Handler file of component $handler->component: $handler->handlerfile can not be found!";
-        return null;
-    }
-
-    // checks for handler validity
-    if (is_callable($function)) {
-        $result = call_user_func($function, $eventdata);
-        if ($result === false) {
-            $errormessage = "Handler function of component $handler->component: $handler->handlerfunction requested resending of event!";
-            return false;
-        }
-        return true;
+function events_load_def() {
+    throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.');
 
-    } else {
-        $errormessage = "Handler function of component $handler->component: $handler->handlerfunction not callable function or class method!";
-        return null;
-    }
 }
 
 /**
- * given a queued handler, call the respective event handler to process the event
- *
- * @access protected To be used from eventslib only
  * @deprecated since Moodle 3.1
- * @param stdClass $qhandler events_queued_handler row from db
- * @return boolean true means event processed, false means retry later, NULL means fatal failure
  */
-function events_process_queued_handler($qhandler) {
-    global $DB;
-
-    // get handler
-    if (!$handler = $DB->get_record('events_handlers', array('id'=>$qhandler->handlerid))) {
-        debugging("Error processing queue handler $qhandler->id, missing handler id: $qhandler->handlerid");
-        //irrecoverable error, remove broken queue handler
-        events_dequeue($qhandler);
-        return NULL;
-    }
-
-    // get event object
-    if (!$event = $DB->get_record('events_queue', array('id'=>$qhandler->queuedeventid))) {
-        // can't proceed with no event object - might happen when two crons running at the same time
-        debugging("Error processing queue handler $qhandler->id, missing event id: $qhandler->queuedeventid");
-        //irrecoverable error, remove broken queue handler
-        events_dequeue($qhandler);
-        return NULL;
-    }
-
-    // call the function specified by the handler
-    try {
-        $errormessage = 'Unknown error';
-        if (events_dispatch($handler, unserialize(base64_decode($event->eventdata)), $errormessage)) {
-            //everything ok
-            events_dequeue($qhandler);
-            return true;
-        }
-    } catch (Exception $e) {
-        // the problem here is that we do not want one broken handler to stop all others,
-        // cron handlers are very tricky because the needed data might have been deleted before the cron execution
-        $errormessage = "Handler function of component $handler->component: $handler->handlerfunction threw exception :" .
-                $e->getMessage() . "\n" . format_backtrace($e->getTrace(), true);
-        if (!empty($e->debuginfo)) {
-            $errormessage .= $e->debuginfo;
-        }
-    }
-
-    //dispatching failed
-    $qh = new stdClass();
-    $qh->id           = $qhandler->id;
-    $qh->errormessage = $errormessage;
-    $qh->timemodified = time();
-    $qh->status       = $qhandler->status + 1;
-    $DB->update_record('events_queue_handlers', $qh);
-
-    debugging($errormessage);
-
-    return false;
+function events_queue_handler() {
+    throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.');
 }
 
 /**
- * Updates all of the event definitions within the database.
- *
- * Unfortunately this isn't as simple as removing them all and then readding
- * the updated event definitions. Chances are queued items are referencing the
- * existing definitions.
- *
- * Note that the absence of the db/events.php event definition file
- * will cause any queued events for the component to be removed from
- * the database.
- *
- * @category event
  * @deprecated since Moodle 3.1
- * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
- * @return boolean always returns true
  */
-function events_update_definition($component='moodle') {
-    global $DB;
-
-    // load event definition from events.php
-    $filehandlers = events_load_def($component);
-
-    if ($filehandlers) {
-        debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.', DEBUG_DEVELOPER);
-    }
-
-    // load event definitions from db tables
-    // if we detect an event being already stored, we discard from this array later
-    // the remaining needs to be removed
-    $cachedhandlers = events_get_cached($component);
-
-    foreach ($filehandlers as $eventname => $filehandler) {
-        if (!empty($cachedhandlers[$eventname])) {
-            if ($cachedhandlers[$eventname]['handlerfile'] === $filehandler['handlerfile'] &&
-                $cachedhandlers[$eventname]['handlerfunction'] === serialize($filehandler['handlerfunction']) &&
-                $cachedhandlers[$eventname]['schedule'] === $filehandler['schedule'] &&
-                $cachedhandlers[$eventname]['internal'] == $filehandler['internal']) {
-                // exact same event handler already present in db, ignore this entry
-
-                unset($cachedhandlers[$eventname]);
-                continue;
-
-            } else {
-                // same event name matches, this event has been updated, update the datebase
-                $handler = new stdClass();
-                $handler->id              = $cachedhandlers[$eventname]['id'];
-                $handler->handlerfile     = $filehandler['handlerfile'];
-                $handler->handlerfunction = serialize($filehandler['handlerfunction']); // static class methods stored as array
-                $handler->schedule        = $filehandler['schedule'];
-                $handler->internal        = $filehandler['internal'];
-
-                $DB->update_record('events_handlers', $handler);
-
-                unset($cachedhandlers[$eventname]);
-                continue;
-            }
-
-        } else {
-            // if we are here, this event handler is not present in db (new)
-            // add it
-            $handler = new stdClass();
-            $handler->eventname       = $eventname;
-            $handler->component       = $component;
-            $handler->handlerfile     = $filehandler['handlerfile'];
-            $handler->handlerfunction = serialize($filehandler['handlerfunction']); // static class methods stored as array
-            $handler->schedule        = $filehandler['schedule'];
-            $handler->status          = 0;
-            $handler->internal        = $filehandler['internal'];
-
-            $DB->insert_record('events_handlers', $handler);
-        }
-    }
-
-    // clean up the left overs, the entries in cached events array at this points are deprecated event handlers
-    // and should be removed, delete from db
-    events_cleanup($component, $cachedhandlers);
-
-    events_get_handlers('reset');
-
-    return true;
+function events_dispatch() {
+    throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.');
 }
 
 /**
- * Events cron will try to empty the events queue by processing all the queued events handlers
- *
- * @access public Part of the public API
  * @deprecated since Moodle 3.1
- * @category event
- * @param string $eventname empty means all
- * @return int number of dispatched events
  */
-function events_cron($eventname='') {
-    global $DB;
-
-    $failed = array();
-    $processed = 0;
-
-    if ($eventname) {
-        $sql = "SELECT qh.*
-                  FROM {events_queue_handlers} qh, {events_handlers} h
-                 WHERE qh.handlerid = h.id AND h.eventname=?
-              ORDER BY qh.id";
-        $params = array($eventname);
-    } else {
-        $sql = "SELECT *
-                  FROM {events_queue_handlers}
-              ORDER BY id";
-        $params = array();
-    }
-
-    $rs = $DB->get_recordset_sql($sql, $params);
-    if ($rs->valid()) {
-        debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.', DEBUG_DEVELOPER);
-    }
-
-    foreach ($rs as $qhandler) {
-        if (isset($failed[$qhandler->handlerid])) {
-            // do not try to dispatch any later events when one already asked for retry or ended with exception
-            continue;
-        }
-        $status = events_process_queued_handler($qhandler);
-        if ($status === false) {
-            // handler is asking for retry, do not send other events to this handler now
-            $failed[$qhandler->handlerid] = $qhandler->handlerid;
-        } else if ($status === NULL) {
-            // means completely broken handler, event data was purged
-            $failed[$qhandler->handlerid] = $qhandler->handlerid;
-        } else {
-            $processed++;
-        }
-    }
-    $rs->close();
-
-    // remove events that do not have any handlers waiting
-    $sql = "SELECT eq.id
-              FROM {events_queue} eq
-              LEFT JOIN {events_queue_handlers} qh ON qh.queuedeventid = eq.id
-             WHERE qh.id IS NULL";
-    $rs = $DB->get_recordset_sql($sql);
-    foreach ($rs as $event) {
-        //debugging('Purging stale event '.$event->id);
-        $DB->delete_records('events_queue', array('id'=>$event->id));
-    }
-    $rs->close();
-
-    return $processed;
+function events_process_queued_handler() {
+    throw new coding_exception(
+        'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'
+    );
 }
 
 /**
- * Do not call directly, this is intended to be used from new event base only.
- *
- * @private
  * @deprecated since Moodle 3.1
- * @param string $eventname name of the event
- * @param mixed $eventdata event data object
- * @return int number of failed events
  */
-function events_trigger_legacy($eventname, $eventdata) {
-    global $CFG, $USER, $DB;
-
-    $failedcount = 0; // number of failed events.
-
-    // pull out all registered event handlers
-    if ($handlers = events_get_handlers($eventname)) {
-        foreach ($handlers as $handler) {
-            $errormessage = '';
-
-            if ($handler->schedule === 'instant') {
-                if ($handler->status) {
-                    //check if previous pending events processed
-                    if (!$DB->record_exists('events_queue_handlers', array('handlerid'=>$handler->id))) {
-                        // ok, queue is empty, lets reset the status back to 0 == ok
-                        $handler->status = 0;
-                        $DB->set_field('events_handlers', 'status', 0, array('id'=>$handler->id));
-                        // reset static handler cache
-                        events_get_handlers('reset');
-                    }
-                }
-
-                // dispatch the event only if instant schedule and status ok
-                if ($handler->status or (!$handler->internal and $DB->is_transaction_started())) {
-                    // increment the error status counter
-                    $handler->status++;
-                    $DB->set_field('events_handlers', 'status', $handler->status, array('id'=>$handler->id));
-                    // reset static handler cache
-                    events_get_handlers('reset');
-
-                } else {
-                    $errormessage = 'Unknown error';
-                    $result = events_dispatch($handler, $eventdata, $errormessage);
-                    if ($result === true) {
-                        // everything is fine - event dispatched
-                        continue;
-                    } else if ($result === false) {
-                        // retry later - set error count to 1 == send next instant into cron queue
-                        $DB->set_field('events_handlers', 'status', 1, array('id'=>$handler->id));
-                        // reset static handler cache
-                        events_get_handlers('reset');
-                    } else {
-                        // internal problem - ignore the event completely
-                        $failedcount ++;
-                        continue;
-                    }
-                }
-
-                // update the failed counter
-                $failedcount ++;
-
-            } else if ($handler->schedule === 'cron') {
-                //ok - use queueing of events only
-
-            } else {
-                // unknown schedule - ignore event completely
-                debugging("Unknown handler schedule type: $handler->schedule");
-                $failedcount ++;
-                continue;
-            }
-
-            // if even type is not instant, or dispatch asked for retry, queue it
-            $event = new stdClass();
-            $event->userid      = $USER->id;
-            $event->eventdata   = base64_encode(serialize($eventdata));
-            $event->timecreated = time();
-            if (debugging()) {
-                $dump = '';
-                $callers = debug_backtrace();
-                foreach ($callers as $caller) {
-                    if (!isset($caller['line'])) {
-                        $caller['line'] = '?';
-                    }
-                    if (!isset($caller['file'])) {
-                        $caller['file'] = '?';
-                    }
-                    $dump .= 'line ' . $caller['line'] . ' of ' . substr($caller['file'], strlen($CFG->dirroot) + 1);
-                    if (isset($caller['function'])) {
-                        $dump .= ': call to ';
-                        if (isset($caller['class'])) {
-                            $dump .= $caller['class'] . $caller['type'];
-                        }
-                        $dump .= $caller['function'] . '()';
-                    }
-                    $dump .= "\n";
-                }
-                $event->stackdump = $dump;
-            } else {
-                $event->stackdump = '';
-            }
-            $event->id = $DB->insert_record('events_queue', $event);
-            events_queue_handler($handler, $event, $errormessage);
-        }
-    } else {
-        // No handler found for this event name - this is ok!
-    }
-
-    return $failedcount;
+function events_update_definition() {
+    throw new coding_exception(
+        'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.'
+    );
 }
 
 /**
- * checks if an event is registered for this component
- *
- * @access public Part of the public API
  * @deprecated since Moodle 3.1
- * @param string $eventname name of the event
- * @param string $component component name, can be mod/data or moodle
- * @return bool
  */
-function events_is_registered($eventname, $component) {
-    global $DB;
-
-    debugging('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API,' .
-        ' please use it instead.', DEBUG_DEVELOPER);
-
-    return $DB->record_exists('events_handlers', array('component'=>$component, 'eventname'=>$eventname));
+function events_cron() {
+    throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.');
 }
 
 /**
- * checks if an event is queued for processing - either cron handlers attached or failed instant handlers
- *
- * @access public Part of the public API
  * @deprecated since Moodle 3.1
- * @param string $eventname name of the event
- * @return int number of queued events
  */
-function events_pending_count($eventname) {
-    global $DB;
-
-    debugging('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API,' .
-        ' please use it instead.', DEBUG_DEVELOPER);
+function events_trigger_legacy() {
+    throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.');
+}
 
-    $sql = "SELECT COUNT('x')
-              FROM {events_queue_handlers} qh
-              JOIN {events_handlers} h ON h.id = qh.handlerid
-             WHERE h.eventname = ?";
+/**
+ * @deprecated since Moodle 3.1
+ */
+function events_is_registered() {
+    throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.');
+}
 
-    return $DB->count_records_sql($sql, array($eventname));
+/**
+ * @deprecated since Moodle 3.1
+ */
+function events_pending_count() {
+    throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.');
 }
 
 /**
- * Emails admins about a clam outcome
- *
  * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
- * @param string $notice The body of the email to be sent.
- * @return void
  */
-function clam_message_admins($notice) {
-    debugging('clam_message_admins() is deprecated, please use message_admins() method of \antivirus_clamav\scanner class.', DEBUG_DEVELOPER);
-
-    $antivirus = \core\antivirus\manager::get_antivirus('clamav');
-    $antivirus->message_admins($notice);
+function clam_message_admins() {
+    throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' .
+        'message_admins() method of \antivirus_clamav\scanner class.');
 }
 
 /**
- * Returns the string equivalent of a numeric clam error code
- *
  * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
- * @param int $returncode The numeric error code in question.
- * @return string The definition of the error code
  */
-function get_clam_error_code($returncode) {
-    debugging('get_clam_error_code() is deprecated, please use get_clam_error_code() method of \antivirus_clamav\scanner class.', DEBUG_DEVELOPER);
-
-    $antivirus = \core\antivirus\manager::get_antivirus('clamav');
-    return $antivirus->get_clam_error_code($returncode);
+function get_clam_error_code() {
+    throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' .
+        'get_clam_error_code() method of \antivirus_clamav\scanner class.');
 }
 
 /**
- * Returns the rename action.
- *
  * @deprecated since 3.1
- * @param cm_info $mod The module to produce editing buttons for
- * @param int $sr The section to link back to (used for creating the links)
- * @return The markup for the rename action, or an empty string if not available.
  */
-function course_get_cm_rename_action(cm_info $mod, $sr = null) {
-    global $COURSE, $OUTPUT;
-
-    static $str;
-    static $baseurl;
-
-    debugging('Function course_get_cm_rename_action() is deprecated. Please use inplace_editable ' .
-        'https://docs.moodle.org/dev/Inplace_editable', DEBUG_DEVELOPER);
+function course_get_cm_rename_action() {
+    throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' .
+        'inplace_editable https://docs.moodle.org/dev/Inplace_editable.');
 
-    $modcontext = context_module::instance($mod->id);
-    $hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
-
-    if (!isset($str)) {
-        $str = get_strings(array('edittitle'));
-    }
-
-    if (!isset($baseurl)) {
-        $baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
-    }
-
-    if ($sr !== null) {
-        $baseurl->param('sr', $sr);
-    }
-
-    // AJAX edit title.
-    if ($mod->has_view() && $hasmanageactivities && course_ajax_enabled($COURSE) &&
-        (($mod->course == $COURSE->id) || ($mod->course == SITEID))) {
-        // we will not display link if we are on some other-course page (where we should not see this module anyway)
-        return html_writer::span(
-            html_writer::link(
-                new moodle_url($baseurl, array('update' => $mod->id)),
-                $OUTPUT->pix_icon('t/editstring', '', 'moodle', array('class' => 'iconsmall visibleifjs', 'title' => '')),
-                array(
-                    'class' => 'editing_title',
-                    'data-action' => 'edittitle',
-                    'title' => $str->edittitle,
-                )
-            )
-        );
-    }
-    return '';
 }
 
-/*
- * This function returns the number of activities using the given scale in the given course.
- *
+/**
  * @deprecated since Moodle 3.1
- * @param int $courseid The course ID to check.
- * @param int $scaleid The scale ID to check
- * @return int
  */
-function course_scale_used($courseid, $scaleid) {
-    global $CFG, $DB;
-
-    debugging('course_scale_used() is deprecated and never used, plugins can implement <modname>_scale_used_anywhere, '.
-        'all implementations of <modname>_scale_used are now ignored', DEBUG_DEVELOPER);
-
-    $return = 0;
-
-    if (!empty($scaleid)) {
-        if ($cms = get_course_mods($courseid)) {
-            foreach ($cms as $cm) {
-                // Check cm->name/lib.php exists.
-                if (file_exists($CFG->dirroot.'/mod/'.$cm->modname.'/lib.php')) {
-                    include_once($CFG->dirroot.'/mod/'.$cm->modname.'/lib.php');
-                    $functionname = $cm->modname.'_scale_used';
-                    if (function_exists($functionname)) {
-                        if ($functionname($cm->instance, $scaleid)) {
-                            $return++;
-                        }
-                    }
-                }
-            }
-        }
-
-        // Check if any course grade item makes use of the scale.
-        $return += $DB->count_records('grade_items', array('courseid' => $courseid, 'scaleid' => $scaleid));
-
-        // Check if any outcome in the course makes use of the scale.
-        $return += $DB->count_records_sql("SELECT COUNT('x')
-                                             FROM {grade_outcomes_courses} goc,
-                                                  {grade_outcomes} go
-                                            WHERE go.id = goc.outcomeid
-                                                  AND go.scaleid = ? AND goc.courseid = ?",
-            array($scaleid, $courseid));
-    }
-    return $return;
+function course_scale_used() {
+    throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' .
+        'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
 }
 
 /**
- * This function returns the number of activities using scaleid in the entire site
- *
  * @deprecated since Moodle 3.1
- * @param int $scaleid
- * @param array $courses
- * @return int
  */
-function site_scale_used($scaleid, &$courses) {
-    $return = 0;
-
-    debugging('site_scale_used() is deprecated and never used, plugins can implement <modname>_scale_used_anywhere, '.
-        'all implementations of <modname>_scale_used are now ignored', DEBUG_DEVELOPER);
-
-    if (!is_array($courses) || count($courses) == 0) {
-        $courses = get_courses("all", false, "c.id, c.shortname");
-    }
-
-    if (!empty($scaleid)) {
-        if (is_array($courses) && count($courses) > 0) {
-            foreach ($courses as $course) {
-                $return += course_scale_used($course->id, $scaleid);
-            }
-        }
-    }
-    return $return;
+function site_scale_used() {
+    throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' .
+        '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
 }
 
 /**
  * @deprecated since Moodle 3.1. Use external_api::external_function_info().
  */
-function external_function_info($function, $strictness=MUST_EXIST) {
+function external_function_info() {
     throw new coding_exception('external_function_info() can not be used any'.
         'more. Please use external_api::external_function_info() instead.');
 }
@@ -5924,39 +4061,21 @@ function calendar_cron() {
 }
 
 /**
- * Previous internal API, it was not supposed to be used anywhere.
- *
- * @access private
  * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
- * @param int $userid the id of the user
- * @param context_course $coursecontext course context
- * @param array $accessdata accessdata array (modified)
- * @return void modifies $accessdata parameter
  */
-function load_course_context($userid, context_course $coursecontext, &$accessdata) {
+function load_course_context() {
     throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.');
 }
 
 /**
- * Previous internal API, it was not supposed to be used anywhere.
- *
- * @access private
  * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
- * @param int $roleid the id of the user
- * @param context $context needs path!
- * @param array $accessdata accessdata array (is modified)
- * @return array
  */
-function load_role_access_by_context($roleid, context $context, &$accessdata) {
+function load_role_access_by_context() {
     throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.');
 }
 
 /**
- * Previous internal API, it was not supposed to be used anywhere.
- *
- * @access private
  * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
- * @return void
  */
 function dedupe_user_access() {
     throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.');
@@ -6613,3 +4732,136 @@ function groups_get_all_groups_for_courses($courses) {
 
     return $groups;
 }
+
+/**
+ * Gets the capabilities that have been cached in the database for this
+ * component.
+ * @deprecated since Moodle 3.6. Please use the Events 2 API.
+ * @todo final deprecation. To be removed in Moodle 4.0
+ *
+ * @access protected To be used from eventslib only
+ *
+ * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
+ * @return array of events
+ */
+function events_get_cached($component) {
+    global $DB;
+
+    debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
+            DEBUG_DEVELOPER);
+
+    $cachedhandlers = array();
+
+    if ($storedhandlers = $DB->get_records('events_handlers', array('component'=>$component))) {
+        foreach ($storedhandlers as $handler) {
+            $cachedhandlers[$handler->eventname] = array (
+                'id'              => $handler->id,
+                'handlerfile'     => $handler->handlerfile,
+                'handlerfunction' => $handler->handlerfunction,
+                'schedule'        => $handler->schedule,
+                'internal'        => $handler->internal);
+        }
+    }
+
+    return $cachedhandlers;
+}
+
+/**
+ * Remove all event handlers and queued events
+ * @deprecated since Moodle 3.6. Please use the Events 2 API.
+ * @todo final deprecation. To be removed in Moodle 4.0
+ *
+ * @category event
+ * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
+ */
+function events_uninstall($component) {
+    debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
+            DEBUG_DEVELOPER);
+    $cachedhandlers = events_get_cached($component);
+    events_cleanup($component, $cachedhandlers);
+
+    events_get_handlers('reset');
+}
+
+/**
+ * Deletes cached events that are no longer needed by the component.
+ * @deprecated since Moodle 3.6. Please use the Events 2 API.
+ * @todo final deprecation. To be removed in Moodle 4.0
+ *
+ * @access protected To be used from eventslib only
+ *
+ * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
+ * @param array $cachedhandlers array of the cached events definitions that will be
+ * @return int number of unused handlers that have been removed
+ */
+function events_cleanup($component, $cachedhandlers) {
+    global $DB;
+    debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
+            DEBUG_DEVELOPER);
+    $deletecount = 0;
+    foreach ($cachedhandlers as $eventname => $cachedhandler) {
+        if ($qhandlers = $DB->get_records('events_queue_handlers', array('handlerid'=>$cachedhandler['id']))) {
+            //debugging("Removing pending events from queue before deleting of event handler: $component - $eventname");
+            foreach ($qhandlers as $qhandler) {
+                events_dequeue($qhandler);
+            }
+        }
+        $DB->delete_records('events_handlers', array('eventname'=>$eventname, 'component'=>$component));
+        $deletecount++;
+    }
+
+    return $deletecount;
+}
+
+/**
+ * Removes this queued handler from the events_queued_handler table
+ *
+ * Removes events_queue record from events_queue if no more references to this event object exists
+ * @deprecated since Moodle 3.6. Please use the Events 2 API.
+ * @todo final deprecation. To be removed in Moodle 4.0
+ *
+ * @access protected To be used from eventslib only
+ *
+ * @param stdClass $qhandler A row from the events_queued_handler table
+ */
+function events_dequeue($qhandler) {
+    global $DB;
+    debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
+         &nbs