本文整理汇总了PHP中assign::cron方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::cron方法的具体用法?PHP assign::cron怎么用?PHP assign::cron使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assign
的用法示例。
在下文中一共展示了assign::cron方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assign_cron
/**
* Call cron on the assign module
*/
function assign_cron()
{
global $CFG;
require_once $CFG->dirroot . '/mod/assign/locallib.php';
assign::cron();
$plugins = get_plugin_list('assignsubmission');
foreach ($plugins as $name => $plugin) {
$disabled = get_config('assignsubmission_' . $name, 'disabled');
if (!$disabled) {
$class = 'assign_submission_' . $name;
require_once $CFG->dirroot . '/mod/assign/submission/' . $name . '/locallib.php';
$class::cron();
}
}
$plugins = get_plugin_list('assignfeedback');
foreach ($plugins as $name => $plugin) {
$disabled = get_config('assignfeedback_' . $name, 'disabled');
if (!$disabled) {
$class = 'assign_feedback_' . $name;
require_once $CFG->dirroot . '/mod/assign/feedback/' . $name . '/locallib.php';
$class::cron();
}
}
}
示例2: test_markingworkflow_cron
/**
* Test delivery of grade notifications as controlled by marking workflow.
*/
public function test_markingworkflow_cron()
{
// First run cron so there are no messages waiting to be sent (from other tests).
cron_setup_user();
assign::cron();
// Now create an assignment with marking workflow enabled.
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance(array('sendstudentnotifications' => 1, 'markingworkflow' => 1));
// Simulate adding a grade.
$this->setUser($this->teachers[0]);
$data = new stdClass();
$data->grade = '50.0';
// This student will not receive notification.
$data->workflowstate = ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE;
$assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
// This student will receive notification.
$data->workflowstate = ASSIGN_MARKING_WORKFLOW_STATE_RELEASED;
$assign->testable_apply_grade_to_user($data, $this->students[1]->id, 0);
// Now run cron and see that one message was sent.
$this->preventResetByRollback();
$sink = $this->redirectMessages();
cron_setup_user();
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
assign::cron();
$messages = $sink->get_messages();
$this->assertEquals(1, count($messages));
$this->assertEquals($messages[0]->useridto, $this->students[1]->id);
$this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
}
示例3: test_cron
public function test_cron()
{
// First run cron so there are no messages waiting to be sent (from other tests).
cron_setup_user();
assign::cron();
// Now create an assignment and add some feedback.
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance(array('sendstudentnotifications' => 1));
// Simulate adding a grade.
$this->setUser($this->teachers[0]);
$data = new stdClass();
$data->grade = '50.0';
$assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
$assign->testable_apply_grade_to_user($data, $this->students[1]->id, 0);
$data->sendstudentnotifications = false;
$assign->testable_apply_grade_to_user($data, $this->students[2]->id, 0);
// Now run cron and see that one message was sent.
$this->preventResetByRollback();
$sink = $this->redirectMessages();
cron_setup_user();
$this->expectOutputRegex('/Done processing 2 assignment submissions/');
assign::cron();
$messages = $sink->get_messages();
// The sent count should be 2, because the 3rd one was marked as do not send notifications.
$this->assertEquals(2, count($messages));
$this->assertEquals(1, $messages[0]->notification);
$this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
}
示例4: test_cron_message_includes_courseid
public function test_cron_message_includes_courseid()
{
// First run cron so there are no messages waiting to be sent (from other tests).
cron_setup_user();
assign::cron();
// Now create an assignment.
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance(array('sendstudentnotifications' => 1));
// Simulate adding a grade.
$this->setUser($this->teachers[0]);
$data = new stdClass();
$data->grade = '50.0';
$assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
$this->preventResetByRollback();
$sink = $this->redirectEvents();
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
assign::cron();
$events = $sink->get_events();
// Two messages are sent, one to student and one to teacher. This generates
// four events:
// core\event\message_sent
// core\event\message_viewed
// core\event\message_sent
// core\event\message_viewed.
$event = reset($events);
$this->assertInstanceOf('\\core\\event\\message_sent', $event);
$this->assertEquals($assign->get_course()->id, $event->other['courseid']);
$sink->close();
}