]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14208 "add cron routine to clean up cache records"
authorjamiesensei <jamiesensei>
Thu, 24 Jul 2008 17:45:01 +0000 (17:45 +0000)
committerjamiesensei <jamiesensei>
Thu, 24 Jul 2008 17:45:01 +0000 (17:45 +0000)
mod/quiz/report/statistics/cron.php [new file with mode: 0644]
mod/quiz/report/statistics/db/upgrade.php [new file with mode: 0644]
mod/quiz/report/statistics/version.php

diff --git a/mod/quiz/report/statistics/cron.php b/mod/quiz/report/statistics/cron.php
new file mode 100644 (file)
index 0000000..0c4537b
--- /dev/null
@@ -0,0 +1,15 @@
+<?php  // $Id$
+function quiz_report_statistics_cron(){
+    global $DB;
+    if ($todelete = $DB->get_records_select_menu('quiz_statistics', 'timemodified < ?', array(time()-5*HOURSECS))){
+        list($todeletesql, $todeleteparams) = $DB->get_in_or_equal($todelete);
+        if (!$DB->delete_records_select('quiz_statistics', "id $todeletesql", $todeleteparams)){
+            mtrace('Error deleting out of date quiz_statistics records.');
+        }
+        if (!$DB->delete_records_select('quiz_question_statistics', "quizstatisticsid $todeletesql", $todeleteparams)){
+            mtrace('Error deleting out of date quiz_question_statistics records.');
+        }
+    }
+    return true;
+}
+?>
diff --git a/mod/quiz/report/statistics/db/upgrade.php b/mod/quiz/report/statistics/db/upgrade.php
new file mode 100644 (file)
index 0000000..23c5e2f
--- /dev/null
@@ -0,0 +1,20 @@
+<?php  // $Id$
+
+function xmldb_quizreport_statistics_upgrade($oldversion=0) {
+
+    global $DB;
+    
+    $dbman = $DB->get_manager();
+
+    $result = true;
+
+//===== 1.9.0 upgrade line ======//
+
+    if ($result && $oldversion < 2008072401) {
+        //register cron to run every 5 hours.
+        $result = $result && $DB->set_field('quiz_report', 'cron', HOURSECS*5, array('name'=>'statistics'));
+    }
+    return $result;
+}
+
+?>
index 45cd43c6f590c744e4a6985f1a3369ed85b08833..f872ee95f146951b9c74da87fc40ad177fa14cf2 100644 (file)
@@ -1,4 +1,4 @@
 <?php
-$plugin->version  = 2008072400;   // The (date) version of this module
+$plugin->version  = 2008072401;   // The (date) version of this module
 
 ?>
\ No newline at end of file