From 3c6ad8ac09f3ca826db4227ba6676c3ce69256d8 Mon Sep 17 00:00:00 2001 From: cescobedo Date: Thu, 30 Sep 2021 07:42:14 +0200 Subject: [PATCH] MDL-72616 blocks: Remove block_quiz_results --- blocks/activity_results/version.php | 2 +- .../restore_quiz_results_block_task.class.php | 113 ------------------ blocks/quiz_results/block_quiz_results.php | 61 ---------- .../quiz_results/classes/privacy/provider.php | 46 ------- blocks/quiz_results/db/access.php | 41 ------- blocks/quiz_results/db/install.php | 31 ----- blocks/quiz_results/db/upgrade.php | 61 ---------- .../lang/en/block_quiz_results.php | 27 ----- blocks/quiz_results/lang/en/depreciated.txt | 0 blocks/quiz_results/version.php | 31 ----- blocks/upgrade.txt | 5 + lib/accesslib.php | 4 +- lib/classes/plugin_manager.php | 4 +- lib/db/upgrade.php | 30 +++++ lib/messagelib.php | 8 +- version.php | 2 +- 16 files changed, 45 insertions(+), 421 deletions(-) delete mode 100644 blocks/quiz_results/backup/moodle2/restore_quiz_results_block_task.class.php delete mode 100644 blocks/quiz_results/block_quiz_results.php delete mode 100644 blocks/quiz_results/classes/privacy/provider.php delete mode 100644 blocks/quiz_results/db/access.php delete mode 100644 blocks/quiz_results/db/install.php delete mode 100644 blocks/quiz_results/db/upgrade.php delete mode 100644 blocks/quiz_results/lang/en/block_quiz_results.php delete mode 100644 blocks/quiz_results/lang/en/depreciated.txt delete mode 100644 blocks/quiz_results/version.php diff --git a/blocks/activity_results/version.php b/blocks/activity_results/version.php index 6d9cac9538d..4bef0eb16a7 100644 --- a/blocks/activity_results/version.php +++ b/blocks/activity_results/version.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Version information for the block_quiz_results plugin. + * Version information for the block_activity_results plugin. * * @package block_activity_results * @copyright 2015 Stephen Bourget diff --git a/blocks/quiz_results/backup/moodle2/restore_quiz_results_block_task.class.php b/blocks/quiz_results/backup/moodle2/restore_quiz_results_block_task.class.php deleted file mode 100644 index 9aff8395b19..00000000000 --- a/blocks/quiz_results/backup/moodle2/restore_quiz_results_block_task.class.php +++ /dev/null @@ -1,113 +0,0 @@ -. - -/** - * @package block_quiz_results - * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * Specialised restore task for the quiz_results block - * (using execute_after_tasks for recoding of target quiz) - * - * TODO: Finish phpdocs - * - * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class restore_quiz_results_block_task extends restore_block_task { - - protected function define_my_settings() { - } - - protected function define_my_steps() { - } - - public function get_fileareas() { - return array(); // No associated fileareas - } - - public function get_configdata_encoded_attributes() { - return array(); // No special handling of configdata - } - - /** - * This function, executed after all the tasks in the plan - * have been executed, will perform the recode of the - * target quiz for the block. This must be done here - * and not in normal execution steps because the quiz - * can be restored after the block. - */ - public function after_restore() { - global $DB; - - // Get the blockid. - $blockid = $this->get_blockid(); - - // Extract block configdata and update it to point to the new quiz. - $configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid)); - $newconfigdata = ''; - - // The block was configured. - if (!empty($configdata)) { - - $config = unserialize(base64_decode($configdata)); - $config->activityparent = 'quiz'; - $config->activityparentid = 0; - $config->gradeformat = isset($config->gradeformat) ? $config->gradeformat : 1; - - if (!empty($config->quizid) - && $quizmap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'quiz', $config->quizid)) { - $config->activityparentid = $quizmap->newitemid; - } - - // Set the decimal valuue as appropriate. - if ($config->gradeformat == 1) { - // This block is using percentages, do not display any decimal places. - $config->decimalpoints = 0; - } else { - // Get the decimal value from the corresponding quiz. - $config->decimalpoints = $DB->get_field('quiz', 'decimalpoints', array('id' => $config->activityparentid)); - } - - // Get the grade_items record to set the activitygradeitemid. - $info = $DB->get_record('grade_items', - array('iteminstance' => $config->activityparentid, 'itemmodule' => $config->activityparent)); - $config->activitygradeitemid = 0; - if ($info) { - $config->activitygradeitemid = $info->id; - } - - unset($config->quizid); - $newconfigdata = base64_encode(serialize($config)); - } - - // Update the configuration and convert the block. - $DB->set_field('block_instances', 'configdata', $newconfigdata, array('id' => $blockid)); - $DB->set_field('block_instances', 'blockname', 'activity_results', array('id' => $blockid)); - } - - static public function define_decode_contents() { - return array(); - } - - static public function define_decode_rules() { - return array(); - } -} diff --git a/blocks/quiz_results/block_quiz_results.php b/blocks/quiz_results/block_quiz_results.php deleted file mode 100644 index bfb259bc994..00000000000 --- a/blocks/quiz_results/block_quiz_results.php +++ /dev/null @@ -1,61 +0,0 @@ -. - -/** - * Classes to enforce the various access rules that can apply to a quiz. - * - * @package block_quiz_results - * @copyright 2009 Tim Hunt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -require_once($CFG->dirroot . '/mod/quiz/lib.php'); - -/** - * Block quiz_results class definition. - * - * This block can be added to a course page or a quiz page to display of list of - * the best/worst students/groups in a particular quiz. - * - * @package block_quiz_results - * @copyright 2009 Tim Hunt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class block_quiz_results extends block_base { - function init() { - $this->title = get_string('pluginname', 'block_quiz_results'); - } - - function applicable_formats() { - return array('mod-quiz' => true); - } - - function instance_config_save($data, $nolongerused = false) { - parent::instance_config_save($data); - } - - function get_content() { - return $this->content; - } - - function instance_allow_multiple() { - return true; - } -} - - diff --git a/blocks/quiz_results/classes/privacy/provider.php b/blocks/quiz_results/classes/privacy/provider.php deleted file mode 100644 index 09946651f7f..00000000000 --- a/blocks/quiz_results/classes/privacy/provider.php +++ /dev/null @@ -1,46 +0,0 @@ -. - -/** - * Privacy Subsystem implementation for block_quiz_results. - * - * @package block_quiz_results - * @copyright 2018 Zig Tan - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace block_quiz_results\privacy; - -defined('MOODLE_INTERNAL') || die(); - -/** - * Privacy Subsystem for block_quiz_results implementing null_provider. - * - * @copyright 2018 Zig Tan - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class provider implements \core_privacy\local\metadata\null_provider { - - /** - * Get the language string identifier with the component's language - * file to explain why this plugin stores no data. - * - * @return string - */ - public static function get_reason() : string { - return 'privacy:metadata'; - } -} diff --git a/blocks/quiz_results/db/access.php b/blocks/quiz_results/db/access.php deleted file mode 100644 index 8e3622bc5bc..00000000000 --- a/blocks/quiz_results/db/access.php +++ /dev/null @@ -1,41 +0,0 @@ -. - -/** - * Quiz results block caps. - * - * @package block_quiz_results - * @copyright Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$capabilities = array( - - 'block/quiz_results:addinstance' => array( - 'riskbitmask' => RISK_SPAM | RISK_XSS, - - 'captype' => 'write', - 'contextlevel' => CONTEXT_BLOCK, - 'archetypes' => array( - 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ), - - 'clonepermissionsfrom' => 'moodle/site:manageblocks' - ), -); diff --git a/blocks/quiz_results/db/install.php b/blocks/quiz_results/db/install.php deleted file mode 100644 index 255cdba70e3..00000000000 --- a/blocks/quiz_results/db/install.php +++ /dev/null @@ -1,31 +0,0 @@ -. - -/** - * Quiz results block installation. - * - * @package block_quiz_results - * @copyright 2015 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -function xmldb_block_quiz_results_install() { - global $DB; - - // Disable quiz_results on new installs (its now just a stub). - $DB->set_field('block', 'visible', 0, array('name' => 'quiz_results')); -} - diff --git a/blocks/quiz_results/db/upgrade.php b/blocks/quiz_results/db/upgrade.php deleted file mode 100644 index ca88593c63a..00000000000 --- a/blocks/quiz_results/db/upgrade.php +++ /dev/null @@ -1,61 +0,0 @@ -. - -/** - * This file keeps track of upgrades to the quiz_results block - * - * Sometimes, changes between versions involve alterations to database structures - * and other major things that may break installations. - * - * The upgrade function in this file will attempt to perform all the necessary - * actions to upgrade your older installation to the current version. - * - * If there's something it cannot do itself, it will tell you what you need to do. - * - * The commands in here will all be database-neutral, using the methods of - * database_manager class - * - * Please do not forget to use upgrade_set_timeout() - * before any action that may take longer time to finish. - * - * @since Moodle 2.9 - * @package block_quiz_results - * @copyright 2015 Stephen Bourget - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Upgrade the quiz_results block - * @param int $oldversion - * @param object $block - */ -function xmldb_block_quiz_results_upgrade($oldversion, $block) { - global $CFG; - - // Automatically generated Moodle v3.6.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.7.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.8.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.9.0 release upgrade line. - // Put any upgrade step following this. - - return true; -} diff --git a/blocks/quiz_results/lang/en/block_quiz_results.php b/blocks/quiz_results/lang/en/block_quiz_results.php deleted file mode 100644 index f822a2fd5ed..00000000000 --- a/blocks/quiz_results/lang/en/block_quiz_results.php +++ /dev/null @@ -1,27 +0,0 @@ -. - -/** - * Strings for component 'block_quiz_results', language 'en', branch 'MOODLE_20_STABLE' - * - * @package block_quiz_results - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['pluginname'] = 'Quiz results (disabled)'; -$string['quiz_results:addinstance'] = 'Add a new quiz results block'; -$string['privacy:metadata'] = 'The Quiz results block only shows data stored in other locations.'; diff --git a/blocks/quiz_results/lang/en/depreciated.txt b/blocks/quiz_results/lang/en/depreciated.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/blocks/quiz_results/version.php b/blocks/quiz_results/version.php deleted file mode 100644 index b11a6e57b7b..00000000000 --- a/blocks/quiz_results/version.php +++ /dev/null @@ -1,31 +0,0 @@ -. - -/** - * Version information for the block_quiz_results plugin. - * - * @package block_quiz_results - * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX). -$plugin->requires = 2021052500; // Requires this Moodle version. -$plugin->component = 'block_quiz_results'; // Full name of the plugin (used for diagnostics) - -$plugin->dependencies = array('mod_quiz' => 2021052500); diff --git a/blocks/upgrade.txt b/blocks/upgrade.txt index 1506c7dc463..54f3fee0a02 100644 --- a/blocks/upgrade.txt +++ b/blocks/upgrade.txt @@ -1,6 +1,11 @@ This files describes API changes in /blocks/* - activity modules, information provided here is intended especially for developers. +=== 4.0 === + +* Block block_quiz_results has been completely removed from core. +The Quiz results block is hidden by default since Moodle 2.9. It is recommended to use the Activity results block instead, which works with any type of activity (not just quizzes). + === 3.8 === * Block block_community is no longer a part of core. * Block block_participants is no longer a part of core. diff --git a/lib/accesslib.php b/lib/accesslib.php index 11669e1dd6b..0867775b912 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -2244,7 +2244,7 @@ function reset_role_capabilities($roleid) { * the database. * * @access private - * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results' + * @param string $component examples: 'moodle', 'mod_forum', 'block_activity_results' * @return boolean true if success, exception in case of any problems */ function update_capabilities($component = 'moodle') { @@ -2366,7 +2366,7 @@ function update_capabilities($component = 'moodle') { * NOTE: this function is called from lib/db/upgrade.php * * @access private - * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results' + * @param string $component examples: 'moodle', 'mod_forum', 'block_activity_results' * @param array $newcapdef array of the new capability definitions that will be * compared with the cached capabilities * @return int number of deprecated capabilities that have been removed diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index c7a053e0242..6ea59bc189e 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1728,7 +1728,7 @@ class core_plugin_manager { $plugins = array( 'qformat' => array('blackboard', 'learnwise', 'examview'), 'auth' => array('radius', 'fc', 'nntp', 'pam', 'pop3', 'imap'), - 'block' => array('course_overview', 'messages', 'community', 'participants'), + 'block' => array('course_overview', 'messages', 'community', 'participants', 'quiz_results'), 'cachestore' => array('memcache'), 'enrol' => array('authorize'), 'filter' => array('censor'), @@ -1806,7 +1806,7 @@ class core_plugin_manager { 'feedback', 'globalsearch', 'glossary_random', 'html', 'login', 'lp', 'mentees', 'mnet_hosts', 'myoverview', 'myprofile', 'navigation', 'news_items', 'online_users', - 'private_files', 'quiz_results', 'recent_activity', 'recentlyaccesseditems', + 'private_files', 'recent_activity', 'recentlyaccesseditems', 'recentlyaccessedcourses', 'rss_client', 'search_forums', 'section_links', 'selfcompletion', 'settings', 'site_main_menu', 'social_activities', 'starredcourses', 'tag_flickr', 'tag_youtube', 'tags', 'timeline' diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 9039e9d2163..e3126338c6a 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3010,5 +3010,35 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2021101900.01); } + if ($oldversion < 2021102600.01) { + // Remove block_quiz_results (unless it has manually been added back). + if (!file_exists($CFG->dirroot . '/blocks/quiz_result/block_quiz_results.php')) { + // Delete instances. + $instances = $DB->get_records_list('block_instances', 'blockname', ['quiz_results']); + $instanceids = array_keys($instances); + + if (!empty($instanceids)) { + blocks_delete_instances($instanceids); + } + + // Delete the block from the block table. + $DB->delete_records('block', array('name' => 'quiz_results')); + + // Remove capabilities. + capabilities_cleanup('block_quiz_results'); + // Clean config. + unset_all_config_for_plugin('block_quiz_results'); + + // Remove Moodle-level quiz_results based capabilities. + $capabilitiestoberemoved = ['block/quiz_results:addinstance']; + // Delete any role_capabilities for the old roles. + $DB->delete_records_list('role_capabilities', 'capability', $capabilitiestoberemoved); + // Delete the capability itself. + $DB->delete_records_list('capabilities', 'name', $capabilitiestoberemoved); + } + + upgrade_main_savepoint(true, 2021102600.01); + } + return true; } diff --git a/lib/messagelib.php b/lib/messagelib.php index b35316ea62e..9138c1577d5 100644 --- a/lib/messagelib.php +++ b/lib/messagelib.php @@ -416,7 +416,7 @@ function message_handle_phpunit_redirection(\core\message\message $eventdata, st /** * Updates the message_providers table with the current set of message providers * - * @param string $component For example 'moodle', 'mod_forum' or 'block_quiz_results' + * @param string $component For example 'moodle', 'mod_forum' or 'block_activity_results' * @return boolean True on success */ function message_update_providers($component='moodle') { @@ -684,7 +684,7 @@ function message_get_providers_for_user($userid) { * This is an internal function used within messagelib.php * * @see message_update_providers() - * @param string $component A moodle component like 'moodle', 'mod_forum', 'block_quiz_results' + * @param string $component A moodle component like 'moodle', 'mod_forum', 'block_activity_results' * @return array An array of message providers */ function message_get_providers_from_db($component) { @@ -701,7 +701,7 @@ function message_get_providers_from_db($component) { * * @see message_update_providers() * @see message_update_processors() - * @param string $component A moodle component like 'moodle', 'mod_forum', 'block_quiz_results' + * @param string $component A moodle component like 'moodle', 'mod_forum', 'block_activity_results' * @return array An array of message providers or empty array if not exists */ function message_get_providers_from_file($component) { @@ -728,7 +728,7 @@ function message_get_providers_from_file($component) { /** * Remove all message providers for particular component and corresponding settings * - * @param string $component A moodle component like 'moodle', 'mod_forum', 'block_quiz_results' + * @param string $component A moodle component like 'moodle', 'mod_forum', 'block_activity_results' * @return void */ function message_provider_uninstall($component) { diff --git a/version.php b/version.php index 34c347017fc..ef1f2da6da2 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2021102600.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2021102600.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '4.0dev+ (Build: 20211026)'; // Human-friendly version name