Permalink
Browse files

MDL-27550 workshop: display the feedback for the submission reviewer …

…when the workshop is closed
  • Loading branch information...
1 parent 275a6f5 commit c6b8bbfa9bf628e94a8db5d75b7320a276fb0392 @mudrd8mz mudrd8mz committed Jul 28, 2011
Showing with 74 additions and 9 deletions.
  1. +34 −5 mod/workshop/locallib.php
  2. +21 −1 mod/workshop/renderer.php
  3. +15 −3 mod/workshop/submission.php
  4. +4 −0 mod/workshop/view.php
@@ -771,14 +771,16 @@ public function get_all_assessments() {
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
$authorfields = user_picture::fields('author', null, 'authorid', 'author');
+ $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
$sql = "SELECT a.id, a.submissionid, a.reviewerid, a.timecreated, a.timemodified,
a.grade, a.gradinggrade, a.gradinggradeover, a.gradinggradeoverby,
- $reviewerfields, $authorfields,
+ $reviewerfields, $authorfields, $overbyfields,
s.title
FROM {workshop_assessments} a
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
INNER JOIN {user} author ON (s.authorid = author.id)
+ LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
WHERE s.workshopid = :workshopid AND s.example = 0
ORDER BY reviewer.lastname, reviewer.firstname";
$params = array('workshopid' => $this->id);
@@ -797,11 +799,13 @@ public function get_assessment_by_id($id) {
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
$authorfields = user_picture::fields('author', null, 'authorid', 'author');
- $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields
+ $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
+ $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields
FROM {workshop_assessments} a
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
INNER JOIN {user} author ON (s.authorid = author.id)
+ LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
WHERE a.id = :id AND s.workshopid = :workshopid";
$params = array('id' => $id, 'workshopid' => $this->id);
@@ -820,11 +824,13 @@ public function get_assessment_of_submission_by_user($submissionid, $reviewerid)
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
$authorfields = user_picture::fields('author', null, 'authorid', 'author');
- $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields
+ $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
+ $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields
FROM {workshop_assessments} a
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id AND s.example = 0)
INNER JOIN {user} author ON (s.authorid = author.id)
+ LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
WHERE s.id = :sid AND reviewer.id = :rid AND s.workshopid = :workshopid";
$params = array('sid' => $submissionid, 'rid' => $reviewerid, 'workshopid' => $this->id);
@@ -841,10 +847,12 @@ public function get_assessments_of_submission($submissionid) {
global $DB;
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
- $sql = "SELECT a.*, s.title, $reviewerfields
+ $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
+ $sql = "SELECT a.*, s.title, $reviewerfields, $overbyfields
FROM {workshop_assessments} a
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
+ LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
WHERE s.example = 0 AND s.id = :submissionid AND s.workshopid = :workshopid
ORDER BY reviewer.lastname, reviewer.firstname, reviewer.id";
$params = array('submissionid' => $submissionid, 'workshopid' => $this->id);
@@ -863,13 +871,15 @@ public function get_assessments_by_reviewer($reviewerid) {
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
$authorfields = user_picture::fields('author', null, 'authorid', 'author');
- $sql = "SELECT a.*, $reviewerfields, $authorfields,
+ $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
+ $sql = "SELECT a.*, $reviewerfields, $authorfields, $overbyfields,
s.id AS submissionid, s.title AS submissiontitle, s.timecreated AS submissioncreated,
s.timemodified AS submissionmodified
FROM {workshop_assessments} a
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
INNER JOIN {user} author ON (s.authorid = author.id)
+ LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
WHERE s.example = 0 AND reviewer.id = :reviewerid AND s.workshopid = :workshopid";
$params = array('reviewerid' => $reviewerid, 'workshopid' => $this->id);
@@ -3040,3 +3050,22 @@ public function __construct(stdClass $submission) {
$this->format = $submission->feedbackauthorformat;
}
}
+
+
+/**
+ * Renderable feedback for the reviewer
+ */
+class workshop_feedback_reviewer extends workshop_feedback implements renderable {
+
+ /**
+ * Extracts feedback from the given assessment record
+ *
+ * @param stdClass $assessment record as returned by eg {@see self::get_assessment_by_id()}
+ */
+ public function __construct(stdClass $assessment) {
+
+ $this->provider = user_picture::unalias($assessment, null, 'gradinggradeoverbyx', 'overby');
+ $this->content = $assessment->feedbackreviewer;
+ $this->format = $assessment->feedbackreviewerformat;
+ }
+}
@@ -497,6 +497,26 @@ protected function render_workshop_grading_report(workshop_grading_report $gradi
* @return string HTML
*/
protected function render_workshop_feedback_author(workshop_feedback_author $feedback) {
+ return $this->helper_render_feedback($feedback);
+ }
+
+ /**
+ * Renders the feedback for the reviewer of the submission
+ *
+ * @param workshop_feedback_reviewer $feedback
+ * @return string HTML
+ */
+ protected function render_workshop_feedback_reviewer(workshop_feedback_reviewer $feedback) {
+ return $this->helper_render_feedback($feedback);
+ }
+
+ /**
+ * Helper method to rendering feedback
+ *
+ * @param workshop_feedback_author|workshop_feedback_reviewer $feedback
+ * @return string HTML
+ */
+ private function helper_render_feedback($feedback) {
$o = ''; // output HTML code
$o .= $this->output->container_start('feedback feedbackforauthor');
@@ -510,7 +530,7 @@ protected function render_workshop_feedback_author(workshop_feedback_author $fee
$content = format_text($feedback->get_content(), $feedback->get_format(), array('overflowdiv' => true));
$o .= $this->output->container($content, 'content');
- $o .= $this->output->container_end(); // end of submission-full
+ $o .= $this->output->container_end();
return $o;
}
@@ -305,6 +305,12 @@
}
echo $output->render($assessment);
+
+ if ($workshop->phase == workshop::PHASE_CLOSED) {
+ if (strlen(trim($userassessment->feedbackreviewer)) > 0) {
+ echo $output->render(new workshop_feedback_reviewer($userassessment));
+ }
+ }
}
if (has_capability('mod/workshop:viewallassessments', $workshop->context) or ($ownsubmission and $workshop->assessments_available())) {
@@ -324,11 +330,17 @@
'showform' => !is_null($assessment->grade),
'showweight' => true,
);
- $assessment = $workshop->prepare_assessment($assessment, $mform, $options);
+ $displayassessment = $workshop->prepare_assessment($assessment, $mform, $options);
if ($canoverride) {
- $assessment->add_action($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'));
+ $displayassessment->add_action($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'));
+ }
+ echo $output->render($displayassessment);
+
+ if ($workshop->phase == workshop::PHASE_CLOSED and has_capability('mod/workshop:viewallassessments', $workshop->context)) {
+ if (strlen(trim($assessment->feedbackreviewer)) > 0) {
+ echo $output->render(new workshop_feedback_reviewer($assessment));
+ }
}
- echo $output->render($assessment);
}
}
@@ -540,6 +540,10 @@
echo $output->box_start('generalbox assessment-summary' . $class);
echo $output->render($workshop->prepare_submission_summary($submission, $shownames));
echo $output->box_end();
+
+ if (strlen(trim($assessment->feedbackreviewer)) > 0) {
+ echo $output->render(new workshop_feedback_reviewer($assessment));
+ }
}
print_collapsible_region_end();
}

0 comments on commit c6b8bbf

Please sign in to comment.