/** * 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(); setask::cron(); // Now create an setaskment with marking workflow enabled. $this->setUser($this->editingteachers[0]); $setask = $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; $setask->testable_apply_grade_to_user($data, $this->students[0]->id, 0); // This student will receive notification. $data->workflowstate = ASSIGN_MARKING_WORKFLOW_STATE_RELEASED; $setask->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 setaskment submissions/'); setask::cron(); $messages = $sink->get_messages(); $this->assertEquals(1, count($messages)); $this->assertEquals($messages[0]->useridto, $this->students[1]->id); $this->assertEquals($setask->get_instance()->name, $messages[0]->contexturlname); }
/** * Call cron on the setask module. */ function setask_cron() { global $CFG; require_once $CFG->dirroot . '/mod/setask/locallib.php'; setask::cron(); $plugins = core_component::get_plugin_list('setasksubmission'); foreach ($plugins as $name => $plugin) { $disabled = get_config('setasksubmission_' . $name, 'disabled'); if (!$disabled) { $class = 'setask_submission_' . $name; require_once $CFG->dirroot . '/mod/setask/submission/' . $name . '/locallib.php'; $class::cron(); } } $plugins = core_component::get_plugin_list('setaskfeedback'); foreach ($plugins as $name => $plugin) { $disabled = get_config('setaskfeedback_' . $name, 'disabled'); if (!$disabled) { $class = 'setask_feedback_' . $name; require_once $CFG->dirroot . '/mod/setask/feedback/' . $name . '/locallib.php'; $class::cron(); } } return true; }