mtrace('Finished blocks');
- //TODO: get rid of this bloody hardcoded quiz module stuff, this must be done from quiz_cron()!
- mtrace("Starting quiz reports");
- if ($reports = $DB->get_records_select('quiz_reports', "cron > 0 AND ((? - lastcron) > cron)", array($timenow))) {
- foreach ($reports as $report) {
- $cronfile = "$CFG->dirroot/mod/quiz/report/$report->name/cron.php";
- if (file_exists($cronfile)) {
- include_once($cronfile);
- $cron_function = 'quiz_report_'.$report->name."_cron";
- if (function_exists($cron_function)) {
- mtrace("Processing quiz report cron function $cron_function ...", '');
- $pre_dbqueries = null;
- $pre_dbqueries = $DB->perf_get_queries();
- $pre_time = microtime(1);
- if ($cron_function()) {
- $DB->set_field('quiz_reports', "lastcron", $timenow, array("id"=>$report->id));
- }
- if (isset($pre_dbqueries)) {
- mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
- mtrace("... used " . (microtime(1) - $pre_time) . " seconds");
- }
- @set_time_limit(0);
- mtrace("done.");
- }
- }
- }
- }
- mtrace("Finished quiz reports");
-
-
mtrace('Starting admin reports');
cron_execute_plugin_type('report');
mtrace('Finished admin reports');
// TODO: Repository lib.php files are messed up (include many other files, etc), so it is
// currently not possible to implement repository plugin cron using this infrastructure
// cron_execute_plugin_type('repository', 'repository plugins');
+ cron_execute_plugin_type('qbehaviour', 'question behaviours');
+ cron_execute_plugin_type('qformat', 'question import/export formats');
cron_execute_plugin_type('qtype', 'question types');
cron_execute_plugin_type('plagiarism', 'plagiarism plugins');
cron_execute_plugin_type('theme', 'themes');
--- /dev/null
+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.2 ===
+
+* This plugin type was new in Moodle 2.2!
+
+
+=== 2.3 ===
+
+* This plugin type now supports cron in the standard way. If required, Create a
+ lib.php file containing
+function quizaccess_mypluginname_cron() {};
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="name of the report, same as the directory name" PREVIOUS="id" NEXT="displayorder"/>
- <FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="display order for report tabs" PREVIOUS="name" NEXT="lastcron"/>
- <FIELD NAME="lastcron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="timestamp when cron was last run for this report." PREVIOUS="displayorder" NEXT="cron"/>
- <FIELD NAME="cron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 if there is no cron for this report (default) or the time between crons otherwise." PREVIOUS="lastcron" NEXT="capability"/>
- <FIELD NAME="capability" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Capability required to see this report. May be blank which means use the default of mod/quiz:viewreport. This is used when deciding which tabs to render." PREVIOUS="cron"/>
+ <FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="display order for report tabs" PREVIOUS="name" NEXT="capability"/>
+ <FIELD NAME="capability" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Capability required to see this report. May be blank which means use the default of mod/quiz:viewreport. This is used when deciding which tabs to render." PREVIOUS="displayorder"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
+ if ($oldversion < 2011120700) {
+
+ // Define field lastcron to be dropped from quiz_reports
+ $table = new xmldb_table('quiz_reports');
+ $field = new xmldb_field('lastcron');
+
+ // Conditionally launch drop field lastcron
+ if ($dbman->field_exists($table, $field)) {
+ $dbman->drop_field($table, $field);
+ }
+
+ // quiz savepoint reached
+ upgrade_mod_savepoint(true, 2011120700, 'quiz');
+ }
+
+ if ($oldversion < 2011120701) {
+
+ // Define field cron to be dropped from quiz_reports
+ $table = new xmldb_table('quiz_reports');
+ $field = new xmldb_field('cron');
+
+ // Conditionally launch drop field cron
+ if ($dbman->field_exists($table, $field)) {
+ $dbman->drop_field($table, $field);
+ }
+
+ // quiz savepoint reached
+ upgrade_mod_savepoint(true, 2011120701, 'quiz');
+ }
+
return true;
}
}
/**
- * Function to be run periodically according to the moodle cron
- * This function searches for things that need to be done, such
- * as sending out mail, toggling flags etc ...
- *
- * @return bool true
+ * Quiz periodic clean-up tasks.
*/
function quiz_cron() {
- return true;
+
+ // Run cron for our sub-plugin types.
+ cron_execute_plugin_type('quiz', 'quiz reports');
+ cron_execute_plugin_type('quizaccess', 'quiz access rules');
}
/**
+++ /dev/null
-<?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 statistics report cron code.
- *
- * @package quiz
- * @subpackage statistics
- * @copyright 2008 Jamie Pratt
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-
-defined('MOODLE_INTERNAL') || die();
-
-
-/**
- * Quiz statistics report cron code. Deletes cached data more than a certain age.
- */
-function quiz_report_statistics_cron() {
- global $DB;
-
- $expiretime = time() - 5*HOURSECS;
- $todelete = $DB->get_records_select_menu('quiz_statistics', 'timemodified < ?',
- array($expiretime), '', 'id, 1');
-
- if (!$todelete) {
- return true;
- }
-
- list($todeletesql, $todeleteparams) = $DB->get_in_or_equal(array_keys($todelete));
-
- if (!$DB->delete_records_select('quiz_question_statistics',
- 'quizstatisticsid ' . $todeletesql, $todeleteparams)) {
- mtrace('Error deleting out of date quiz_question_statistics records.');
- }
-
- if (!$DB->delete_records_select('quiz_question_response_stats',
- 'quizstatisticsid ' . $todeletesql, $todeleteparams)) {
- mtrace('Error deleting out of date quiz_question_response_stats records.');
- }
-
- if (!$DB->delete_records_select('quiz_statistics',
- 'id ' . $todeletesql, $todeleteparams)) {
- mtrace('Error deleting out of date quiz_statistics records.');
- }
-
- return true;
-}
$record = new stdClass();
$record->name = 'statistics';
$record->displayorder = 8000;
- $record->cron = 18000;
$record->capability = 'quiz/statistics:view';
if ($dbman->table_exists('quiz_reports')) {
*/
+defined('MOODLE_INTERNAL') || die();
+
+
/**
* Serve questiontext files in the question text when they are displayed in this report.
* @param context $context the context
question_send_questiontext_file($questionid, $args, $forcedownload);
}
+
+/**
+* Quiz statistics report cron code. Deletes cached data more than a certain age.
+*/
+function quiz_report_statistics_cron() {
+ global $DB;
+
+ $expiretime = time() - 5*HOURSECS;
+ $todelete = $DB->get_records_select_menu('quiz_statistics', 'timemodified < ?',
+ array($expiretime), '', 'id, 1');
+
+ if (!$todelete) {
+ return true;
+ }
+
+ list($todeletesql, $todeleteparams) = $DB->get_in_or_equal(array_keys($todelete));
+
+ if (!$DB->delete_records_select('quiz_question_statistics',
+ 'quizstatisticsid ' . $todeletesql, $todeleteparams)) {
+ mtrace('Error deleting out of date quiz_question_statistics records.');
+ }
+
+ if (!$DB->delete_records_select('quiz_question_response_stats',
+ 'quizstatisticsid ' . $todeletesql, $todeleteparams)) {
+ mtrace('Error deleting out of date quiz_question_response_stats records.');
+ }
+
+ if (!$DB->delete_records_select('quiz_statistics',
+ 'id ' . $todeletesql, $todeleteparams)) {
+ mtrace('Error deleting out of date quiz_statistics records.');
+ }
+
+ return true;
+}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2011062600;
-$plugin->requires = 2011060313;
+$plugin->version = 2011062600;
+$plugin->requires = 2011060313;
+$plugin->cron = 18000;
$plugin->component = 'quiz_statistics';
--- /dev/null
+This files describes API changes for quiz report plugins.
+
+Overview of this plugin type at http://docs.moodle.org/dev/Quiz_reports
+
+
+=== earlier versions ===
+
+* ... API changes were not documented properly. Sorry. (There weren't many!)
+
+
+=== 2.2 ===
+
+* Plugins should be converted to implement cron in the standard way. In lib.php,
+define a
+function quiz_myreportname_cron() {};
+This replaces the old way of having a separate cron.php file. Also, the cron
+frequency should be defined in version.php, not in the quiz_reports table.
+
+
+=== 2.3 ===
+
+* Support for the old way of doing cron in a separate cron.php file has been removed.
defined('MOODLE_INTERNAL') || die();
-$module->version = 2011112900; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2011120701; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2011112900; // Requires this Moodle version
$module->component = 'mod_quiz'; // Full name of the plugin (used for diagnostics)
$module->cron = 0;
is_compatible_question method. You should change your behaviour to override the
new method, not the old one. This change has been implemented in a
backwards-compatible way, so behaviours will not break.
+
+
+=== 2.3 ===
+
+* This plugin type now supports cron in the standard way. If required, Create a
+ lib.php file containing
+function qbehaviour_mypluginname_cron() {};
$string['pluginname'] = 'Aiken format';
$string['pluginname_help'] = 'This is a simple format ...';
$string['pluginname_link'] = 'qformat/aiken';
+
+
+=== 2.3 ===
+
+* This plugin type now supports cron in the standard way. If required, Create a
+ lib.php file containing
+function qformat_mypluginname_cron() {};
This files describes API changes for question type plugins.
+=== 2.0 ===
+
+* Lots of changes due to all the API changes in Moodle 2.0.
+
+* This plugin type now supports cron in the standard way. If required, Create a
+ lib.php file containing
+function qtype_mypluginname_cron() {};
+
+
+=== 2.1 ===
+
+* Lots of API changes due to the new question engine. See
+http://docs.moodle.org/dev/Developing_a_Question_Type#Converting_a_Moodle_2.0_question_type
+
+
=== 2.2 ===
* The XML import/export base class has had some minor API changes. The