Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'MDL-27550-workshop-feedback_20_STABLE' of git://github.…

…com/mudrd8mz/moodle into MOODLE_20_STABLE
  • Loading branch information...
commit e8a165d2a3255e0b0c5e6fa233b5046c8694cd4e 2 parents fcda253 + 4ac89c8
Eloy Lafuente (stronk7) stronk7 authored
37 mod/workshop/assessment.php
@@ -182,24 +182,33 @@
182 182 print_collapsible_region_end();
183 183 }
184 184
  185 +// extend the current assessment record with user details
  186 +$assessment = $workshop->get_assessment_by_id($assessment->id);
  187 +
185 188 if ($isreviewer) {
186   - echo $output->heading(get_string('assessmentbyyourself', 'workshop'), 2);
187   -} elseif (has_capability('mod/workshop:viewreviewernames', $workshop->context)) {
188   - $assessment = $workshop->get_assessment_by_id($assessment->id); // extend the current record with user details
189   - $reviewer = new stdclass();
190   - $reviewer->firstname = $assessment->reviewerfirstname;
191   - $reviewer->lastname = $assessment->reviewerlastname;
192   - echo $output->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
193   -} else {
194   - echo $output->heading(get_string('assessmentbyunknown', 'workshop'), 2);
195   -}
  189 + $options = array(
  190 + 'showreviewer' => true,
  191 + 'showauthor' => has_capability('mod/workshop:viewauthornames', $workshop->context),
  192 + 'showform' => $assessmenteditable or !is_null($assessment->grade),
  193 + 'showweight' => true,
  194 + );
  195 + $assessment = $workshop->prepare_assessment($assessment, $mform, $options);
  196 + $assessment->title = get_string('assessmentbyyourself', 'workshop');
  197 + echo $output->render($assessment);
196 198
197   -if ($mform) {
198   - $mform->display();
199 199 } else {
200   - echo $output->heading(get_string('notassessed', 'workshop'));
  200 + $options = array(
  201 + 'showreviewer' => has_capability('mod/workshop:viewreviewernames', $workshop->context),
  202 + 'showauthor' => has_capability('mod/workshop:viewauthornames', $workshop->context),
  203 + 'showform' => $assessmenteditable or !is_null($assessment->grade),
  204 + 'showweight' => true,
  205 + );
  206 + $assessment = $workshop->prepare_assessment($assessment, $mform, $options);
  207 + echo $output->render($assessment);
201 208 }
202   -if ($canoverridegrades) {
  209 +
  210 +if (!$assessmenteditable and $canoverridegrades) {
203 211 $feedbackform->display();
204 212 }
  213 +
205 214 echo $output->footer();
47 mod/workshop/exassessment.php
@@ -56,7 +56,7 @@
56 56 }
57 57
58 58 // only the reviewer is allowed to modify the assessment
59   -if ($canmanage or ($isreviewer and $workshop->assessing_examples_allowed())) {
  59 +if (($canmanage and $assessment->weight == 1) or ($isreviewer and $workshop->assessing_examples_allowed())) {
60 60 $assessmenteditable = true;
61 61 } else {
62 62 $assessmenteditable = false;
@@ -119,17 +119,40 @@
119 119 print_collapsible_region_end();
120 120 }
121 121
122   -if ($canmanage) {
123   - echo $output->heading(get_string('assessmentreference', 'workshop'), 2);
124   -} elseif ($isreviewer) {
125   - echo $output->heading(get_string('assessmentbyyourself', 'workshop'), 2);
126   -} else {
127   - $assessment = $workshop->get_assessment_by_id($assessment->id); // extend the current record with user details
128   - $reviewer = new stdclass();
129   - $reviewer->firstname = $assessment->reviewerfirstname;
130   - $reviewer->lastname = $assessment->reviewerlastname;
131   - echo $output->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
  122 +// extend the current assessment record with user details
  123 +$assessment = $workshop->get_assessment_by_id($assessment->id);
  124 +
  125 +if ($canmanage and $assessment->weight == 1) {
  126 + $options = array(
  127 + 'showreviewer' => false,
  128 + 'showauthor' => false,
  129 + 'showform' => true,
  130 + 'showweight' => false,
  131 + );
  132 + $assessment = $workshop->prepare_assessment($assessment, $mform, $options);
  133 + $assessment->title = get_string('assessmentreference', 'workshop');
  134 + echo $output->render($assessment);
  135 +
  136 +} else if ($isreviewer) {
  137 + $options = array(
  138 + 'showreviewer' => true,
  139 + 'showauthor' => false,
  140 + 'showform' => true,
  141 + 'showweight' => false,
  142 + );
  143 + $assessment = $workshop->prepare_assessment($assessment, $mform, $options);
  144 + $assessment->title = get_string('assessmentbyyourself', 'workshop');
  145 + echo $output->render($assessment);
  146 +
  147 +} else if ($canmanage) {
  148 + $options = array(
  149 + 'showreviewer' => true,
  150 + 'showauthor' => false,
  151 + 'showform' => true,
  152 + 'showweight' => false,
  153 + );
  154 + $assessment = $workshop->prepare_assessment($assessment, $mform, $options);
  155 + echo $output->render($assessment);
132 156 }
133 157
134   -$mform->display();
135 158 echo $output->footer();
56 mod/workshop/excompare.php
@@ -78,33 +78,45 @@
78 78
79 79 echo $output->render($workshop->prepare_example_submission($example));
80 80
  81 +// if the reference assessment is available, display it
81 82 if (!empty($mformreference)) {
82   - echo $output->heading(get_string('assessmentreference', 'workshop'), 2);
83   - $a = new stdclass();
84   - $a->received = $workshop->real_grade($reference->grade);
85   - $a->max = $workshop->real_grade(100);
86   - echo $output->heading(get_string('gradeinfo', 'workshop' , $a), 3);
87   - $mformreference->display();
  83 + $options = array(
  84 + 'showreviewer' => false,
  85 + 'showauthor' => false,
  86 + 'showform' => true,
  87 + 'showweight' => false,
  88 + );
  89 + $reference = $workshop->prepare_assessment($reference, $mformreference, $options);
  90 + $reference->title = get_string('assessmentreference', 'workshop');
  91 + echo $output->render($reference);
88 92 }
89 93
90 94 if ($isreviewer) {
91   - echo $output->heading(get_string('assessmentbyyourself', 'workshop'), 2);
  95 + $options = array(
  96 + 'showreviewer' => true,
  97 + 'showauthor' => false,
  98 + 'showform' => true,
  99 + 'showweight' => false,
  100 + );
  101 + $assessment = $workshop->prepare_assessment($assessment, $mformassessment, $options);
  102 + $assessment->title = get_string('assessmentbyyourself', 'workshop');
  103 + if ($workshop->assessing_examples_allowed()) {
  104 + $assessment->add_action(
  105 + new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey())),
  106 + get_string('reassess', 'workshop')
  107 + );
  108 + }
  109 + echo $output->render($assessment);
  110 +
92 111 } elseif ($canmanage) {
93   - $reviewer = new stdclass();
94   - $reviewer->firstname = $assessment->reviewerfirstname;
95   - $reviewer->lastname = $assessment->reviewerlastname;
96   - echo $output->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
97   -}
98   -$a = new stdclass();
99   -$a->received = $workshop->real_grade($assessment->grade);
100   -$a->max = $workshop->real_grade(100);
101   -echo $output->heading(get_string('gradeinfo', 'workshop' , $a), 3);
102   -$mformassessment->display();
103   -echo $output->container_start('buttonsbar');
104   -if ($isreviewer and $workshop->assessing_examples_allowed()) {
105   - $aurl = new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey()));
106   - echo $output->single_button($aurl, get_string('reassess', 'workshop'), 'get');
  112 + $options = array(
  113 + 'showreviewer' => true,
  114 + 'showauthor' => false,
  115 + 'showform' => true,
  116 + 'showweight' => false,
  117 + );
  118 + $assessment = $workshop->prepare_assessment($assessment, $mformassessment, $options);
  119 + echo $output->render($assessment);
107 120 }
108   -echo $output->container_end(); // buttonsbar
109 121
110 122 echo $output->footer();
8 mod/workshop/lang/en/workshop.php
@@ -43,9 +43,10 @@
43 43 $string['assessedsubmission'] = 'Assessed submission';
44 44 $string['assessingexample'] = 'Assessing example submission';
45 45 $string['assessingsubmission'] = 'Assessing submission';
46   -$string['assessmentbyknown'] = 'Assessment by {$a}';
47   -$string['assessmentbyunknown'] = 'Assessment';
48   -$string['assessmentbyyourself'] = 'Assessment by yourself';
  46 +$string['assessment'] = 'Assessment';
  47 +$string['assessmentby'] = 'by <a href="{$a->url}">{$a->name}</a>';
  48 +$string['assessmentbyfullname'] = 'Assessment by {$a}';
  49 +$string['assessmentbyyourself'] = 'Your assessment';
49 50 $string['assessmentdeleted'] = 'Assessment deallocated';
50 51 $string['assessmentend'] = 'Deadline for assessment';
51 52 $string['assessmentenddatetime'] = 'Assessment deadline: {$a->daydatetime} ({$a->distanceday})';
@@ -113,6 +114,7 @@
113 114 $string['examplesubmissions'] = 'Example submissions';
114 115 $string['examplesvoluntary'] = 'Assessment of example submission is voluntary';
115 116 $string['feedbackauthor'] = 'Feedback for the author';
  117 +$string['feedbackby'] = 'Feedback by {$a}';
116 118 $string['feedbackreviewer'] = 'Feedback for the reviewer';
117 119 $string['formataggregatedgrade'] = '{$a->grade}';
118 120 $string['formataggregatedgradeover'] = '<del>{$a->grade}</del><br /><ins>{$a->over}</ins>';
4 mod/workshop/lib.php
@@ -862,12 +862,12 @@ function workshop_print_recent_mod_activity($activity, $courseid, $detail, $modn
862 862 $url = new moodle_url('/user/view.php', array('id'=>$activity->user->id, 'course'=>$courseid));
863 863 $name = fullname($activity->user);
864 864 $link = html_writer::link($url, $name);
865   - echo get_string('assessmentbyknown', 'workshop', $link);
  865 + echo get_string('assessmentbyfullname', 'workshop', $link);
866 866 echo ' - '.userdate($activity->timestamp);
867 867 echo html_writer::end_tag('div');
868 868 } else {
869 869 echo html_writer::start_tag('div', array('class'=>'anonymous'));
870   - echo get_string('assessmentbyunknown', 'workshop');
  870 + echo get_string('assessment', 'workshop');
871 871 echo ' - '.userdate($activity->timestamp);
872 872 echo html_writer::end_tag('div');
873 873 }
338 mod/workshop/locallib.php
@@ -489,16 +489,15 @@ public function get_allocations() {
489 489 public function get_submissions($authorid='all') {
490 490 global $DB;
491 491
492   - $sql = 'SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified,
  492 + $authorfields = user_picture::fields('u', null, 'authoridx', 'author');
  493 + $gradeoverbyfields = user_picture::fields('t', null, 'gradeoverbyx', 'over');
  494 + $sql = "SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified,
493 495 s.title, s.grade, s.gradeover, s.gradeoverby, s.published,
494   - u.lastname AS authorlastname, u.firstname AS authorfirstname,
495   - u.picture AS authorpicture, u.imagealt AS authorimagealt, u.email AS authoremail,
496   - t.lastname AS overlastname, t.firstname AS overfirstname,
497   - t.picture AS overpicture, t.imagealt AS overimagealt, t.email AS overemail
  496 + $authorfields, $gradeoverbyfields
498 497 FROM {workshop_submissions} s
499 498 INNER JOIN {user} u ON (s.authorid = u.id)
500 499 LEFT JOIN {user} t ON (s.gradeoverby = t.id)
501   - WHERE s.example = 0 AND s.workshopid = :workshopid';
  500 + WHERE s.example = 0 AND s.workshopid = :workshopid";
502 501 $params = array('workshopid' => $this->id);
503 502
504 503 if ('all' === $authorid) {
@@ -511,7 +510,7 @@ public function get_submissions($authorid='all') {
511 510 // $authorid is empty
512 511 return array();
513 512 }
514   - $sql .= ' ORDER BY u.lastname, u.firstname';
  513 + $sql .= " ORDER BY u.lastname, u.firstname";
515 514
516 515 return $DB->get_records_sql($sql, $params);
517 516 }
@@ -527,12 +526,13 @@ public function get_submission_by_id($id) {
527 526
528 527 // we intentionally check the workshopid here, too, so the workshop can't touch submissions
529 528 // from other instances
530   - $sql = 'SELECT s.*,
531   - u.lastname AS authorlastname, u.firstname AS authorfirstname, u.id AS authorid,
532   - u.picture AS authorpicture, u.imagealt AS authorimagealt, u.email AS authoremail
  529 + $authorfields = user_picture::fields('u', null, 'authoridx', 'author');
  530 + $gradeoverbyfields = user_picture::fields('g', null, 'gradeoverbyx', 'gradeoverby');
  531 + $sql = "SELECT s.*, $authorfields, $gradeoverbyfields
533 532 FROM {workshop_submissions} s
534 533 INNER JOIN {user} u ON (s.authorid = u.id)
535   - WHERE s.example = 0 AND s.workshopid = :workshopid AND s.id = :id';
  534 + LEFT JOIN {user} g ON (s.gradeoverby = g.id)
  535 + WHERE s.example = 0 AND s.workshopid = :workshopid AND s.id = :id";
536 536 $params = array('workshopid' => $this->id, 'id' => $id);
537 537 return $DB->get_record_sql($sql, $params, MUST_EXIST);
538 538 }
@@ -549,12 +549,13 @@ public function get_submission_by_author($authorid) {
549 549 if (empty($authorid)) {
550 550 return false;
551 551 }
552   - $sql = 'SELECT s.*,
553   - u.lastname AS authorlastname, u.firstname AS authorfirstname, u.id AS authorid,
554   - u.picture AS authorpicture, u.imagealt AS authorimagealt, u.email AS authoremail
  552 + $authorfields = user_picture::fields('u', null, 'authoridx', 'author');
  553 + $gradeoverbyfields = user_picture::fields('g', null, 'gradeoverbyx', 'gradeoverby');
  554 + $sql = "SELECT s.*, $authorfields, $gradeoverbyfields
555 555 FROM {workshop_submissions} s
556 556 INNER JOIN {user} u ON (s.authorid = u.id)
557   - WHERE s.example = 0 AND s.workshopid = :workshopid AND s.authorid = :authorid';
  557 + LEFT JOIN {user} g ON (s.gradeoverby = g.id)
  558 + WHERE s.example = 0 AND s.workshopid = :workshopid AND s.authorid = :authorid";
558 559 $params = array('workshopid' => $this->id, 'authorid' => $authorid);
559 560 return $DB->get_record_sql($sql, $params);
560 561 }
@@ -567,10 +568,10 @@ public function get_submission_by_author($authorid) {
567 568 public function get_published_submissions($orderby='finalgrade DESC') {
568 569 global $DB;
569 570
  571 + $authorfields = user_picture::fields('u', null, 'authoridx', 'author');
570 572 $sql = "SELECT s.id, s.authorid, s.timecreated, s.timemodified,
571 573 s.title, s.grade, s.gradeover, COALESCE(s.gradeover,s.grade) AS finalgrade,
572   - u.lastname AS authorlastname, u.firstname AS authorfirstname, u.id AS authorid,
573   - u.picture AS authorpicture, u.imagealt AS authorimagealt, u.email AS authoremail
  574 + $authorfields
574 575 FROM {workshop_submissions} s
575 576 INNER JOIN {user} u ON (s.authorid = u.id)
576 577 WHERE s.example = 0 AND s.workshopid = :workshopid AND s.published = 1
@@ -706,6 +707,44 @@ public function prepare_example_summary(stdClass $example) {
706 707 }
707 708
708 709 /**
  710 + * Prepares renderable assessment component
  711 + *
  712 + * The $options array supports the following keys:
  713 + * showauthor - should the author user info be available for the renderer
  714 + * showreviewer - should the reviewer user info be available for the renderer
  715 + * showform - show the assessment form if it is available
  716 + *
  717 + * @param stdClass $record as returned by eg {@link self::get_assessment_by_id()}
  718 + * @param workshop_assessment_form|null $form as returned by {@link workshop_strategy::get_assessment_form()}
  719 + * @param array $options
  720 + * @return workshop_assessment
  721 + */
  722 + public function prepare_assessment(stdClass $record, $form, array $options = array()) {
  723 +
  724 + $assessment = new workshop_assessment($record, $options);
  725 + $assessment->url = $this->assess_url($record->id);
  726 + $assessment->maxgrade = $this->real_grade(100);
  727 +
  728 + if (!empty($options['showform']) and !($form instanceof workshop_assessment_form)) {
  729 + debugging('Not a valid instance of workshop_assessment_form supplied', DEBUG_DEVELOPER);
  730 + }
  731 +
  732 + if (!empty($options['showform']) and ($form instanceof workshop_assessment_form)) {
  733 + $assessment->form = $form;
  734 + }
  735 +
  736 + if (empty($options['showweight'])) {
  737 + $assessment->weight = null;
  738 + }
  739 +
  740 + if (!is_null($record->grade)) {
  741 + $assessment->realgrade = $this->real_grade($record->grade);
  742 + }
  743 +
  744 + return $assessment;
  745 + }
  746 +
  747 + /**
709 748 * Removes the submission and all relevant data
710 749 *
711 750 * @param stdClass $submission record to delete
@@ -730,17 +769,20 @@ public function delete_submission(stdclass $submission) {
730 769 public function get_all_assessments() {
731 770 global $DB;
732 771
733   - $sql = 'SELECT a.id, a.submissionid, a.reviewerid, a.timecreated, a.timemodified,
  772 + $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
  773 + $authorfields = user_picture::fields('author', null, 'authorid', 'author');
  774 + $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
  775 + $sql = "SELECT a.id, a.submissionid, a.reviewerid, a.timecreated, a.timemodified,
734 776 a.grade, a.gradinggrade, a.gradinggradeover, a.gradinggradeoverby,
735   - reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname as reviewerlastname,
736   - s.title,
737   - author.id AS authorid, author.firstname AS authorfirstname,author.lastname AS authorlastname
  777 + $reviewerfields, $authorfields, $overbyfields,
  778 + s.title
738 779 FROM {workshop_assessments} a
739 780 INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
740 781 INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
741 782 INNER JOIN {user} author ON (s.authorid = author.id)
  783 + LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
742 784 WHERE s.workshopid = :workshopid AND s.example = 0
743   - ORDER BY reviewer.lastname, reviewer.firstname';
  785 + ORDER BY reviewer.lastname, reviewer.firstname";
744 786 $params = array('workshopid' => $this->id);
745 787
746 788 return $DB->get_records_sql($sql, $params);
@@ -755,15 +797,16 @@ public function get_all_assessments() {
755 797 public function get_assessment_by_id($id) {
756 798 global $DB;
757 799
758   - $sql = 'SELECT a.*,
759   - reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname as reviewerlastname,
760   - s.title,
761   - author.id AS authorid, author.firstname AS authorfirstname,author.lastname as authorlastname
  800 + $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
  801 + $authorfields = user_picture::fields('author', null, 'authorid', 'author');
  802 + $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
  803 + $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields
762 804 FROM {workshop_assessments} a
763 805 INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
764 806 INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
765 807 INNER JOIN {user} author ON (s.authorid = author.id)
766   - WHERE a.id = :id AND s.workshopid = :workshopid';
  808 + LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
  809 + WHERE a.id = :id AND s.workshopid = :workshopid";
767 810 $params = array('id' => $id, 'workshopid' => $this->id);
768 811
769 812 return $DB->get_record_sql($sql, $params, MUST_EXIST);
@@ -779,15 +822,16 @@ public function get_assessment_by_id($id) {
779 822 public function get_assessment_of_submission_by_user($submissionid, $reviewerid) {
780 823 global $DB;
781 824
782   - $sql = 'SELECT a.*,
783   - reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname as reviewerlastname,
784   - s.title,
785   - author.id AS authorid, author.firstname AS authorfirstname,author.lastname as authorlastname
  825 + $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
  826 + $authorfields = user_picture::fields('author', null, 'authorid', 'author');
  827 + $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
  828 + $sql = "SELECT a.*, s.title, $reviewerfields, $authorfields, $overbyfields
786 829 FROM {workshop_assessments} a
787 830 INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
788 831 INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id AND s.example = 0)
789 832 INNER JOIN {user} author ON (s.authorid = author.id)
790   - WHERE s.id = :sid AND reviewer.id = :rid AND s.workshopid = :workshopid';
  833 + LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
  834 + WHERE s.id = :sid AND reviewer.id = :rid AND s.workshopid = :workshopid";
791 835 $params = array('sid' => $submissionid, 'rid' => $reviewerid, 'workshopid' => $this->id);
792 836
793 837 return $DB->get_record_sql($sql, $params, IGNORE_MISSING);
@@ -802,12 +846,15 @@ public function get_assessment_of_submission_by_user($submissionid, $reviewerid)
802 846 public function get_assessments_of_submission($submissionid) {
803 847 global $DB;
804 848
805   - $sql = 'SELECT a.*,
806   - reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname AS reviewerlastname
  849 + $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
  850 + $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
  851 + $sql = "SELECT a.*, s.title, $reviewerfields, $overbyfields
807 852 FROM {workshop_assessments} a
808 853 INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
809 854 INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
810   - WHERE s.example = 0 AND s.id = :submissionid AND s.workshopid = :workshopid';
  855 + LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
  856 + WHERE s.example = 0 AND s.id = :submissionid AND s.workshopid = :workshopid
  857 + ORDER BY reviewer.lastname, reviewer.firstname, reviewer.id";
811 858 $params = array('submissionid' => $submissionid, 'workshopid' => $this->id);
812 859
813 860 return $DB->get_records_sql($sql, $params);
@@ -822,17 +869,18 @@ public function get_assessments_of_submission($submissionid) {
822 869 public function get_assessments_by_reviewer($reviewerid) {
823 870 global $DB;
824 871
825   - $sql = 'SELECT a.*,
826   - reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname AS reviewerlastname,
  872 + $reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
  873 + $authorfields = user_picture::fields('author', null, 'authorid', 'author');
  874 + $overbyfields = user_picture::fields('overby', null, 'gradinggradeoverbyx', 'overby');
  875 + $sql = "SELECT a.*, $reviewerfields, $authorfields, $overbyfields,
827 876 s.id AS submissionid, s.title AS submissiontitle, s.timecreated AS submissioncreated,
828   - s.timemodified AS submissionmodified,
829   - author.id AS authorid, author.firstname AS authorfirstname,author.lastname AS authorlastname,
830   - author.picture AS authorpicture, author.imagealt AS authorimagealt, author.email AS authoremail
  877 + s.timemodified AS submissionmodified
831 878 FROM {workshop_assessments} a
832 879 INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
833 880 INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
834 881 INNER JOIN {user} author ON (s.authorid = author.id)
835   - WHERE s.example = 0 AND reviewer.id = :reviewerid AND s.workshopid = :workshopid';
  882 + LEFT JOIN {user} overby ON (a.gradinggradeoverby = overby.id)
  883 + WHERE s.example = 0 AND reviewer.id = :reviewerid AND s.workshopid = :workshopid";
836 884 $params = array('reviewerid' => $reviewerid, 'workshopid' => $this->id);
837 885
838 886 return $DB->get_records_sql($sql, $params);
@@ -2592,6 +2640,124 @@ class workshop_example_submission extends workshop_example_submission_summary im
2592 2640 protected $fields = array('id', 'title', 'content', 'contentformat', 'contenttrust', 'attachment');
2593 2641 }
2594 2642
  2643 +
  2644 +/**
  2645 + * Common base class for assessments rendering
  2646 + *
  2647 + * Subclasses of this class convert raw assessment record from
  2648 + * workshop_assessments table (as returned by {@see workshop::get_assessment_by_id()}
  2649 + * for example) into renderable objects.
  2650 + */
  2651 +abstract class workshop_assessment_base {
  2652 +
  2653 + /** @var string the optional title of the assessment */
  2654 + public $title = '';
  2655 +
  2656 + /** @var workshop_assessment_form $form as returned by {@link workshop_strategy::get_assessment_form()} */
  2657 + public $form;
  2658 +
  2659 + /** @var moodle_url */
  2660 + public $url;
  2661 +
  2662 + /** @var float|null the real received grade */
  2663 + public $realgrade = null;
  2664 +
  2665 + /** @var float the real maximum grade */
  2666 + public $maxgrade;
  2667 +
  2668 + /** @var stdClass|null reviewer user info */
  2669 + public $reviewer = null;
  2670 +
  2671 + /** @var stdClass|null assessed submission's author user info */
  2672 + public $author = null;
  2673 +
  2674 + /** @var array of actions */
  2675 + public $actions = array();
  2676 +
  2677 + /* @var array of columns that are assigned as properties */
  2678 + protected $fields = array();
  2679 +
  2680 + /**
  2681 + * Copies the properties of the given database record into properties of $this instance
  2682 + *
  2683 + * The $options keys are: showreviewer, showauthor
  2684 + * @param stdClass $assessment full record
  2685 + * @param array $options additional properties
  2686 + */
  2687 + public function __construct(stdClass $record, array $options = array()) {
  2688 +
  2689 + foreach ($this->fields as $field) {
  2690 + if (!property_exists($record, $field)) {
  2691 + throw new coding_exception('Assessment record must provide public property ' . $field);
  2692 + }
  2693 + if (!property_exists($this, $field)) {
  2694 + throw new coding_exception('Renderable component must accept public property ' . $field);
  2695 + }
  2696 + $this->{$field} = $record->{$field};
  2697 + }
  2698 +
  2699 + if (!empty($options['showreviewer'])) {
  2700 + $this->reviewer = user_picture::unalias($record, null, 'revieweridx', 'reviewer');
  2701 + }
  2702 +
  2703 + if (!empty($options['showauthor'])) {
  2704 + $this->author = user_picture::unalias($record, null, 'authorid', 'author');
  2705 + }
  2706 + }
  2707 +
  2708 + /**
  2709 + * Adds a new action
  2710 + *
  2711 + * @param moodle_url $url action URL
  2712 + * @param string $label action label
  2713 + * @param string $method get|post
  2714 + */
  2715 + public function add_action(moodle_url $url, $label, $method = 'get') {
  2716 +
  2717 + $action = new stdClass();
  2718 + $action->url = $url;
  2719 + $action->label = $label;
  2720 + $action->method = $method;
  2721 +
  2722 + $this->actions[] = $action;
  2723 + }
  2724 +}
  2725 +
  2726 +
  2727 +/**
  2728 + * Represents a rendarable full assessment
  2729 + */
  2730 +class workshop_assessment extends workshop_assessment_base implements renderable {
  2731 +
  2732 + /** @var int */
  2733 + public $id;
  2734 +
  2735 + /** @var int */
  2736 + public $submissionid;
  2737 +
  2738 + /** @var int */
  2739 + public $weight;
  2740 +
  2741 + /** @var int */
  2742 + public $timecreated;
  2743 +
  2744 + /** @var int */
  2745 + public $timemodified;
  2746 +
  2747 + /** @var float */
  2748 + public $grade;
  2749 +
  2750 + /** @var float */
  2751 + public $gradinggrade;
  2752 +
  2753 + /** @var float */
  2754 + public $gradinggradeover;
  2755 +
  2756 + /** @var array */
  2757 + protected $fields = array('id', 'submissionid', 'weight', 'timecreated',
  2758 + 'timemodified', 'grade', 'gradinggrade', 'gradinggradeover');
  2759 +}
  2760 +
2595 2761 /**
2596 2762 * Renderable message to be displayed to the user
2597 2763 *
@@ -2786,3 +2952,93 @@ public function get_options() {
2786 2952 return $this->options;
2787 2953 }
2788 2954 }
  2955 +
  2956 +
  2957 +/**
  2958 + * Base class for renderable feedback for author and feedback for reviewer
  2959 + */
  2960 +abstract class workshop_feedback {
  2961 +
  2962 + /** @var stdClass the user info */
  2963 + protected $provider = null;
  2964 +
  2965 + /** @var string the feedback text */
  2966 + protected $content = null;
  2967 +
  2968 + /** @var int format of the feedback text */
  2969 + protected $format = null;
  2970 +
  2971 + /**
  2972 + * @return stdClass the user info
  2973 + */
  2974 + public function get_provider() {
  2975 +
  2976 + if (is_null($this->provider)) {
  2977 + throw new coding_exception('Feedback provider not set');
  2978 + }
  2979 +
  2980 + return $this->provider;
  2981 + }
  2982 +
  2983 + /**
  2984 + * @return string the feedback text
  2985 + */
  2986 + public function get_content() {
  2987 +
  2988 + if (is_null($this->content)) {
  2989 + throw new coding_exception('Feedback content not set');
  2990 + }
  2991 +
  2992 + return $this->content;
  2993 + }
  2994 +
  2995 + /**
  2996 + * @return int format of the feedback text
  2997 + */
  2998 + public function get_format() {
  2999 +
  3000 + if (is_null($this->format)) {
  3001 + throw new coding_exception('Feedback text format not set');
  3002 + }
  3003 +
  3004 + return $this->format;
  3005 + }
  3006 +}
  3007 +
  3008 +
  3009 +/**
  3010 + * Renderable feedback for the author of submission
  3011 + */
  3012 +class workshop_feedback_author extends workshop_feedback implements renderable {
  3013 +
  3014 + /**
  3015 + * Extracts feedback from the given submission record
  3016 + *
  3017 + * @param stdClass $submission record as returned by {@see self::get_submission_by_id()}
  3018 + */
  3019 + public function __construct(stdClass $submission) {
  3020 +
  3021 + $this->provider = user_picture::unalias($submission, null, 'gradeoverbyx', 'gradeoverby');
  3022 + $this->content = $submission->feedbackauthor;
  3023 + $this->format = $submission->feedbackauthorformat;
  3024 + }
  3025 +}
  3026 +
  3027 +
  3028 +/**
  3029 + * Renderable feedback for the reviewer
  3030 + */
  3031 +class workshop_feedback_reviewer extends workshop_feedback implements renderable {
  3032 +
  3033 + /**
  3034 + * Extracts feedback from the given assessment record
  3035 + *
  3036 + * @param stdClass $assessment record as returned by eg {@see self::get_assessment_by_id()}
  3037 + */
  3038 + public function __construct(stdClass $assessment) {
  3039 +
  3040 + $this->provider = user_picture::unalias($assessment, null, 'gradinggradeoverbyx', 'overby');
  3041 + $this->content = $assessment->feedbackreviewer;
  3042 + $this->format = $assessment->feedbackreviewerformat;
  3043 + }
  3044 +}
156 mod/workshop/renderer.php
@@ -91,7 +91,14 @@ protected function render_workshop_submission(workshop_submission $submission) {
91 91 }
92 92 $o .= $this->output->container_start($classes);
93 93 $o .= $this->output->container_start('header');
94   - $o .= $this->output->heading(format_string($submission->title), 3, 'title');
  94 +
  95 + $title = format_string($submission->title);
  96 +
  97 + if ($this->page->url != $submission->url) {
  98 + $title = html_writer::link($submission->url, $title);
  99 + }
  100 +
  101 + $o .= $this->output->heading($title, 3, 'title');
95 102
96 103 if (!$anonymous) {
97 104 $author = new stdclass();
@@ -490,6 +497,137 @@ protected function render_workshop_grading_report(workshop_grading_report $gradi
490 497 return html_writer::table($table);
491 498 }
492 499
  500 + /**
  501 + * Renders the feedback for the author of the submission
  502 + *
  503 + * @param workshop_feedback_author $feedback
  504 + * @return string HTML
  505 + */
  506 + protected function render_workshop_feedback_author(workshop_feedback_author $feedback) {
  507 + return $this->helper_render_feedback($feedback);
  508 + }
  509 +
  510 + /**
  511 + * Renders the feedback for the reviewer of the submission
  512 + *
  513 + * @param workshop_feedback_reviewer $feedback
  514 + * @return string HTML
  515 + */
  516 + protected function render_workshop_feedback_reviewer(workshop_feedback_reviewer $feedback) {
  517 + return $this->helper_render_feedback($feedback);
  518 + }
  519 +
  520 + /**
  521 + * Helper method to rendering feedback
  522 + *
  523 + * @param workshop_feedback_author|workshop_feedback_reviewer $feedback
  524 + * @return string HTML
  525 + */
  526 + private function helper_render_feedback($feedback) {
  527 +
  528 + $o = ''; // output HTML code
  529 + $o .= $this->output->container_start('feedback feedbackforauthor');
  530 + $o .= $this->output->container_start('header');
  531 + $o .= $this->output->heading(get_string('feedbackby', 'workshop', s(fullname($feedback->get_provider()))), 3, 'title');
  532 +
  533 + $userpic = $this->output->user_picture($feedback->get_provider(), array('courseid' => $this->page->course->id, 'size' => 32));
  534 + $o .= $this->output->container($userpic, 'picture');
  535 + $o .= $this->output->container_end(); // end of header
  536 +
  537 + $content = format_text($feedback->get_content(), $feedback->get_format(), array('overflowdiv' => true));
  538 + $o .= $this->output->container($content, 'content');
  539 +
  540 + $o .= $this->output->container_end();
  541 +
  542 + return $o;
  543 + }
  544 +
  545 + /**
  546 + * Renders the full assessment
  547 + *
  548 + * @param workshop_assessment $assessment
  549 + * @return string HTML
  550 + */
  551 + protected function render_workshop_assessment(workshop_assessment $assessment) {
  552 +
  553 + $o = ''; // output HTML code
  554 + $anonymous = is_null($assessment->reviewer);
  555 + $classes = 'assessment-full';
  556 + if ($anonymous) {
  557 + $classes .= ' anonymous';
  558 + }
  559 +
  560 + $o .= $this->output->container_start($classes);
  561 + $o .= $this->output->container_start('header');
  562 +
  563 + if (!empty($assessment->title)) {
  564 + $title = s($assessment->title);
  565 + } else {
  566 + $title = get_string('assessment', 'workshop');
  567 + }
  568 + if ($this->page->url != $assessment->url) {
  569 + $o .= $this->output->container(html_writer::link($assessment->url, $title), 'title');
  570 + } else {
  571 + $o .= $this->output->container($title, 'title');
  572 + }
  573 +
  574 + if (!$anonymous) {
  575 + $reviewer = $assessment->reviewer;
  576 + $userpic = $this->output->user_picture($reviewer, array('courseid' => $this->page->course->id, 'size' => 32));
  577 +
  578 + $userurl = new moodle_url('/user/view.php',
  579 + array('id' => $reviewer->id, 'course' => $this->page->course->id));
  580 + $a = new stdClass();
  581 + $a->name = fullname($reviewer);
  582 + $a->url = $userurl->out();
  583 + $byfullname = get_string('assessmentby', 'workshop', $a);
  584 + $oo = $this->output->container($userpic, 'picture');
  585 + $oo .= $this->output->container($byfullname, 'fullname');
  586 +
  587 + $o .= $this->output->container($oo, 'reviewer');
  588 + }
  589 +
  590 + if (is_null($assessment->realgrade)) {
  591 + $o .= $this->output->container(
  592 + get_string('notassessed', 'workshop'),
  593 + 'grade nograde'
  594 + );
  595 + } else {
  596 + $a = new stdClass();
  597 + $a->max = $assessment->maxgrade;
  598 + $a->received = $assessment->realgrade;
  599 + $o .= $this->output->container(
  600 + get_string('gradeinfo', 'workshop', $a),
  601 + 'grade'
  602 + );
  603 +
  604 + if (!is_null($assessment->weight) and $assessment->weight != 1) {
  605 + $o .= $this->output->container(
  606 + get_string('weightinfo', 'workshop', $assessment->weight),
  607 + 'weight'
  608 + );
  609 + }
  610 + }
  611 +
  612 + $o .= $this->output->container_start('actions');
  613 + foreach ($assessment->actions as $action) {
  614 + $o .= $this->output->single_button($action->url, $action->label, $action->method);
  615 + }
  616 + $o .= $this->output->container_end(); // actions
  617 +
  618 + $o .= $this->output->container_end(); // header
  619 +
  620 + if (!is_null($assessment->form)) {
  621 + $o .= print_collapsible_region_start('assessment-form-wrapper', uniqid('workshop-assessment'),
  622 + get_string('assessmentform', 'workshop'), '', false, true);
  623 + $o .= $this->output->container(self::moodleform($assessment->form), 'assessment-form');
  624 + $o .= print_collapsible_region_end(true);
  625 + }
  626 +
  627 + $o .= $this->output->container_end(); // main wrapper
  628 +
  629 + return $o;
  630 + }
493 631
494 632 ////////////////////////////////////////////////////////////////////////////
495 633 // Internal rendering helper methods
@@ -727,6 +865,22 @@ protected function helper_grading_report_grade($grade, $over=null) {
727 865 ////////////////////////////////////////////////////////////////////////////
728 866
729 867 /**
  868 + * Helper method dealing with the fact we can not just fetch the output of moodleforms
  869 + *
  870 + * @param moodleform $mform
  871 + * @return string HTML
  872 + */
  873 + protected static function moodleform(moodleform $mform) {
  874 +
  875 + ob_start();
  876 + $mform->display();
  877 + $o = ob_get_contents();
  878 + ob_end_clean();
  879 +
  880 + return $o;
  881 + }
  882 +
  883 + /**
730 884 * Helper function returning the n-th item of the array
731 885 *
732 886 * @param array $a
98 mod/workshop/styles.css
@@ -45,7 +45,8 @@
45 45
46 46 .path-mod-workshop .submission-summary.anonymous .title,
47 47 .path-mod-workshop .submission-summary.anonymous .author,
48   -.path-mod-workshop .submission-summary.anonymous .userdate {
  48 +.path-mod-workshop .submission-summary.anonymous .userdate,
  49 +.path-mod-workshop .submission-summary.anonymous .grade-status {
49 50 margin: 0px 0px 0px 5px;
50 51 }
51 52
@@ -309,16 +310,75 @@
309 310 }
310 311
311 312 /**
312   - * Assessment
  313 + * Assessment - full display
313 314 */
314   -.path-mod-workshop .assessment-summary.graded {
  315 +.path-mod-workshop .assessment-full {
  316 + border: 1px solid #ddd;
  317 + margin: 0px auto 1em auto;
  318 +}
  319 +
  320 +.path-mod-workshop .assessment-full .header {
  321 + position: relative;
  322 + background-color: #ddd;
  323 + padding: 3px;
  324 + min-height: 35px;
  325 +}
  326 +
  327 +.path-mod-workshop .assessment-full .header .title {
  328 + font-weight: bold;
  329 +}
  330 +
  331 +.path-mod-workshop .assessment-full .header .title,
  332 +.path-mod-workshop .assessment-full .header .reviewer,
  333 +.path-mod-workshop .assessment-full .header .grade,
  334 +.path-mod-workshop .assessment-full .header .weight {
  335 + margin: 0px 0px 0px 40px;
  336 +}
  337 +
  338 +.path-mod-workshop .assessment-full.anonymous .header .title,
  339 +.path-mod-workshop .assessment-full.anonymous .header .reviewer,
  340 +.path-mod-workshop .assessment-full.anonymous .header .grade,
  341 +.path-mod-workshop .assessment-full.anonymous .header .weight {
  342 + margin: 0px 0px 0px 5px;
  343 +}
  344 +
  345 +.path-mod-workshop .assessment-full .header .reviewer .picture {
  346 + position: absolute;
  347 + top: 3px;
  348 + left: 3px;
  349 +}
  350 +
  351 +.path-mod-workshop .assessment-full .header .actions {
  352 + position: absolute;
  353 + top: 5px;
  354 + right: 5px;
  355 + text-align: right;
  356 +}
  357 +
  358 +.path-mod-workshop .assessment-full .header .actions .singlebutton,
  359 +.path-mod-workshop .assessment-full .header .actions .singlebutton form,
  360 +.path-mod-workshop .assessment-full .header .actions .singlebutton form div {
  361 + display: inline;
  362 +}
  363 +
  364 +.path-mod-workshop .assessment-full .assessment-form-wrapper {
  365 + margin-top: 0.5em;
  366 + padding: 0px 1em;
  367 +}
  368 +
  369 +.path-mod-workshop .assessment-summary.graded .singlebutton input[type="submit"],
  370 +.path-mod-workshop .example-summary.graded .singlebutton input[type="submit"] {
315 371 background-color: #e7f1c3;
316 372 }
317 373
318   -.path-mod-workshop .example-summary.notgraded {
  374 +.path-mod-workshop .assessment-summary.notgraded .singlebutton input[type="submit"],
  375 +.path-mod-workshop .example-summary.notgraded .singlebutton input[type="submit"] {
319 376 background-color: #ffd3d9;
320 377 }
321 378
  379 +/**
  380 + * Assessment form
  381 + */
322 382 .path-mod-workshop .assessmentform .description {
323 383 margin: 0px 1em;
324 384 }
@@ -396,6 +456,36 @@
396 456 }
397 457
398 458 /**
  459 + * Feedback
  460 + */
  461 +.path-mod-workshop .feedback {
  462 + border: 1px solid #ddd;
  463 + margin: 0px auto 1em auto;
  464 + width: 80%;
  465 +}
  466 +
  467 +.path-mod-workshop .feedback .header {
  468 + position: relative;
  469 + background-color: #ddd;
  470 + padding: 3px;
  471 + min-height: 35px;
  472 +}
  473 +
  474 +.path-mod-workshop .feedback .header .title {
  475 + margin: 0px 0px 0px 40px;
  476 +}
  477 +
  478 +.path-mod-workshop .feedback .header .picture {
  479 + position: absolute;
  480 + top: 3px;
  481 + left: 3px;
  482 +}
  483 +
  484 +.path-mod-workshop .feedback .content {
  485 + padding: 5px 10px;
  486 +}
  487 +
  488 +/**
399 489 * Misc
400 490 */
401 491 .path-mod-workshop div.buttonsbar {
106 mod/workshop/submission.php
@@ -43,7 +43,11 @@
43 43 $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
44 44 $workshop = new workshop($workshop, $cm, $course);
45 45
46   -$PAGE->set_url($workshop->submission_url(), array('cmid' => $cmid, 'id' => $id, 'edit' => $edit));
  46 +$PAGE->set_url($workshop->submission_url(), array('cmid' => $cmid, 'id' => $id));
  47 +
  48 +if ($edit) {
  49 + $PAGE->url->param('edit', $edit);
  50 +}
47 51
48 52 if ($id) { // submission is specified
49 53 $submission = $workshop->get_submission_by_id($id);
@@ -272,69 +276,79 @@
272 276 echo $output->single_button($url, get_string('assess', 'workshop'), 'post');
273 277 }
274 278
  279 +if (($workshop->phase == workshop::PHASE_CLOSED) and ($ownsubmission or $canviewall)) {
  280 + if (!empty($submission->gradeoverby) and strlen(trim($submission->feedbackauthor)) > 0) {
  281 + echo $output->render(new workshop_feedback_author($submission));
  282 + }
  283 +}
  284 +
275 285 // and possibly display the submission's review(s)
276 286
277 287 if ($isreviewer) {
278   - $strategy = $workshop->grading_strategy_instance();
279   - $mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $userassessment, false);
280   - echo $output->heading(get_string('assessmentbyyourself', 'workshop'), 2);
281   - // reviewers can always see the grades they gave even they are not available yet
282   - if (is_null($userassessment->grade)) {
283   - echo $output->heading(get_string('notassessed', 'workshop'), 3);
284   - if ($workshop->assessing_allowed()) {
285   - echo $output->container($output->single_button($workshop->assess_url($userassessment->id), get_string('assess', 'workshop'), 'get'),
286   - array('class' => 'buttonsbar'));
287   - }
288   - } else {
289   - $a = new stdclass();
290   - $a->max = $workshop->real_grade(100);
291   - $a->received = $workshop->real_grade($userassessment->grade);
292   - echo $output->heading(get_string('gradeinfo', 'workshop', $a), 3);
293   - if ($userassessment->weight != 1) {
294   - echo $output->heading(get_string('weightinfo', 'workshop', $userassessment->weight), 3);
  288 + // user's own assessment
  289 + $strategy = $workshop->grading_strategy_instance();
  290 + $mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $userassessment, false);
  291 + $options = array(
  292 + 'showreviewer' => true,
  293 + 'showauthor' => $showauthor,
  294 + 'showform' => !is_null($userassessment->grade),
  295 + 'showweight' => true,
  296 + );
  297 + $assessment = $workshop->prepare_assessment($userassessment, $mform, $options);
  298 + $assessment->title = get_string('assessmentbyyourself', 'workshop');
  299 +
  300 + if ($workshop->assessing_allowed()) {
  301 + if (is_null($userassessment->grade)) {
  302 + $assessment->add_action($workshop->assess_url($assessment->id), get_string('assess', 'workshop'));
  303 + } else {
  304 + $assessment->add_action($workshop->assess_url($assessment->id), get_string('reassess', 'workshop'));
295 305 }
296   - if ($workshop->assessing_allowed()) {
297   - echo $output->container($output->single_button($workshop->assess_url($userassessment->id), get_string('reassess', 'workshop'), 'get'),
298   - array('class' => 'buttonsbar'));
  306 + }
  307 + if ($canoverride) {
  308 + $assessment->add_action($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'));
  309 + }
  310 +
  311 + echo $output->render($assessment);
  312 +
  313 + if ($workshop->phase == workshop::PHASE_CLOSED) {
  314 + if (strlen(trim($userassessment->feedbackreviewer)) > 0) {
  315 + echo $output->render(new workshop_feedback_reviewer($userassessment));
299 316 }
300   - $mform->display();
301 317 }
302 318 }
303 319
304 320 if (has_capability('mod/workshop:viewallassessments', $workshop->context) or ($ownsubmission and $workshop->assessments_available())) {
305   - $strategy = $workshop->grading_strategy_instance();
306   - $assessments = $workshop->get_assessments_of_submission($submission->id);
307   - $canviewreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);
  321 + // other assessments
  322 + $strategy = $workshop->grading_strategy_instance();
  323 + $assessments = $workshop->get_assessments_of_submission($submission->id);
  324 + $showreviewer = has_capability('mod/workshop:viewreviewernames', $workshop->context);
308 325 foreach ($assessments as $assessment) {
309 326 if ($assessment->reviewerid == $USER->id) {
310 327 // own assessment has been displayed already
311 328 continue;
312 329 }
313   - if (is_null($assessment->grade)) {
314   - // not graded assessment are not displayed
  330 + if (is_null($assessment->grade) and !has_capability('mod/workshop:viewallassessments', $workshop->context)) {
  331 + // students do not see peer-assessment that are not graded yet
315 332 continue;
316 333 }
317   - if ($canviewreviewernames) {
318   - $reviewer = new stdclass();
319   - $reviewer->firstname = $assessment->reviewerfirstname;
320   - $reviewer->lastname = $assessment->reviewerlastname;
321   - echo $output->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
322   - } else {
323   - echo $output->heading(get_string('assessmentbyunknown', 'workshop'), 2);
324   - }
325   - $a = new stdclass();
326   - $a->max = $workshop->real_grade(100);
327   - $a->received = $workshop->real_grade($assessment->grade);
328   - echo $output->heading(get_string('gradeinfo', 'workshop', $a), 3);
329   - if ($assessment->weight != 1) {
330   - echo $output->heading(get_string('weightinfo', 'workshop', $assessment->weight), 3);
  334 + $mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, false);
  335 + $options = array(
  336 + 'showreviewer' => $showreviewer,
  337 + 'showauthor' => $showauthor,
  338 + 'showform' => !is_null($assessment->grade),
  339 + 'showweight' => true,
  340 + );
  341 + $displayassessment = $workshop->prepare_assessment($assessment, $mform, $options);
  342 + if ($canoverride) {
  343 + $displayassessment->add_action($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'));
331 344 }
332   - if (has_capability('mod/workshop:overridegrades', $workshop->context)) {
333   - echo $output->container($output->single_button($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'), 'get'),
334   - array('class' => 'buttonsbar'));
  345 + echo $output->render($displayassessment);
  346 +
  347 + if ($workshop->phase == workshop::PHASE_CLOSED and has_capability('mod/workshop:viewallassessments', $workshop->context)) {
  348 + if (strlen(trim($assessment->feedbackreviewer)) > 0) {
  349 + echo $output->render(new workshop_feedback_reviewer($assessment));
  350 + }
335 351 }
336   - $mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, false);
337   - $mform->display();
338 352 }
339 353 }
340 354
9 mod/workshop/view.php
@@ -493,6 +493,11 @@
493 493 echo $output->container(get_string('noyoursubmission', 'workshop'));
494 494 }
495 495 echo $output->box_end();
  496 +
  497 + if (!empty($submission->gradeoverby) and strlen(trim($submission->feedbackauthor)) > 0) {
  498 + echo $output->render(new workshop_feedback_author($submission));
  499 + }
  500 +
496 501 print_collapsible_region_end();
497 502 }
498 503 if (has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context)) {
@@ -535,6 +540,10 @@
535 540 echo $output->box_start('generalbox assessment-summary' . $class);
536 541 echo $output->render($workshop->prepare_submission_summary($submission, $shownames));
537 542 echo $output->box_end();
  543 +
  544 + if (strlen(trim($assessment->feedbackreviewer)) > 0) {
  545 + echo $output->render(new workshop_feedback_reviewer($assessment));
  546 + }
538 547 }
539 548 print_collapsible_region_end();
540 549 }

0 comments on commit e8a165d

Please sign in to comment.
Something went wrong with that request. Please try again.