diff --git a/mod/workshop/version.php b/mod/workshop/version.php index e442c137d45..ef4f5d236da 100644 --- a/mod/workshop/version.php +++ b/mod/workshop/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$module->version = 2012112900; // the current module version (YYYYMMDDXX) +$module->version = 2012112901; // the current module version (YYYYMMDDXX) $module->requires = 2012112900; // requires this Moodle version $module->component = 'mod_workshop'; // full name of the plugin (used for diagnostics) $module->cron = 60; // give as a chance every minute diff --git a/mod/workshop/view.php b/mod/workshop/view.php index fbcbc469146..37168ce144e 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -60,6 +60,24 @@ $workshop->log('view'); $completion = new completion_info($course); $completion->set_module_viewed($cm); +// Fire the event +events_trigger('workshop_viewed', (object)array( + 'workshop' => $workshop, + 'user' => $USER, +)); + +// If the phase is to be switched, do it asap. This just has to happen after triggering +// the event so that the scheduled allocator had a chance to allocate submissions. +if ($workshop->phase == workshop::PHASE_SUBMISSION and $workshop->phaseswitchassessment + and $workshop->submissionend > 0 and $workshop->submissionend < time()) { + $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)); + $workshop->phaseswitchassessment = 0; +} + if (!is_null($editmode) && $PAGE->user_allowed_editing()) { $USER->editing = $editmode; }