From: David Mudrak Date: Mon, 4 Jan 2010 18:28:02 +0000 (+0000) Subject: workshop 2.0: implement phase-related allowers X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=74bf8a947fc5a5d5009af58205b883ccca743c6c;p=moodle.git workshop 2.0: implement phase-related allowers --- diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index 0ea77b315c..74f4795c56 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -744,34 +744,70 @@ class workshop { /** * Are users allowed to create/edit their submissions? * - * TODO: this depends on the workshop phase, phase deadlines, submitting after deadlines possibility - * * @return bool */ public function submitting_allowed() { + if ($this->phase != self::PHASE_SUBMISSION) { + // submitting is not allowed but in the submission phase + return false; + } + $now = time(); + if (!empty($this->submissionstart) and $this->submissionstart > $now) { + // if enabled, submitting is not allowed before the date/time defined in the mod_form + return false; + } + if (!empty($this->submissionend) and empty($this->latesubmissions) and $now > $this->submissionend ) { + // if enabled, submitting is not allowed after the date/time defined in the mod_form unless late submission is allowed + return false; + } + // here we go, submission is allowed return true; } /** * Are reviewers allowed to create/edit their assessments? * - * TODO: this depends on the workshop phase, phase deadlines - * * @return bool */ public function assessing_allowed() { + if ($this->phase != self::PHASE_ASSESSMENT) { + // assessing is not allowed but in the assessment phase + return false; + } + $now = time(); + if (!empty($this->assessmentstart) and $this->assessmentstart > $now) { + // if enabled, assessing is not allowed before the date/time defined in the mod_form + return false; + } + if (!empty($this->assessmentend) and $now > $this->assessmentend ) { + // if enabled, assessing is not allowed after the date/time defined in the mod_form + return false; + } + // here we go, assessing is allowed return true; } /** * Are reviewers allowed to create/edit their assessments of the example submissions? * - * TODO: this depends on the workshop phase, phase deadlines + * Note this does not check other conditions like the number of already submitted examples etc. * - * @return bool + * @return null|bool */ public function assessing_examples_allowed() { - return true; + if (empty($this->useexamples)) { + return null; + } + if (self::EXAMPLES_VOLUNTARY == $this->examplesmode) { + return true; + } + if (self::EXAMPLES_BEFORE_SUBMISSION == $this->examplesmode and self::PHASE_SUBMISSION == $this->phase) { + return true; + } + if (self::EXAMPLES_BEFORE_ASSESSMENT == $this->examplesmode and self::PHASE_ASSESSMENT == $this->phase) { + return true; + } + return false; } /**