MDL-26535 workshop: fixed availability of published and assessed submissions
authorDavid Mudrak <david@moodle.com>
Fri, 4 Mar 2011 12:51:28 +0000 (13:51 +0100)
committerDavid Mudrak <david@moodle.com>
Sun, 6 Mar 2011 22:49:49 +0000 (23:49 +0100)
While working on the new capability to view authors of published
submissions, I realized that published submissions are correctly listed
(implemented in 00bc77ee) but they can't be viewed by submission.php.
This patch fixes submission.php so that it allows to view published
submissions.

Also, I noticed that when the workshop is closed, the submissions that
were assessed by the user are not listed (as they were in the previous
phases) but submission.php provides access to them correctly. So I added
a code that lists assessed submissions in the closed phase.

mod/workshop/styles.css
mod/workshop/submission.php
mod/workshop/view.php

index 3c65483..22c4851 100644 (file)
     margin: 0.75em auto;
 }
 
+.path-mod-workshop #workshop-viewlet-assignedassessments div.singlebutton,
+.path-mod-workshop #workshop-viewlet-allexamples div.singlebutton,
+.path-mod-workshop #workshop-viewlet-examples div.singlebutton {
+    text-align: left;
+}
+
 /**
  * Submission - one line summary display
  */
index a0766e6..81b5e9a 100644 (file)
@@ -72,6 +72,9 @@ $canoverride    = (($workshop->phase == workshop::PHASE_EVALUATION) and has_capa
 $userassessment = $workshop->get_assessment_of_submission_by_user($submission->id, $USER->id);
 $isreviewer     = !empty($userassessment);
 $editable       = ($cansubmit and $ownsubmission);
+$ispublished    = ($workshop->phase == workshop::PHASE_CLOSED
+                    and $submission->published == 1
+                    and has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context));
 
 if (empty($submission->id) and !$workshop->creating_submission_allowed()) {
     $editable = false;
@@ -93,8 +96,13 @@ if ($editable and $workshop->useexamples and $workshop->examplesmode == workshop
 }
 $edit = ($editable and $edit);
 
+$seenaspublished = false; // is the submission seen as a published submission?
+
 if ($submission->id and ($ownsubmission or $canviewall or $isreviewer)) {
     // ok you can go
+} elseif ($submission->id and $ispublished) {
+    // ok you can go
+    $seenaspublished = true;
 } elseif (is_null($submission->id) and $cansubmit) {
     // ok you can go
 } else {
@@ -238,7 +246,12 @@ if ($edit) {
 // else display the submission
 
 if ($submission->id) {
-    echo $output->render($workshop->prepare_submission($submission, has_capability('mod/workshop:viewauthornames', $workshop->context)));
+    if ($seenaspublished) {
+        $showauthor = has_capability('mod/workshop:viewauthorpublished', $workshop->context);
+    } else {
+        $showauthor = has_capability('mod/workshop:viewauthornames', $workshop->context);
+    }
+    echo $output->render($workshop->prepare_submission($submission, $showauthor));
 } else {
     echo $output->box(get_string('noyoursubmission', 'workshop'));
 }
index ab47886..2cd32a0 100644 (file)
@@ -503,6 +503,37 @@ case workshop::PHASE_CLOSED:
             print_collapsible_region_end();
         }
     }
+    if ($assessments = $workshop->get_assessments_by_reviewer($USER->id)) {
+        print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop'));
+        $shownames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
+        foreach ($assessments as $assessment) {
+            $submission                     = new stdclass();
+            $submission->id                 = $assessment->submissionid;
+            $submission->title              = $assessment->submissiontitle;
+            $submission->timecreated        = $assessment->submissioncreated;
+            $submission->timemodified       = $assessment->submissionmodified;
+            $submission->authorid           = $assessment->authorid;
+            $submission->authorfirstname    = $assessment->authorfirstname;
+            $submission->authorlastname     = $assessment->authorlastname;
+            $submission->authorpicture      = $assessment->authorpicture;
+            $submission->authorimagealt     = $assessment->authorimagealt;
+            $submission->authoremail        = $assessment->authoremail;
+
+            if (is_null($assessment->grade)) {
+                $class = ' notgraded';
+                $submission->status = 'notgraded';
+                $buttontext = get_string('assess', 'workshop');
+            } else {
+                $class = ' graded';
+                $submission->status = 'graded';
+                $buttontext = get_string('reassess', 'workshop');
+            }
+            echo $output->box_start('generalbox assessment-summary' . $class);
+            echo $output->render($workshop->prepare_submission_summary($submission, $shownames));
+            echo $output->box_end();
+        }
+        print_collapsible_region_end();
+    }
     break;
 default:
 }