From ac239eba05a42cdf3b3771fb4ea0e81c0b25dc37 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Tue, 8 Jun 2010 23:10:43 +0000 Subject: [PATCH] NOBUG workshop: allows instant assessment for the teachers If a user is allowed to allocate a submission to herself for assessment, there is now a button that she can press to immediately allocate and assess the submission. This patch also contains various cleanups spotted during the work. --- mod/workshop/assessment.php | 1 - mod/workshop/lang/en/workshop.php | 4 ++-- mod/workshop/locallib.php | 8 ++++---- mod/workshop/submission.php | 15 ++++++++++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mod/workshop/assessment.php b/mod/workshop/assessment.php index 590e35c6a53..666962a3eb6 100644 --- a/mod/workshop/assessment.php +++ b/mod/workshop/assessment.php @@ -54,7 +54,6 @@ $PAGE->set_url($workshop->assess_url($assessment->id)); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('assessingsubmission', 'workshop')); -$currenttab = 'assessment'; $canviewallassessments = has_capability('mod/workshop:viewallassessments', $workshop->context); $canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $workshop->context); diff --git a/mod/workshop/lang/en/workshop.php b/mod/workshop/lang/en/workshop.php index 19d25645ad7..feb36b66b39 100644 --- a/mod/workshop/lang/en/workshop.php +++ b/mod/workshop/lang/en/workshop.php @@ -106,7 +106,7 @@ $string['formatpeergrade'] = '{$a->grade} $value) { - $this->{$field} = $value; + if (property_exists('workshop', $field)) { + $this->{$field} = $value; + } } $this->cm = $cm; - $this->course = $course; // beware - this replaces the standard course field in the instance table - // this is intentional - IMO there should be no such field as it violates - // 3rd normal form with no real performance gain + $this->course = $course; if (is_null($context)) { $this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id); } else { diff --git a/mod/workshop/submission.php b/mod/workshop/submission.php index 00907bf5013..3227eb68ee4 100644 --- a/mod/workshop/submission.php +++ b/mod/workshop/submission.php @@ -29,6 +29,7 @@ require_once(dirname(__FILE__).'/locallib.php'); $cmid = required_param('cmid', PARAM_INT); // course module id $id = optional_param('id', 0, PARAM_INT); // submission id $edit = optional_param('edit', false, PARAM_BOOL); // open for editing? +$assess = optional_param('assess', false, PARAM_BOOL); // instant assessment required $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); @@ -56,6 +57,7 @@ if ($id) { // submission is specified $ownsubmission = $submission->authorid == $USER->id; $canviewall = has_capability('mod/workshop:viewallsubmissions', $workshop->context); $cansubmit = has_capability('mod/workshop:submit', $workshop->context); +$canallocate = has_capability('mod/workshop:allocate', $workshop->context); $canoverride = (($workshop->phase == workshop::PHASE_EVALUATION) and has_capability('mod/workshop:overridegrades', $workshop->context)); $isreviewer = $DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $USER->id)); $editable = $workshop->submitting_allowed(); @@ -69,6 +71,12 @@ if ($submission->id and ($ownsubmission or $canviewall or $isreviewer)) { print_error('nopermissions'); } +if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop->assessing_allowed()) { + require_sesskey(); + $assessmentid = $workshop->add_allocation($submission, $USER->id); + redirect($workshop->assess_url($assessmentid)); +} + if ($edit and $ownsubmission) { require_once(dirname(__FILE__).'/submission_form.php'); @@ -111,7 +119,7 @@ if ($edit and $ownsubmission) { $formdata = file_postupdate_standard_filemanager($formdata, 'attachment', $attachmentopts, $workshop->context, 'workshop_submission_attachment', $formdata->id); if (empty($formdata->attachment)) { - // explicit cas to zero integer + // explicit cast to zero integer $formdata->attachment = 0; } // store the updated values or re-save the new submission (re-saving needed because URLs are now rewritten) @@ -173,6 +181,11 @@ if ($ownsubmission and $editable) { echo $OUTPUT->single_button($url, get_string('editsubmission', 'workshop'), 'get'); } +if ($submission->id and !$edit and !$isreviewer and $canallocate and $workshop->assessing_allowed()) { + $url = new moodle_url($PAGE->url, array('assess' => 1)); + echo $OUTPUT->single_button($url, get_string('assess', 'workshop'), 'post'); +} + // and possibly display the submission's review(s) $canviewallassessments = false;