Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-37781 Check for switching the workshop phase without waiting for …

…cron

Now we are checking for the need to switch the phase when the main
view.php is displayed to any user (previously this was done via cron
only). To give our subplugins (such as the scheduled allocation method)
a chance to do what they need to do, the workshop_viewed event is
triggered before the phase is actually switched.
  • Loading branch information...
commit 85f1c2d68bb7ae65a347f3e9d1d82af85e169151 1 parent b3778a0
David Mudrák mudrd8mz authored

Showing 2 changed files with 20 additions and 2 deletions. Show diff stats Hide diff stats

  1. +2 2 mod/workshop/version.php
  2. +18 0 mod/workshop/view.php
4 mod/workshop/version.php
@@ -24,7 +24,7 @@
24 24
25 25 defined('MOODLE_INTERNAL') || die();
26 26
27   -$module->version = 2012112900; // the current module version (YYYYMMDDXX)
28   -$module->requires = 2012112900; // requires this Moodle version
  27 +$module->version = 2013013100; // the current module version (YYYYMMDDXX)
  28 +$module->requires = 2013012500; // requires this Moodle version
29 29 $module->component = 'mod_workshop'; // full name of the plugin (used for diagnostics)
30 30 $module->cron = 60; // give as a chance every minute
18 mod/workshop/view.php
@@ -60,6 +60,24 @@
60 60 $completion = new completion_info($course);
61 61 $completion->set_module_viewed($cm);
62 62
  63 +// Fire the event
  64 +events_trigger('workshop_viewed', (object)array(
  65 + 'workshop' => $workshop,
  66 + 'user' => $USER,
  67 +));
  68 +
  69 +// If the phase is to be switched, do it asap. This just has to happen after triggering
  70 +// the event so that the scheduled allocator had a chance to allocate submissions.
  71 +if ($workshop->phase == workshop::PHASE_SUBMISSION and $workshop->phaseswitchassessment
  72 + and $workshop->submissionend > 0 and $workshop->submissionend < time()) {
  73 + $workshop->switch_phase(workshop::PHASE_ASSESSMENT);
  74 + $workshop->log('update switch phase', $workshop->view_url(), $workshop->phase);
  75 + // Disable the automatic switching now so that it is not executed again by accident
  76 + // if the teacher changes the phase back to the submission one.
  77 + $DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id));
  78 + $workshop->phaseswitchassessment = 0;
  79 +}
  80 +
63 81 if (!is_null($editmode) && $PAGE->user_allowed_editing()) {
64 82 $USER->editing = $editmode;
65 83 }

0 comments on commit 85f1c2d

Please sign in to comment.
Something went wrong with that request. Please try again.