本文整理汇总了PHP中grade_cron函数的典型用法代码示例。如果您正苦于以下问题:PHP grade_cron函数的具体用法?PHP grade_cron怎么用?PHP grade_cron使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了grade_cron函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cron_run
//.........这里部分代码省略.........
mtrace("... used " . (microtime(1) - $pre_time) . " seconds");
}
mtrace("done.");
}
}
}
}
mtrace("Finished quiz reports");
mtrace('Starting admin reports');
// Admin reports do not have a database table that lists them. Instead a
// report includes cron.php with function report_reportname_cron() if it wishes
// to be cronned. It is up to cron.php to handle e.g. if it only needs to
// actually do anything occasionally.
$reports = get_plugin_list('report');
foreach ($reports as $report => $reportdir) {
$cronfile = $reportdir . '/cron.php';
if (file_exists($cronfile)) {
require_once $cronfile;
$cronfunction = 'report_' . $report . '_cron';
mtrace('Processing cron function for ' . $report . '...', '');
$pre_dbqueries = null;
$pre_dbqueries = $DB->perf_get_queries();
$pre_time = microtime(true);
$cronfunction();
if (isset($pre_dbqueries)) {
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
mtrace("... used " . round(microtime(true) - $pre_time, 2) . " seconds");
}
mtrace('done.');
}
}
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');
}
/// 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...");
/// Delete users who haven't confirmed within required period
if (!empty($CFG->deleteunconfirmed)) {
$cuttime = $timenow - $CFG->deleteunconfirmed * 3600;
$rs = $DB->get_recordset_sql("SELECT id, firstname, lastname\n FROM {user}\n WHERE confirmed = 0 AND firstaccess > 0\n AND firstaccess < ?", array($cuttime));
foreach ($rs as $user) {
if ($DB->delete_records('user', array('id' => $user->id))) {
示例2: cron_run
//.........这里部分代码省略.........
}
}
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
mtrace('Starting gradebook plugins');
cron_execute_plugin_type('gradeimport');
cron_execute_plugin_type('gradeexport');
cron_execute_plugin_type('gradereport');
示例3: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG;
require_once $CFG->libdir . '/gradelib.php';
grade_cron();
}