$string[''] = '';
$string[''] = '';
$string[''] = '';
-$string['aggregationinfo'] = 'During the aggregation process, the grades for submission, grades for assessment and total grades are re-calculated and stored into the Workshop database. This does not modify any manual overrides nor does not push the total grade into the gradebook.';
-$string['aggregation'] = 'Grades aggregation';
-$string['aggregategrades'] = 'Re-calculate grades';
-$string['nullgrade'] = '?';
-$string['formatpeergradeover'] = '$a->grade (<del>$a->gradinggrade</del> / <ins>$a->gradinggradeover</ins>)';
-$string['formatpeergrade'] = '$a->grade ($a->gradinggrade)';
$string['accesscontrol'] = 'Access control';
+$string['aggregategrades'] = 'Re-calculate grades';
+$string['aggregation'] = 'Grades aggregation';
+$string['aggregationinfo'] = 'During the aggregation process, the grades for submission, grades for assessment and total grades are re-calculated and stored into the Workshop database. This does not modify any manual overrides nor does not push the total grade into the gradebook.';
$string['agreeassessments'] = 'Assessments must be agreed';
$string['agreeassessmentsdesc'] = 'Authors may comment assessments of their work and agree/disagree with it';
$string['allocate'] = 'Allocate submissions';
$string['examplesbeforesubmission'] = 'Examples must be assessed before own submission';
$string['examplesmode'] = 'Mode of examples assessment';
$string['examplesvoluntary'] = 'Assessment of example submission is voluntary';
+$string['formatpeergrade'] = '$a->grade ($a->gradinggrade)';
+$string['formatpeergradeover'] = '$a->grade (<del>$a->gradinggrade</del> / <ins>$a->gradinggradeover</ins>)';
$string['givengrade'] = 'Given grade: $a';
$string['givengrades'] = 'Given grades';
-$string['gradeforassessment'] = 'Grade for assessment';
-$string['gradeforsubmission'] = 'Grade for submission';
+$string['gradinggrade'] = 'Grade for assessment';
$string['gradingsettings'] = 'Grading settings';
$string['chooseuser'] = 'Choose user...';
$string['iamsure'] = 'Yes, I am sure';
$string['noworkshops'] = 'There are no workshops in this course';
$string['noyoursubmission'] = 'You have not submitted your work yet';
$string['nsassessments'] = 'Number of required assessments of other users\' work';
+$string['nullgrade'] = '?';
$string['numofreviews'] = 'Number of reviews';
$string['participant'] = 'Participant';
$string['participantrevierof'] = 'Participant is reviewer of';
$string['submissionattachment'] = 'Attachment';
$string['submissioncontent'] = 'Submission content';
$string['submissionend'] = 'End of submission phase';
+$string['submissiongrade'] = 'Grade for submission';
$string['submissionsettings'] = 'Submission settings';
$string['submissionstart'] = 'Start of submission phase';
$string['submission'] = 'Submission';
* @param stdClass $data prepared by {@link workshop::prepare_grading_report()}
* @param bool $showauthornames
* @param bool $showreviewernames
+ * @param string $sortby
+ * @param string $sorthow
* @return string html code
*/
- public function grading_report(stdClass $data, $showauthornames, $showreviewernames) {
+ public function grading_report(stdClass $data, $showauthornames, $showreviewernames, $sortby, $sorthow) {
$grades = $data->grades;
$userinfo = $data->userinfo;
return '';
}
- $table = new html_table();
+ $table = new html_table();
$table->set_classes('grading-report');
- $table->head = array(get_string('participant', 'workshop'),
- get_string('submission', 'workshop'),
- get_string('receivedgrades', 'workshop'),
- get_string('gradeforsubmission', 'workshop'),
- get_string('givengrades', 'workshop'),
- get_string('gradeforassessment', 'workshop'),
- get_string('totalgrade', 'workshop'));
+
+ $sortbyfirstname = $this->sortable_heading(get_string('firstname'), 'firstname', $sortby, $sorthow);
+ $sortbylastname = $this->sortable_heading(get_string('lastname'), 'lastname', $sortby, $sorthow);
+ if (self::fullname_format() == 'lf') {
+ $sortbyname = $sortbylastname . ' / ' . $sortbyfirstname;
+ } else {
+ $sortbyname = $sortbyfirstname . ' / ' . $sortbylastname;
+ }
+
+ $table->head = array(
+ $sortbyname,
+ $this->sortable_heading(get_string('submission', 'workshop'), 'submissiontitle', $sortby, $sorthow),
+ $this->sortable_heading(get_string('receivedgrades', 'workshop')),
+ $this->sortable_heading(get_string('submissiongrade', 'workshop'), 'submissiongrade', $sortby, $sorthow),
+ $this->sortable_heading(get_string('givengrades', 'workshop')),
+ $this->sortable_heading(get_string('gradinggrade', 'workshop'), 'gradinggrade', $sortby, $sorthow),
+ $this->sortable_heading(get_string('totalgrade', 'workshop'), 'totalgrade', $sortby, $sorthow),
+ );
$table->rowclasses = array();
$table->colclasses = array('reviewedby', 'peer', 'reviewerof');
$table->data = array();
return $this->output->table($table);
}
+ /**
+ * Renders a text with icons to sort by the given column
+ *
+ * This is intended for table headings.
+ *
+ * @param string $text The heading text
+ * @param string $sortid The column id used for sorting
+ * @param string $sortby Currently sorted by (column id)
+ * @param string $sorthow Currently sorted how (ASC|DESC)
+ *
+ * @return string
+ */
+ protected function sortable_heading($text, $sortid=null, $sortby=null, $sorthow=null) {
+ global $PAGE;
+
+ $out = $this->output->output_tag('span', array('class'=>'text'), $text);
+
+ if (!is_null($sortid)) {
+ $iconasc = new moodle_action_icon();
+ $iconasc->image->src = $this->old_icon_url('t/down');
+ $iconasc->image->alt = get_string('sortasc', 'workshop');
+ $iconasc->image->set_classes('sort asc');
+ $newurl = clone($PAGE->url);
+ $newurl->params(array('sortby' => $sortid, 'sorthow' => 'ASC'));
+ $iconasc->link->url = new moodle_url($newurl);
+
+ $icondesc = new moodle_action_icon();
+ $icondesc->image->src = $this->old_icon_url('t/up');
+ $icondesc->image->alt = get_string('sortdesc', 'workshop');
+ $icondesc->image->set_classes('sort desc');
+ $newurl = clone($PAGE->url);
+ $newurl->params(array('sortby' => $sortid, 'sorthow' => 'DESC'));
+ $icondesc->link->url = new moodle_url($newurl);
+
+ if ($sortby !== $sortid or $sorthow !== 'ASC') {
+ $out .= $this->output->action_icon($iconasc);
+ }
+ if ($sortby !== $sortid or $sorthow !== 'DESC') {
+ $out .= $this->output->action_icon($icondesc);
+ }
+ }
+ return $out;
+}
+
/**
* @param stdClass $participant
* @param array $userinfo
return $a[$key];
}
+ /**
+ * Tries to guess the fullname format set at the site
+ *
+ * @return string fl|lf
+ */
+ protected static function fullname_format() {
+ $fake = new stdClass(); // fake user
+ $fake->lastname = 'LLLL';
+ $fake->firstname = 'FFFF';
+ $fullname = get_string('fullnamedisplay', '', $fake);
+ if (strpos($fullname, 'LLLL') < strpos($fullname, 'FFFF')) {
+ return 'lf';
+ } else {
+ return 'fl';
+ }
+ }
+
}
case workshop::PHASE_EVALUATION:
$pagingvar = 'page';
$page = optional_param($pagingvar, 0, PARAM_INT);
+ $sortby = optional_param('sortby', 'lastname', PARAM_ALPHA);
+ $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA);
+
$perpage = 10; // todo let the user modify this
$groups = ''; // todo let the user choose the group
- $sortby = 'submissiongrade'; // todo let the user choose the column to sort by
- $sorthow = 'ASC'; // todo detto
-
$data = $workshop->prepare_grading_report($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
if ($data) {
$showauthornames = has_capability('mod/workshop:viewauthornames', $PAGE->context);
$pagingbar->pagevar = $pagingvar;
echo $OUTPUT->paging_bar($pagingbar);
- echo $wsoutput->grading_report($data, $showauthornames, $showreviewernames);
+ echo $wsoutput->grading_report($data, $showauthornames, $showreviewernames, $sortby, $sorthow);
echo $OUTPUT->paging_bar($pagingbar);
}
break;