|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00027 defined('MOODLE_INTERNAL') || die(); 00028 00029 00037 function quiz_statistics_questiontext_preview_pluginfile($context, $questionid, $args, $forcedownload) { 00038 global $CFG; 00039 require_once($CFG->dirroot . '/mod/quiz/locallib.php'); 00040 00041 list($context, $course, $cm) = get_context_info_array($context->id); 00042 require_login($course, false, $cm); 00043 00044 // Assume only trusted people can see this report. There is no real way to 00045 // validate questionid, becuase of the complexity of random quetsions. 00046 require_capability('quiz/statistics:view', $context); 00047 00048 question_send_questiontext_file($questionid, $args, $forcedownload); 00049 } 00050 00054 function quiz_statistics_cron() { 00055 global $DB; 00056 00057 $expiretime = time() - 5*HOURSECS; 00058 $todelete = $DB->get_records_select_menu('quiz_statistics', 00059 'timemodified < ?', array($expiretime), '', 'id, 1'); 00060 00061 if (!$todelete) { 00062 return true; 00063 } 00064 00065 list($todeletesql, $todeleteparams) = $DB->get_in_or_equal(array_keys($todelete)); 00066 00067 $DB->delete_records_select('quiz_question_statistics', 00068 'quizstatisticsid ' . $todeletesql, $todeleteparams); 00069 00070 $DB->delete_records_select('quiz_question_response_stats', 00071 'quizstatisticsid ' . $todeletesql, $todeleteparams); 00072 00073 $DB->delete_records_select('quiz_statistics', 00074 'id ' . $todeletesql, $todeleteparams); 00075 00076 return true; 00077 }