Permalink
Browse files

Merge branch 'MDL-26147-workshop-ignore-deadlines' of git://github.co…

…m/mudrd8mz/moodle
  • Loading branch information...
2 parents 0723dca + 9ddff58 commit f44c912bd0aa0164c91246b98d7f69fc423b1e9a Sam Hemelryk committed Jun 13, 2011
@@ -75,7 +75,7 @@
}
// only the reviewer is allowed to modify the assessment
-if ($isreviewer and $workshop->assessing_allowed()) {
+if ($isreviewer and $workshop->assessing_allowed($USER->id)) {
$assessmenteditable = true;
} else {
$assessmenteditable = false;
View
@@ -206,4 +206,15 @@
)
),
+ // Ability to ignore time restrictions (submission start/end time and assessment
+ // start/end time) if they are defined
+ 'mod/workshop:ignoredeadlines' => array(
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'archetypes' => array(
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'manager' => CAP_ALLOW
+ )
+ ),
);
@@ -83,6 +83,7 @@
$string['daystoday'] = 'today';
$string['daystomorrow'] = 'tomorrow';
$string['daysyesterday'] = 'yesterday';
+$string['deadlinesignored'] = 'Time restrictions do not apply to you';
$string['editassessmentform'] = 'Edit assessment form';
$string['editassessmentformstrategy'] = 'Edit assessment form ({$a})';
$string['editingassessmentform'] = 'Editing assessment form';
@@ -249,6 +250,7 @@
$string['workshop:allocate'] = 'Allocate submissions for review';
$string['workshop:editdimensions'] = 'Edit assessment forms';
$string['workshopfeatures'] = 'Workshop features';
+$string['workshop:ignoredeadlines'] = 'Ignore time restrictions';
$string['workshop:manageexamples'] = 'Manage example submissions';
$string['workshopname'] = 'Workshop name';
$string['workshop:overridegrades'] = 'Override calculated grades';
View
@@ -1115,19 +1115,22 @@ public function log($action, moodle_url $url = null, $info = null) {
}
/**
- * Are users allowed to create their submissions?
+ * Is the given user allowed to create their submission?
*
+ * @param int $userid
* @return bool
*/
- public function creating_submission_allowed() {
+ public function creating_submission_allowed($userid) {
+
$now = time();
+ $ignoredeadlines = has_capability('mod/workshop:ignoredeadlines', $this->context, $userid);
if ($this->latesubmissions) {
if ($this->phase != self::PHASE_SUBMISSION and $this->phase != self::PHASE_ASSESSMENT) {
// late submissions are allowed in the submission and assessment phase only
return false;
}
- if (!empty($this->submissionstart) and $this->submissionstart > $now) {
+ if (!$ignoredeadlines and !empty($this->submissionstart) and $this->submissionstart > $now) {
// late submissions are not allowed before the submission start
return false;
}
@@ -1138,11 +1141,11 @@ public function creating_submission_allowed() {
// submissions are allowed during the submission phase only
return false;
}
- if (!empty($this->submissionstart) and $this->submissionstart > $now) {
+ if (!$ignoredeadlines and !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 $now > $this->submissionend ) {
+ if (!$ignoredeadlines and !empty($this->submissionend) 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;
}
@@ -1151,44 +1154,52 @@ public function creating_submission_allowed() {
}
/**
- * Are users allowed to modify their existing submission?
+ * Is the given user allowed to modify their existing submission?
*
+ * @param int $userid
* @return bool
*/
- public function modifying_submission_allowed() {
+ public function modifying_submission_allowed($userid) {
+
$now = time();
+ $ignoredeadlines = has_capability('mod/workshop:ignoredeadlines', $this->context, $userid);
if ($this->phase != self::PHASE_SUBMISSION) {
// submissions can be edited during the submission phase only
return false;
}
- if (!empty($this->submissionstart) and $this->submissionstart > $now) {
+ if (!$ignoredeadlines and !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 $now > $this->submissionend) {
+ if (!$ignoredeadlines and !$this->latesubmissions and !empty($this->submissionend) 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;
}
return true;
}
/**
- * Are reviewers allowed to create/edit their assessments?
+ * Is the given reviewer allowed to create/edit their assessments?
*
+ * @param int $userid
* @return bool
*/
- public function assessing_allowed() {
+ public function assessing_allowed($userid) {
+
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) {
+ $ignoredeadlines = has_capability('mod/workshop:ignoredeadlines', $this->context, $userid);
+
+ if (!$ignoredeadlines and !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 (!$ignoredeadlines and !empty($this->assessmentend) and $now > $this->assessmentend) {
// if enabled, assessing is not allowed after the date/time defined in the mod_form
return false;
}
@@ -2193,6 +2204,14 @@ public function __construct(workshop $workshop, $userid) {
$task->completed = 'info';
$phase->tasks['latesubmissionsallowed'] = $task;
}
+ if (isset($phase->tasks['submissionstartdatetime']) or isset($phase->tasks['submissionenddatetime'])) {
+ if (has_capability('mod/workshop:ignoredeadlines', $workshop->context, $userid)) {
+ $task = new stdclass();
+ $task->title = get_string('deadlinesignored', 'workshop');
+ $task->completed = 'info';
+ $phase->tasks['deadlinesignored'] = $task;
+ }
+ }
$this->phases[workshop::PHASE_SUBMISSION] = $phase;
//---------------------------------------------------------
@@ -2281,6 +2300,14 @@ public function __construct(workshop $workshop, $userid) {
$task->completed = 'info';
$phase->tasks['assessmentenddatetime'] = $task;
}
+ if (isset($phase->tasks['assessmentstartdatetime']) or isset($phase->tasks['assessmentenddatetime'])) {
+ if (has_capability('mod/workshop:ignoredeadlines', $workshop->context, $userid)) {
+ $task = new stdclass();
+ $task->title = get_string('deadlinesignored', 'workshop');
+ $task->completed = 'info';
+ $phase->tasks['deadlinesignored'] = $task;
+ }
+ }
$this->phases[workshop::PHASE_ASSESSMENT] = $phase;
//---------------------------------------------------------
@@ -76,10 +76,10 @@
and $submission->published == 1
and has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context));
-if (empty($submission->id) and !$workshop->creating_submission_allowed()) {
+if (empty($submission->id) and !$workshop->creating_submission_allowed($USER->id)) {
$editable = false;
}
-if ($submission->id and !$workshop->modifying_submission_allowed()) {
+if ($submission->id and !$workshop->modifying_submission_allowed($USER->id)) {
$editable = false;
}
@@ -109,7 +109,7 @@
print_error('nopermissions', 'error', $workshop->view_url(), 'view or create submission');
}
-if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop->assessing_allowed()) {
+if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop->assessing_allowed($USER->id)) {
require_sesskey();
$assessmentid = $workshop->add_allocation($submission, $USER->id);
redirect($workshop->assess_url($assessmentid));
@@ -267,7 +267,7 @@
echo $output->single_button($btnurl, $btntxt, 'get');
}
-if ($submission->id and !$edit and !$isreviewer and $canallocate and $workshop->assessing_allowed()) {
+if ($submission->id and !$edit and !$isreviewer and $canallocate and $workshop->assessing_allowed($USER->id)) {
$url = new moodle_url($PAGE->url, array('assess' => 1));
echo $output->single_button($url, get_string('assess', 'workshop'), 'post');
}
@@ -281,7 +281,7 @@
// reviewers can always see the grades they gave even they are not available yet
if (is_null($userassessment->grade)) {
echo $output->heading(get_string('notassessed', 'workshop'), 3);
- if ($workshop->assessing_allowed()) {
+ if ($workshop->assessing_allowed($USER->id)) {
echo $output->container($output->single_button($workshop->assess_url($userassessment->id), get_string('assess', 'workshop'), 'get'),
array('class' => 'buttonsbar'));
}
@@ -293,7 +293,7 @@
if ($userassessment->weight != 1) {
echo $output->heading(get_string('weightinfo', 'workshop', $userassessment->weight), 3);
}
- if ($workshop->assessing_allowed()) {
+ if ($workshop->assessing_allowed($USER->id)) {
echo $output->container($output->single_button($workshop->assess_url($userassessment->id), get_string('reassess', 'workshop'), 'get'),
array('class' => 'buttonsbar'));
}
View
@@ -29,6 +29,6 @@
defined('MOODLE_INTERNAL') || die();
-$module->version = 2011030400;
+$module->version = 2011061000;
$module->requires = 2011020900; // Requires this Moodle version
//$module->cron = 60;
View
@@ -153,13 +153,13 @@
echo $output->box_start('generalbox ownsubmission');
if ($submission = $workshop->get_submission_by_author($USER->id)) {
echo $output->render($workshop->prepare_submission_summary($submission, true));
- if ($workshop->modifying_submission_allowed()) {
+ if ($workshop->modifying_submission_allowed($USER->id)) {
$btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
$btntxt = get_string('editsubmission', 'workshop');
}
} else {
echo $output->container(get_string('noyoursubmission', 'workshop'));
- if ($workshop->creating_submission_allowed()) {
+ if ($workshop->creating_submission_allowed($USER->id)) {
$btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
$btntxt = get_string('createsubmission', 'workshop');
}
@@ -201,7 +201,7 @@
echo $output->box_start('generalbox ownsubmission');
echo $output->container(get_string('noyoursubmission', 'workshop'));
$ownsubmissionexists = false;
- if ($workshop->creating_submission_allowed()) {
+ if ($workshop->creating_submission_allowed($USER->id)) {
$btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
$btntxt = get_string('createsubmission', 'workshop');
}

0 comments on commit f44c912

Please sign in to comment.