$string['backtoeditform'] = 'Back to editing form';
$string['byfullname'] = 'by <a href=\"{$a->url}\">{$a->name}</a>';
$string['calculatetotalgrades'] = 'Calculate total grades';
-$string['calculatetotalgradesdetails'] = 'expected: $a->expected<br />known: $a->known';
+$string['calculatetotalgradesdetails'] = 'expected: $a->expected<br />calculated: $a->known';
$string['configexamplesmode'] = 'Default mode of examples assessment in workshops';
$string['configgradedecimals'] = 'Default number of digits that should be shown after the decimal point when displaying grades.';
$string['configgrade'] = 'Default maximum grade for submission in workshops';
$task->completed = 'info';
$phase->tasks['totalgradesmissinginfo'] = $task;
}
- } else {
+ } elseif ($this->phase == self::PHASE_EVALUATION) {
$task = new stdClass();
$task->title = get_string('evaluategradeswait', 'workshop');
$task->completed = 'info';
// we will need to know the number of all records later for the pagination purposes
$numofparticipants = count($participants);
- // load all fields which can be used sorting and paginate the records
+ // load all fields which can be used for sorting and paginate the records
list($participantids, $params) = $DB->get_in_or_equal(array_keys($participants), SQL_PARAMS_NAMED);
- $params['workshopid'] = $this->id;
+ $params['workshopid1'] = $this->id;
+ $params['workshopid2'] = $this->id;
$sqlsort = $sortby . ' ' . $sorthow . ',u.lastname,u.firstname,u.id';
$sql = "SELECT u.id AS userid,u.firstname,u.lastname,u.picture,u.imagealt,
s.title AS submissiontitle, s.grade AS submissiongrade, ag.gradinggrade, ag.totalgrade
FROM {user} u
- LEFT JOIN {workshop_submissions} s ON (s.authorid = u.id)
- LEFT JOIN {workshop_aggregations} ag ON (ag.userid = u.id AND ag.workshopid = s.workshopid)
- WHERE s.workshopid = :workshopid AND s.example = 0 AND u.id $participantids
+ LEFT JOIN {workshop_submissions} s ON (s.authorid = u.id AND s.workshopid = :workshopid1 AND s.example = 0)
+ LEFT JOIN {workshop_aggregations} ag ON (ag.userid = u.id AND ag.workshopid = :workshopid2)
+ WHERE u.id $participantids
ORDER BY $sqlsort";
$participants = $DB->get_records_sql($sql, $params, $page * $perpage, $perpage);
if ($participants) {
list($participantids, $params) = $DB->get_in_or_equal(array_keys($participants), SQL_PARAMS_NAMED);
$params['workshopid'] = $this->id;
- $sql = "SELECT a.id AS assessmentid, a.submissionid, a.grade, a.gradinggrade, a.gradinggradeover,
- u.id AS reviewerid,
+ $sql = "SELECT a.id AS assessmentid, a.submissionid, a.grade, a.gradinggrade, a.gradinggradeover, a.reviewerid,
s.id AS submissionid,
e.id AS authorid, e.lastname, e.firstname, e.picture, e.imagealt
FROM {user} u
foreach ($participants as $participant) {
// set up default (null) values
+ $grades[$participant->userid]->submissionid = null;
+ $grades[$participant->userid]->submissiontitle = null;
+ $grades[$participant->userid]->submissiongrade = null;
+ $grades[$participant->userid]->submissiongradeover = null;
+ $grades[$participant->userid]->submissiongradeoverby = null;
$grades[$participant->userid]->reviewedby = array();
$grades[$participant->userid]->reviewerof = array();
}
* @return float suitable to be stored as numeric(10,5)
*/
public function raw_grade_value($value, $max) {
- if (empty($value)) {
+ if (is_null($value)) {
return null;
}
if ($max == 0 or $value < 0) {
* the [[nullgrade]] string shall be displayed).
*
* @param stdClass $data prepared by {@link workshop::prepare_grading_report()}
- * @param bool $showauthornames
- * @param bool $showreviewernames
- * @param string $sortby
- * @param string $sorthow
+ * @param stdClass $options display options object with properties ->showauthornames ->showreviewernames ->sortby ->sorthow
+ * ->showsubmissiongrade ->showgradinggrade ->showtotalgrade
* @return string html code
*/
- public function grading_report(stdClass $data, $showauthornames, $showreviewernames, $sortby, $sorthow) {
- $grades = $data->grades;
- $userinfo = $data->userinfo;
+ public function grading_report(stdClass $data, stdClass $options) {
+ $grades = $data->grades;
+ $userinfo = $data->userinfo;
if (empty($grades)) {
return '';
$table = new html_table();
$table->set_classes('grading-report');
- $sortbyfirstname = $this->sortable_heading(get_string('firstname'), 'firstname', $sortby, $sorthow);
- $sortbylastname = $this->sortable_heading(get_string('lastname'), 'lastname', $sortby, $sorthow);
+ $sortbyfirstname = $this->sortable_heading(get_string('firstname'), 'firstname', $options->sortby, $options->sorthow);
+ $sortbylastname = $this->sortable_heading(get_string('lastname'), 'lastname', $options->sortby, $options->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('submissiongradeof', 'workshop', $data->maxgrade),
- 'submissiongrade', $sortby, $sorthow),
- $this->sortable_heading(get_string('givengrades', 'workshop')),
- $this->sortable_heading(get_string('gradinggradeof', 'workshop', $data->maxgradinggrade),
- 'gradinggrade', $sortby, $sorthow),
- $this->sortable_heading(get_string('totalgradeof', 'workshop', $data->maxtotalgrade),
- 'totalgrade', $sortby, $sorthow),
- );
+ $table->head = array();
+ $table->head[] = $sortbyname;
+ $table->head[] = $this->sortable_heading(get_string('submission', 'workshop'), 'submissiontitle',
+ $options->sortby, $options->sorthow);
+ $table->head[] = $this->sortable_heading(get_string('receivedgrades', 'workshop'));
+ if ($options->showsubmissiongrade) {
+ $table->head[] = $this->sortable_heading(get_string('submissiongradeof', 'workshop', $data->maxgrade),
+ 'submissiongrade', $options->sortby, $options->sorthow);
+ }
+ $table->head[] = $this->sortable_heading(get_string('givengrades', 'workshop'));
+ if ($options->showgradinggrade) {
+ $table->head[] = $this->sortable_heading(get_string('gradinggradeof', 'workshop', $data->maxgradinggrade),
+ 'gradinggrade', $options->sortby, $options->sorthow);
+ }
+ if ($options->showtotalgrade) {
+ $table->head[] = $this->sortable_heading(get_string('totalgradeof', 'workshop', $data->maxtotalgrade),
+ 'totalgrade', $options->sortby, $options->sorthow);
+ }
+
$table->rowclasses = array();
$table->colclasses = array();
$table->data = array();
$cell = new html_table_cell();
$cell->text = $this->grading_report_participant($participant, $userinfo);
$cell->rowspan = $numoftrs;
+ $cell->add_class('participant');
$row->cells[] = $cell;
}
// column #2 - submission - spans over all rows
$cell = new html_table_cell();
$cell->text = $this->grading_report_submission($participant);
$cell->rowspan = $numoftrs;
+ $cell->add_class('submission');
$row->cells[] = $cell;
}
// column #3 - received grades
if ($tr % $spanreceived == 0) {
$idx = intval($tr / $spanreceived);
+ $assessment = self::array_nth($participant->reviewedby, $idx);
$cell = new html_table_cell();
- $cell->text = $this->grading_report_assessment(self::array_nth($participant->reviewedby, $idx),
- $showreviewernames, $userinfo, get_string('gradereceivedfrom', 'workshop'));
+ $cell->text = $this->grading_report_assessment($assessment, $options->showreviewernames, $userinfo,
+ get_string('gradereceivedfrom', 'workshop'));
$cell->rowspan = $spanreceived;
+ $cell->add_class('receivedgrade');
+ if (is_null($assessment) or is_null($assessment->grade)) {
+ $cell->add_class('null');
+ } else {
+ $cell->add_class('notnull');
+ }
$row->cells[] = $cell;
}
// column #4 - total grade for submission
- if ($tr == 0) {
+ if ($options->showsubmissiongrade and $tr == 0) {
$cell = new html_table_cell();
$cell->text = $this->grading_report_grade($participant->submissiongrade, $participant->submissiongradeover);
$cell->rowspan = $numoftrs;
+ $cell->add_class('submissiongrade');
$row->cells[] = $cell;
}
// column #5 - given grades
if ($tr % $spangiven == 0) {
$idx = intval($tr / $spangiven);
+ $assessment = self::array_nth($participant->reviewerof, $idx);
$cell = new html_table_cell();
- $cell->text = $this->grading_report_assessment(self::array_nth($participant->reviewerof, $idx),
- $showauthornames, $userinfo, get_string('gradegivento', 'workshop'));
+ $cell->text = $this->grading_report_assessment($assessment, $options->showauthornames, $userinfo,
+ get_string('gradegivento', 'workshop'));
$cell->rowspan = $spangiven;
+ $cell->add_class('givengrade');
+ if (is_null($assessment) or is_null($assessment->grade)) {
+ $cell->add_class('null');
+ } else {
+ $cell->add_class('notnull');
+ }
$row->cells[] = $cell;
}
// column #6 - total grade for assessment
- if ($tr == 0) {
+ if ($options->showgradinggrade and $tr == 0) {
$cell = new html_table_cell();
$cell->text = $this->grading_report_grade($participant->gradinggrade);
$cell->rowspan = $numoftrs;
+ $cell->add_class('gradinggrade');
$row->cells[] = $cell;
}
// column #7 - total grade for assessment
- if ($tr == 0) {
+ if ($options->showtotalgrade and $tr == 0) {
$cell = new html_table_cell();
if (is_null($participant->totalgrade)) {
$cell->text = get_string('nullgrade', 'workshop');
}
$cell->text = $this->grading_report_grade($participant->totalgrade);
$cell->rowspan = $numoftrs;
+ $cell->add_class('totalgrade');
$row->cells[] = $cell;
}
$table->data[] = $row;
white-space: nowrap;
}
-.mod-workshop .grading-report td.c3,
-.mod-workshop .grading-report td.c5 {
+.mod-workshop .grading-report .submissiongrade,
+.mod-workshop .grading-report .gradinggrade {
text-align: center;
font-size: 160%;
white-space: nowrap;
}
-.mod-workshop .grading-report td.c6 {
+.mod-workshop .grading-report .givengrade.null .user,
+.mod-workshop .grading-report .receivedgrade.null .user {
+ color: #ee0000;
+}
+
+.mod-workshop .grading-report .totalgrade {
text-align: center;
font-size: 220%;
}
}
break;
case workshop::PHASE_ASSESSMENT:
+ if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
+ $page = optional_param('page', 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
+ $PAGE->set_url(new moodle_url($PAGE->url, compact('sortby', 'sorthow', 'page')));
+ $data = $workshop->prepare_grading_report($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
+ if ($data) {
+ $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context);
+ $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);
+
+ // prepare paging bar
+ $pagingbar = new moodle_paging_bar();
+ $pagingbar->totalcount = $data->totalcount;
+ $pagingbar->page = $page;
+ $pagingbar->perpage = $perpage;
+ $pagingbar->baseurl = $PAGE->url;
+ $pagingbar->pagevar = 'page';
+
+ // grading report display options
+ $reportopts = new stdClass();
+ $reportopts->showauthornames = $showauthornames;
+ $reportopts->showreviewernames = $showreviewernames;
+ $reportopts->sortby = $sortby;
+ $reportopts->sorthow = $sorthow;
+ $reportopts->showsubmissiongrade = false;
+ $reportopts->showgradinggrade = false;
+ $reportopts->showtotalgrade = false;
+
+ echo $OUTPUT->paging_bar($pagingbar);
+ echo $wsoutput->grading_report($data, $reportopts);
+ echo $OUTPUT->paging_bar($pagingbar);
+ }
+ }
if (trim(strip_tags($workshop->instructreviewers))) {
$instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id,
'workshop_instructreviewers', 0, workshop::instruction_editors_options($PAGE->context));
}
break;
case workshop::PHASE_EVALUATION:
- if (has_capability('mod/workshop:overridegrades', $PAGE->context)) {
+ if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
$page = optional_param('page', 0, PARAM_INT);
$sortby = optional_param('sortby', 'lastname', PARAM_ALPHA);
$sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA);
$showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context);
$showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);
- // load the grading evaluator
- $evaluator = $workshop->grading_evaluation_instance();
- $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(), compact('sortby', 'sorthow', 'page')));
- $form->display();
+ if (has_capability('mod/workshop:overridegrades', $PAGE->context)) {
+ // load the grading evaluator
+ $evaluator = $workshop->grading_evaluation_instance();
+ $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(),
+ compact('sortby', 'sorthow', 'page')));
+ $form->display();
+ }
// prepare paging bar
$pagingbar = new moodle_paging_bar();
$pagingbar->baseurl = $PAGE->url;
$pagingbar->pagevar = 'page';
+ // grading report display options
+ $reportopts = new stdClass();
+ $reportopts->showauthornames = $showauthornames;
+ $reportopts->showreviewernames = $showreviewernames;
+ $reportopts->sortby = $sortby;
+ $reportopts->sorthow = $sorthow;
+ $reportopts->showsubmissiongrade = true;
+ $reportopts->showgradinggrade = true;
+ $reportopts->showtotalgrade = true;
+
echo $OUTPUT->paging_bar($pagingbar);
- echo $wsoutput->grading_report($data, $showauthornames, $showreviewernames, $sortby, $sorthow);
+ echo $wsoutput->grading_report($data, $reportopts);
echo $OUTPUT->paging_bar($pagingbar);
}
}