本文整理汇总了PHP中cron_execute_plugin_type函数的典型用法代码示例。如果您正苦于以下问题:PHP cron_execute_plugin_type函数的具体用法?PHP cron_execute_plugin_type怎么用?PHP cron_execute_plugin_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cron_execute_plugin_type函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: workshop_cron
/**
* Regular jobs to execute via cron
*
* @return boolean true on success, false otherwise
*/
function workshop_cron() {
global $CFG, $DB;
$now = time();
mtrace(' processing workshop subplugins ...');
cron_execute_plugin_type('workshopallocation', 'workshop allocation methods');
// now when the scheduled allocator had a chance to do its job, check if there
// are some workshops to switch into the assessment phase
$workshops = $DB->get_records_select("workshop",
"phase = 20 AND phaseswitchassessment = 1 AND submissionend > 0 AND submissionend < ?", array($now));
if (!empty($workshops)) {
mtrace('Processing automatic assessment phase switch in '.count($workshops).' workshop(s) ... ', '');
require_once($CFG->dirroot.'/mod/workshop/locallib.php');
foreach ($workshops as $workshop) {
$cm = get_coursemodule_from_instance('workshop', $workshop->id, $workshop->course, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$workshop = new workshop($workshop, $cm, $course);
$workshop->switch_phase(workshop::PHASE_ASSESSMENT);
$workshop->log('update switch phase', $workshop->view_url(), $workshop->phase);
// disable the automatic switching now so that it is not executed again by accident
// if the teacher changes the phase back to the submission one
$DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id));
// todo inform the teachers
}
mtrace('done');
}
return true;
}
示例2: cron_run
//.........这里部分代码省略.........
@set_time_limit(0);
mtrace("done.");
}
}
}
}
get_mailer('close');
mtrace("Finished activity modules");
mtrace("Starting blocks");
if ($blocks = $DB->get_records_select("block", "cron > 0 AND ((? - lastcron) > cron) AND visible = 1", array($timenow))) {
// We will need the base class.
require_once $CFG->dirroot . '/blocks/moodleblock.class.php';
foreach ($blocks as $block) {
$blockfile = $CFG->dirroot . '/blocks/' . $block->name . '/block_' . $block->name . '.php';
if (file_exists($blockfile)) {
require_once $blockfile;
$classname = 'block_' . $block->name;
$blockobj = new $classname();
if (method_exists($blockobj, 'cron')) {
mtrace("Processing cron function for " . $block->name . '....', '');
cron_trace_time_and_memory();
if ($blockobj->cron()) {
$DB->set_field('block', 'lastcron', $timenow, array('id' => $block->id));
}
// Reset possible changes by blocks to time_limit. MDL-11597
@set_time_limit(0);
mtrace('done.');
}
}
}
}
mtrace('Finished blocks');
mtrace('Starting admin reports');
cron_execute_plugin_type('report');
mtrace('Finished admin reports');
mtrace('Starting main gradebook job...');
cron_trace_time_and_memory();
grade_cron();
mtrace('done.');
mtrace('Starting processing the event queue...');
cron_trace_time_and_memory();
events_cron();
mtrace('done.');
if ($CFG->enablecompletion) {
// Completion cron
mtrace('Starting the completion cron...');
cron_trace_time_and_memory();
require_once $CFG->dirroot . '/completion/cron.php';
completion_cron();
mtrace('done');
}
if ($CFG->enableportfolios) {
// Portfolio cron
mtrace('Starting the portfolio cron...');
cron_trace_time_and_memory();
require_once $CFG->libdir . '/portfoliolib.php';
portfolio_cron();
mtrace('done');
}
//now do plagiarism checks
require_once $CFG->libdir . '/plagiarismlib.php';
plagiarism_cron();
mtrace('Starting course reports');
cron_execute_plugin_type('coursereport');
mtrace('Finished course reports');
// run gradebook import/export/report cron
示例3: quiz_cron
/**
* Quiz periodic clean-up tasks.
*/
function quiz_cron()
{
global $CFG;
require_once $CFG->dirroot . '/mod/quiz/cronlib.php';
mtrace('');
$timenow = time();
$overduehander = new mod_quiz_overdue_attempt_updater();
$processto = $timenow - get_config('quiz', 'graceperiodmin');
mtrace(' Looking for quiz overdue quiz attempts...');
list($count, $quizcount) = $overduehander->update_overdue_attempts($timenow, $processto);
mtrace(' Considered ' . $count . ' attempts in ' . $quizcount . ' quizzes.');
// Run cron for our sub-plugin types.
cron_execute_plugin_type('quiz', 'quiz reports');
cron_execute_plugin_type('quizaccess', 'quiz access rules');
return true;
}
示例4: quiz_cron
/**
* Quiz periodic clean-up tasks.
*/
function quiz_cron() {
global $CFG;
mtrace('');
// Since the quiz specifies $module->cron = 60, so that the subplugins can
// have frequent cron if they need it, we now need to do our own scheduling.
$quizconfig = get_config('quiz');
if (!isset($quizconfig->overduelastrun)) {
$quizconfig->overduelastrun = 0;
$quizconfig->overduedoneto = 0;
}
$timenow = time();
if ($timenow > $quizconfig->overduelastrun + 3600) {
require_once($CFG->dirroot . '/mod/quiz/cronlib.php');
$overduehander = new mod_quiz_overdue_attempt_updater();
$processto = $timenow - $quizconfig->graceperiodmin;
mtrace(' Looking for quiz overdue quiz attempts between ' .
userdate($quizconfig->overduedoneto) . ' and ' . userdate($processto) . '...');
list($count, $quizcount) = $overduehander->update_overdue_attempts($timenow, $quizconfig->overduedoneto, $processto);
set_config('overduelastrun', $timenow, 'quiz');
set_config('overduedoneto', $processto, 'quiz');
mtrace(' Considered ' . $count . ' attempts in ' . $quizcount . ' quizzes.');
}
// Run cron for our sub-plugin types.
cron_execute_plugin_type('quiz', 'quiz reports');
cron_execute_plugin_type('quizaccess', 'quiz access rules');
return true;
}
示例5: offlinequiz_cron
/**
* 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 ...
*
* Note: The evaluation of answer forms is done by a separate cron job using the script mod/offlinequiz/cron.php.
*
**/
function offlinequiz_cron()
{
global $DB;
cron_execute_plugin_type('offlinequiz', 'offlinequiz reports');
// Remove all saved hotspot data that is older than 7 days.
$timenow = time();
// We have to make sure we do this atomic for each scanned page.
$sql = "SELECT DISTINCT(scannedpageid)\n FROM {offlinequiz_hotspots}\n WHERE time < :expiretime";
$params = array('expiretime' => $timenow - 604800);
// First we get the different IDs.
$ids = $DB->get_fieldset_sql($sql, $params);
if (!empty($ids)) {
list($isql, $iparams) = $DB->get_in_or_equal($ids);
// Now we delete the records.
$DB->delete_records_select('offlinequiz_hotspots', 'scannedpageid ' . $isql, $iparams);
}
// Delete old temporary files not needed any longer.
$keepdays = get_config('offlinequiz', 'keepfilesfordays');
$keepseconds = $keepdays * 24 * 60 * 60;
$sql = "SELECT id\n FROM {offlinequiz_queue}\n WHERE timecreated < :expiretime";
$params = array('expiretime' => $timenow - $keepseconds);
// First we get the IDs of cronjobs older than the configured number of days.
$jobids = $DB->get_fieldset_sql($sql, $params);
foreach ($jobids as $jobid) {
$dirname = null;
// Delete all temporary files and the database entries.
if ($files = $DB->get_records('offlinequiz_queue_data', array('queueid' => $jobid))) {
foreach ($files as $file) {
if (empty($dirname)) {
$pathparts = pathinfo($file->filename);
$dirname = $pathparts['dirname'];
}
$DB->delete_records('offlinequiz_queue_data', array('id' => $file->id));
}
// Remove the temporary directory.
echo "Removing dir " . $dirname . "\n";
remove_dir($dirname);
}
}
return true;
}
示例6: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG, $DB;
$timenow = time();
// Run the auth cron, if any before enrolments
// because it might add users that will be needed in enrol plugins.
$auths = get_enabled_auth_plugins();
mtrace("Running auth crons if required...");
foreach ($auths as $auth) {
$authplugin = get_auth_plugin($auth);
if (method_exists($authplugin, 'cron')) {
mtrace("Running cron for auth/{$auth}...");
$authplugin->cron();
if (!empty($authplugin->log)) {
mtrace($authplugin->log);
}
}
unset($authplugin);
}
// It is very important to run enrol early
// because other plugins depend on correct enrolment info.
mtrace("Running enrol crons if required...");
$enrols = enrol_get_plugins(true);
foreach ($enrols as $ename => $enrol) {
// Do this for all plugins, disabled plugins might want to cleanup stuff such as roles.
if (!$enrol->is_cron_required()) {
continue;
}
mtrace("Running cron for enrol_{$ename}...");
$enrol->cron();
$enrol->set_config('lastcron', time());
}
// Run all cron jobs for each module.
mtrace("Starting activity modules");
if ($mods = $DB->get_records_select("modules", "cron > 0 AND ((? - lastcron) > cron) AND visible = 1", array($timenow))) {
foreach ($mods as $mod) {
$libfile = "{$CFG->dirroot}/mod/{$mod->name}/lib.php";
if (file_exists($libfile)) {
include_once $libfile;
$cronfunction = $mod->name . "_cron";
if (function_exists($cronfunction)) {
mtrace("Processing module function {$cronfunction} ...\n", '');
$predbqueries = null;
$predbqueries = $DB->perf_get_queries();
$pretime = microtime(1);
if ($cronfunction()) {
$DB->set_field("modules", "lastcron", $timenow, array("id" => $mod->id));
}
if (isset($predbqueries)) {
mtrace("... used " . ($DB->perf_get_queries() - $predbqueries) . " dbqueries");
mtrace("... used " . (microtime(1) - $pretime) . " seconds");
}
// Reset possible changes by modules to time_limit. MDL-11597.
\core_php_time_limit::raise();
mtrace("done.");
}
}
}
}
mtrace("Finished activity modules");
mtrace("Starting blocks");
if ($blocks = $DB->get_records_select("block", "cron > 0 AND ((? - lastcron) > cron) AND visible = 1", array($timenow))) {
// We will need the base class.
require_once $CFG->dirroot . '/blocks/moodleblock.class.php';
foreach ($blocks as $block) {
$blockfile = $CFG->dirroot . '/blocks/' . $block->name . '/block_' . $block->name . '.php';
if (file_exists($blockfile)) {
require_once $blockfile;
$classname = '\\block_' . $block->name;
$blockobj = new $classname();
if (method_exists($blockobj, 'cron')) {
mtrace("Processing cron function for " . $block->name . '....', '');
if ($blockobj->cron()) {
$DB->set_field('block', 'lastcron', $timenow, array('id' => $block->id));
}
// Reset possible changes by blocks to time_limit. MDL-11597.
\core_php_time_limit::raise();
mtrace('done.');
}
}
}
}
mtrace('Finished blocks');
mtrace('Starting admin reports');
cron_execute_plugin_type('report');
mtrace('Finished admin reports');
mtrace('Starting course reports');
cron_execute_plugin_type('coursereport');
mtrace('Finished course reports');
// Run gradebook import/export/report cron.
mtrace('Starting gradebook plugins');
cron_execute_plugin_type('gradeimport');
cron_execute_plugin_type('gradeexport');
cron_execute_plugin_type('gradereport');
mtrace('Finished gradebook plugins');
// All other plugins.
//.........这里部分代码省略.........
示例7: cron_run
//.........这里部分代码省略.........
@set_time_limit(0);
mtrace('done.');
}
}
}
}
mtrace('Finished blocks');
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");
}
mtrace("done.");
}
}
}
}
mtrace("Finished quiz reports");
mtrace('Starting admin reports');
cron_execute_plugin_type('report');
mtrace('Finished admin reports');
mtrace('Starting main gradebook job ...');
grade_cron();
mtrace('done.');
mtrace('Starting processing the event queue...');
events_cron();
mtrace('done.');
if ($CFG->enablecompletion) {
// Completion cron
mtrace('Starting the completion cron...');
require_once $CFG->libdir . '/completion/cron.php';
completion_cron();
mtrace('done');
}
if ($CFG->enableportfolios) {
// Portfolio cron
mtrace('Starting the portfolio cron...');
require_once $CFG->libdir . '/portfoliolib.php';
portfolio_cron();
mtrace('done');
}
//now do plagiarism checks
require_once $CFG->libdir . '/plagiarismlib.php';
plagiarism_cron();
/// Run all core cron jobs, but not every time since they aren't too important.
/// These don't have a timer to reduce load, so we'll use a random number
/// to randomly choose the percentage of times we should run these jobs.
srand((double) microtime() * 10000000);
$random100 = rand(0, 100);
if ($random100 < 20) {
// Approximately 20% of the time.
mtrace("Running clean-up tasks...");
示例8: teamwork_cron
/**
* Regular jobs to execute via cron
*
* @return boolean true on success, false otherwise
*/
function teamwork_cron()
{
global $CFG, $DB;
$now = time();
mtrace(' processing teamwork subplugins ...');
cron_execute_plugin_type('teamworkallocation', 'teamwork allocation methods');
// now when the scheduled allocator had a chance to do its job, check if there
// are some teamworks to switch into the assessment phase
$teamworks = $DB->get_records_select("teamwork", "phase = 20 AND phaseswitchassessment = 1 AND submissionend > 0 AND submissionend < ?", array($now));
if (!empty($teamworks)) {
mtrace('Processing automatic assessment phase switch in ' . count($teamworks) . ' teamwork(s) ... ', '');
require_once $CFG->dirroot . '/mod/teamwork/locallib.php';
foreach ($teamworks as $teamwork) {
$cm = get_coursemodule_from_instance('teamwork', $teamwork->id, $teamwork->course, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$teamwork = new teamwork($teamwork, $cm, $course);
$teamwork->switch_phase(teamwork::PHASE_ASSESSMENT);
$params = array('objectid' => $teamwork->id, 'context' => $teamwork->context, 'courseid' => $teamwork->course->id, 'other' => array('teamworkphase' => $teamwork->phase));
$event = \mod_teamwork\event\phase_switched::create($params);
$event->trigger();
// disable the automatic switching now so that it is not executed again by accident
// if the teacher changes the phase back to the submission one
$DB->set_field('teamwork', 'phaseswitchassessment', 0, array('id' => $teamwork->id));
// todo inform the teachers
}
mtrace('done');
}
return true;
}