MDL-64881 mod_workshop: remove legacy workshop_cron() function

This commit is contained in:
Simey Lameze
2019-03-05 06:35:35 +08:00
parent 29bddab8c8
commit 8c0f43c477
2 changed files with 0 additions and 51 deletions
-50
View File
@@ -1056,56 +1056,6 @@ function workshop_print_recent_mod_activity($activity, $courseid, $detail, $modn
echo html_writer::empty_tag('br', array('style'=>'clear:both'));
}
/**
* 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);
$params = array(
'objectid' => $workshop->id,
'context' => $workshop->context,
'courseid' => $workshop->course->id,
'other' => array(
'workshopphase' => $workshop->phase
)
);
$event = \mod_workshop\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('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id));
// todo inform the teachers
}
mtrace('done');
}
return true;
}
/**
* Is a given scale used by the instance of workshop?
*
-1
View File
@@ -27,4 +27,3 @@ defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018120301; // The current module version (YYYYMMDDXX)
$plugin->requires = 2018112800; // Requires this Moodle version.
$plugin->component = 'mod_workshop';
$plugin->cron = 60; // Give as a chance every minute.