Commit 3c6ad8ac authored by cescobedo's avatar cescobedo
Browse files

MDL-72616 blocks: Remove block_quiz_results

parent 2b2897bf
......@@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version information for the block_quiz_results plugin.
* Version information for the block_activity_results plugin.
*
* @package block_activity_results
* @copyright 2015 Stephen Bourget
......
<?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/>.
/**
* @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();
}
}
<?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/>.
/**
* 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;
}
}
<?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 block_quiz_results.
*
* @package block_quiz_results
* @copyright 2018 Zig Tan <zig@moodle.com>
* @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 <zig@moodle.com>
* @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';
}
}
<?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/>.
/**
* Quiz results block caps.
*
* @package block_quiz_results
* @copyright Mark Nelson <markn@moodle.com>
* @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'
),
);
<?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/>.
/**
* Quiz results block installation.
*
* @package block_quiz_results
* @copyright 2015 Dan Poltawski <dan@moodle.com>
* @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'));
}
<?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 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;
}
<?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 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.';
<?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/>.
/**
* 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);
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.
......
......@@ -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
......
......@@ -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'
......
......@@ -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;
}
......@@ -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) {
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment