Merge branch 'MDL-44449' of git://github.com/timhunt/moodle

This commit is contained in:
Dan Poltawski 2014-05-20 09:50:43 +08:00
commit 0c722830d9
4 changed files with 47 additions and 7 deletions

View File

@ -30,8 +30,9 @@ defined('MOODLE_INTERNAL') || die();
* This class keeps track of the various access rules that apply to a particular
* quiz, with convinient methods for seeing whether access is allowed.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.2
*/
class quiz_access_manager {
/** @var quiz the quiz settings object. */
@ -143,11 +144,11 @@ class quiz_access_manager {
/**
* Save any submitted settings when the quiz settings form is submitted.
*
* Note that the standard plugins do not use this mechanism, becuase all their
* Note that the standard plugins do not use this mechanism because their
* settings are stored in the quiz table.
*
* @param object $quiz the data from the quiz form, including $quiz->id
* which is the is of the quiz being saved.
* which is the id of the quiz being saved.
*/
public static function save_settings($quiz) {
@ -156,6 +157,23 @@ class quiz_access_manager {
}
}
/**
* Delete any rule-specific settings when the quiz is deleted.
*
* Note that the standard plugins do not use this mechanism because their
* settings are stored in the quiz table.
*
* @param object $quiz the data from the database, including $quiz->id
* which is the id of the quiz being deleted.
* @since Moodle 2.7.1, 2.6.4, 2.5.7
*/
public static function delete_settings($quiz) {
foreach (self::get_rule_classes() as $rule) {
$rule::delete_settings($quiz);
}
}
/**
* Build the SQL for loading all the access settings in one go.
* @param int $quizid the quiz id.

View File

@ -37,8 +37,9 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
* as true) if access should be blocked. Slighly unnatural, but acutally the easist
* way to implement this.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.2
*/
abstract class quiz_access_rule_base {
/** @var stdClass the quiz settings. */
@ -281,12 +282,23 @@ abstract class quiz_access_rule_base {
* Save any submitted settings when the quiz settings form is submitted. This
* is called from {@link quiz_after_add_or_update()} in lib.php.
* @param object $quiz the data from the quiz form, including $quiz->id
* which is the is of the quiz being saved.
* which is the id of the quiz being saved.
*/
public static function save_settings($quiz) {
// By default do nothing.
}
/**
* Delete any rule-specific settings when the quiz is deleted. This is called
* from {@link quiz_delete_instance()} in lib.php.
* @param object $quiz the data from the database, including $quiz->id
* which is the id of the quiz being deleted.
* @since Moodle 2.7.1, 2.6.4, 2.5.7
*/
public static function delete_settings($quiz) {
// By default do nothing.
}
/**
* Return the bits of SQL needed to load all the settings from all the access
* plugins in one DB query. The easiest way to understand what you need to do

View File

@ -2,16 +2,24 @@ This files describes API changes for quiz access rule plugins.
Overview of this plugin type at http://docs.moodle.org/dev/Quiz_access_rules
=== 2.8, 2.7.1, 2.6.4 and 2.5.7 ===
* New static method delete_settings for access rules, which is called when a
quiz is deleted.
=== 2.4 and 2.3.4 ===
* Replaced time_left() with new time_left_display() and end_time() functions.
=== 2.3 ===
* This plugin type now supports cron in the standard way. If required, Create a
lib.php file containing
function quizaccess_mypluginname_cron() {};
=== 2.2 ===
* This plugin type was new in Moodle 2.2!

View File

@ -169,6 +169,8 @@ function quiz_delete_instance($id) {
$DB->delete_records('quiz_slots', array('quizid' => $quiz->id));
$DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
quiz_access_manager::delete_settings($quiz);
$events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
foreach ($events as $event) {
$event = calendar_event::load($event);