* 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. */
/**
* 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) {
}
}
+ /**
+ * 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.
* 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. */
* 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
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!
$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);