]> git.mjollnir.org Git - moodle.git/commitdiff
VIP Assessment review
authorDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:19:58 +0000 (18:19 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:19:58 +0000 (18:19 +0000)
mod/workshop/assessment.php
mod/workshop/lang/en_utf8/workshop.php
mod/workshop/locallib.php
mod/workshop/renderer.php
mod/workshop/styles.php
mod/workshop/submission.php

index 6154a0100cf8cf00de0f6c665bcc40eb52d9ec20..94fd9aeb6e542e5499998b946cadcd9d42a1e76d 100644 (file)
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
- * Assess a submission or preview the assessment form
+ * Assess a submission or view the single assessment
  *
- * Displays an assessment form and saves the grades given by current user (reviewer)
- * for the dimensions.
+ * Assessment id parameter must be passed. The script displays the submission and
+ * the assessment form. If the current user is the reviewer and the assessing is
+ * allowed, new assessment can be saved.
+ * If the assessing is not allowed (for example, the assessment period is over
+ * or the current user is eg a teacher), the assessment form is opened
+ * in a non-editable mode.
+ * The capability 'mod/workshop:peerassess' is intentionally not checked here.
+ * The user is considered as a reviewer if the corresponding assessment record
+ * has been prepared for him/her (during the allocation). So even a user without the
+ * peerassess capability (like a 'teacher', for example) can become a reviewer.
  *
  * @package   mod-workshop
  * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
 require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
 require_once(dirname(__FILE__).'/locallib.php');
 
-if ($preview = optional_param('preview', 0, PARAM_INT)) {
-    $mode       = 'preview';
-    $cm         = get_coursemodule_from_id('workshop', $preview, 0, false, MUST_EXIST);
-    $course     = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
-    $workshop   = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
-    $submission = new stdClass();
-    $assessment = new stdClass();
-
-} else {
-    $mode       = 'assessment';
-    $asid       = required_param('asid', PARAM_INT);  // assessment id
-    $assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST);
-    $submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid), '*', MUST_EXIST);
-    $workshop   = $DB->get_record('workshop', array('id' => $submission->workshopid), '*', MUST_EXIST);
-    $course     = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST);
-    $cm         = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST);
-}
+$asid       = required_param('asid', PARAM_INT);  // assessment id
+$assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST);
+$submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid), '*', MUST_EXIST);
+$workshop   = $DB->get_record('workshop', array('id' => $submission->workshopid), '*', MUST_EXIST);
+$course     = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST);
+$cm         = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST);
 
 require_login($course, false, $cm);
 if (isguestuser()) {
@@ -53,75 +50,57 @@ if (isguestuser()) {
 }
 $workshop = new workshop($workshop, $cm, $course);
 
-if ('preview' == $mode) {
-    require_capability('mod/workshop:editdimensions', $PAGE->context);
-    $PAGE->set_url($workshop->previewform_url());
-    $PAGE->set_title($workshop->name);
-    $PAGE->set_heading($course->fullname);
-    $PAGE->navbar->add(get_string('editingassessmentform', 'workshop'), $workshop->editform_url(), navigation_node::TYPE_CUSTOM);
-    $PAGE->navbar->add(get_string('previewassessmentform', 'workshop'));
-    $currenttab = 'editform';
-
-} elseif ('assessment' == $mode) {
-    // we do not require 'mod/workshop:peerassess' here, we just check that the assessment record
-    // has been prepared for the current user. So even a user without the peerassess capability
-    // (like a 'teacher', for example) can become a reviewer
-    if ($USER->id !== $assessment->reviewerid) {
-        print_error('nopermissions', '', $workshop->view_url());
-    }
-    $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';
+$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);
+$isreviewer             = ($USER->id == $assessment->reviewerid);
+$isauthor               = ($USER->id == $submission->authorid);
+
+if ($isreviewer or $isauthor or ($canviewallassessments and $canviewallsubmissions)) {
+    // such a user can continue
+} else {
+    print_error('nopermissions', '', $workshop->view_url());
+}
+
+// only the reviewer is allowed to modify the assessment
+if ($isreviewer and $workshop->assessing_allowed()) {
+    $editable = true;
+} else {
+    $editable = false;
 }
 
 // load the grading strategy logic
 $strategy = $workshop->grading_strategy_instance();
 
-// load the form to edit the grading strategy dimensions
-$mform = $strategy->get_assessment_form($PAGE->url, $mode, $assessment);
+// load the assessment form
+$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $editable);
 
 if ($mform->is_cancelled()) {
     redirect($workshop->view_url());
 
-} elseif ($data = $mform->get_data()) {
-    if (isset($data->backtoeditform)) {
-        // user wants to return from preview to form editing
-        redirect($workshop->editform_url());
-    }
+} elseif ($editable and ($data = $mform->get_data())) {
     $rawgrade = $strategy->save_assessment($assessment, $data);
     if (!is_null($rawgrade) and isset($data->saveandclose)) {
-        echo $OUTPUT->header();
-        echo $OUTPUT->heading(get_string('assessmentresult', 'workshop'), 2);
-        echo $OUTPUT->box('Given grade: ' . $rawgrade . ' %'); // todo more detailed info using own renderer, format grade
-        echo $OUTPUT->continue_button($workshop->view_url());
-        echo $OUTPUT->footer();
-        die();  // bye-bye
+        redirect($workshop->view_url());
     } else {
-        // either it is not possible to calculate the $rawgrade or the reviewer has chosen "Save and continue"
-        // redirect to self to prevent data being re-posted by pressing "Reload"
+        // either it is not possible to calculate the $rawgrade
+        // or the reviewer has chosen "Save and continue"
         redirect($PAGE->url);
     }
 }
 
-// Output starts here
-
+// output starts here
 echo $OUTPUT->header();
 echo $OUTPUT->heading(get_string('assessmentform', 'workshop'), 2);
 
-if ('assessment' === $mode) {
-    if (has_capability('mod/workshop:viewauthornames', $PAGE->context)) {
-        $showname   = true;
-        $author     = $workshop->user_info($submission->authorid);
-    } else {
-        $showname   = false;
-        $author     = null;
-    }
-    $wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE);      // workshop renderer
-    $submission = $workshop->get_submission_by_id($submission->id);     // reload so can be passed to the renderer
-    echo $wsoutput->submission_full($submission, $showname);
-}
+$wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE);      // workshop renderer
+$submission = $workshop->get_submission_by_id($submission->id);     // reload so can be passed to the renderer
+echo $wsoutput->submission_full($submission, has_capability('mod/workshop:viewauthornames', $workshop->context));
 
 $mform->display();
 echo $OUTPUT->footer();
index f41b043cd81bdd177b709cca83e6a503f6d10392..9656ea419f5434d687bceaba8063e9febbc9b982 100644 (file)
@@ -56,7 +56,6 @@ $string['assessmentcomps'] = 'Required level of assessments similarity';
 $string['assessmentdeleted'] = 'Assessment deallocated';
 $string['assessmentend'] = 'End of assessment phase';
 $string['assessmentform'] = 'Assessment form';
-$string['assessmentresult'] = 'Assessment result';
 $string['assessmentsettings'] = 'Assessment settings';
 $string['assessmentstart'] = 'Start of assessment phase';
 $string['assignedassessments'] = 'Assigned submissions to assess';
index 28e7ef0b9f4eeaea9040a9d85a74297dfe612619..d04b0d0f09ef4f4fc5223082607254565bb2e888 100644 (file)
@@ -600,32 +600,28 @@ class workshop {
     }
 
     /**
-     * Returns an object containing all data to display the user's full name and picture
+     * Are users allowed to create/edit their submissions?
+     *
+     * TODO: this depends on the workshop phase, phase deadlines, submitting after deadlines possibility
      *
-     * @param int $id optional user id, defaults to the current user
-     * @return stdClass containing properties lastname, firstname, picture and imagealt
+     * @return bool
      */
-    public function user_info($id=null) {
-        global $USER, $DB;
-
-        if (is_null($id) || ($id == $USER->id)) {
-            return $USER;
-        } else {
-            return $DB->get_record('user', array('id' => $id), 'id,lastname,firstname,picture,imagealt', MUST_EXIST);
-        }
+    public function submitting_allowed() {
+        return true;
     }
 
     /**
-     * Are users allowed to create/edit their submissions?
+     * Are reviewers allowed to create/edit their assessments?
      *
-     * TODO: this depends on the workshop phase, phase deadlines, submitting after deadlines possibility
+     * TODO: this depends on the workshop phase, phase deadlines
      *
      * @return bool
      */
-    public function submitting_allowed() {
+    public function assessing_allowed() {
         return true;
     }
 
+
     /**
      * Are the peer-reviews available to the authors?
      *
index afd728ba03ee2a3c60606b4dfe705bc94cc85fd5..a92d90d8b998a8d39689861bb04c48252711f019 100644 (file)
@@ -623,6 +623,8 @@ class moodle_mod_workshop_renderer extends moodle_renderer_base {
      * @return string
      */
     protected function grading_report_assessment(stdClass $assessment, $shownames, array $userinfo, $separator) {
+        global $CFG;
+
         if (is_null($assessment)) {
             return get_string('nullgrade', 'workshop');
         }
@@ -635,7 +637,12 @@ class moodle_mod_workshop_renderer extends moodle_renderer_base {
             $a->gradinggradeover = $assessment->gradinggradeover;
             $grade = get_string('formatpeergradeover', 'workshop', $a);
         }
-        $grade = $this->output->output_tag('span', array('class' => 'grade'), $grade);
+        $link = new html_link();
+        $link->text = $grade;
+        $link->url = new moodle_url($CFG->wwwroot . '/mod/workshop/assessment.php',
+                            array('asid' => $assessment->assessmentid));
+        $link->set_classes('grade');
+        $grade = $this->output->link($link);
 
         if ($shownames) {
             $userid = $assessment->userid;
index 54b9f78fa366c9a55afad3895cc09b1bc48f6f6a..2a081d87b77c676b03961733c40621dfdd9973c5 100644 (file)
 
 /* Rubric - list layout */
 
+.mod-workshop .mform.frozen .fitem.description.rubric + .fitem .fitemtitle,
 .mod-workshop .assessmentform.rubric.list .fitem .fitemtitle {
     display: none;
 }
 
+.mod-workshop .mform.frozen .fitem.description.rubric + .fitem .fitemtitle + .felement,
 .mod-workshop .assessmentform.rubric.list .fitem .felement {
-    width: auto;
+    width: auto%;
+    border: none;
 }
 
 .mod-workshop .assessmentform.rubric.list .fitem .felement span {
index 8a01a9715c758acdf43f25630c258bfed4254efa..0e11cd5b2105ae36ec40b05efc975f38d41fa63e 100644 (file)
@@ -173,13 +173,12 @@ if ($isreviewer) {
 }
 
 if ($isreviewer) {
-    // display own assessment
-    $assessment = 
+    // display own assessment - todo
     $strategy = $workshop->grading_strategy_instance();
 }
 
 if ($canviewallassessments) {
-    // display all assessments (except the eventual own one - that has been already displayed
+    // display all assessments (except the eventual own one - that has been already displayed) - todo
     $strategy = $workshop->grading_strategy_instance();
 }