From 70b10bcd8c0529641db93a9212fcd32841d454b5 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Fri, 18 Oct 2019 13:57:00 +0800 Subject: [PATCH] MDL-61121 assign: Improve accessibility in quick grading page tables --- mod/assign/renderer.php | 361 ++++++++++++++++++---------------------- 1 file changed, 162 insertions(+), 199 deletions(-) diff --git a/mod/assign/renderer.php b/mod/assign/renderer.php index 736c40f1320..eea7fac2a25 100644 --- a/mod/assign/renderer.php +++ b/mod/assign/renderer.php @@ -70,18 +70,28 @@ class mod_assign_renderer extends plugin_renderer_base { } /** - * Utility function to add a row of data to a table with 2 columns. Modified - * the table param and does not return a value + * Utility function to add a row of data to a table with 2 columns where the first column is the table's header. + * Modified the table param and does not return a value. * * @param html_table $table The table to append the row of data to * @param string $first The first column text * @param string $second The second column text + * @param array $firstattributes The first column attributes (optional) + * @param array $secondattributes The second column attributes (optional) * @return void */ - private function add_table_row_tuple(html_table $table, $first, $second) { + private function add_table_row_tuple(html_table $table, $first, $second, $firstattributes = [], + $secondattributes = []) { $row = new html_table_row(); $cell1 = new html_table_cell($first); + $cell1->header = true; + if (!empty($firstattributes)) { + $cell1->attributes = $firstattributes; + } $cell2 = new html_table_cell($second); + if (!empty($secondattributes)) { + $cell2->attributes = $secondattributes; + } $row->cells = array($cell1, $cell2); $table->data[] = $row; } @@ -274,8 +284,9 @@ class mod_assign_renderer extends plugin_renderer_base { $t = new html_table(); // Visibility Status. - $this->add_table_row_tuple($t, get_string('hiddenfromstudents'), - (!$summary->isvisible) ? get_string('yes') : get_string('no')); + $cell1content = get_string('hiddenfromstudents'); + $cell2content = (!$summary->isvisible) ? get_string('yes') : get_string('no'); + $this->add_table_row_tuple($t, $cell1content, $cell2content); // Status. if ($summary->teamsubmission) { @@ -284,70 +295,80 @@ class mod_assign_renderer extends plugin_renderer_base { } else if ($summary->warnofungroupedusers === assign_grading_summary::WARN_GROUPS_OPTIONAL) { $o .= $this->output->notification(get_string('ungroupedusersoptional', 'assign')); } - - $this->add_table_row_tuple($t, get_string('numberofteams', 'assign'), - $summary->participantcount); + $cell1content = get_string('numberofteams', 'assign'); } else { - $this->add_table_row_tuple($t, get_string('numberofparticipants', 'assign'), - $summary->participantcount); + $cell1content = get_string('numberofparticipants', 'assign'); } + $cell2content = $summary->participantcount; + $this->add_table_row_tuple($t, $cell1content, $cell2content); + // Drafts count and dont show drafts count when using offline assignment. if ($summary->submissiondraftsenabled && $summary->submissionsenabled) { - $this->add_table_row_tuple($t, get_string('numberofdraftsubmissions', 'assign'), - $summary->submissiondraftscount); + $cell1content = get_string('numberofdraftsubmissions', 'assign'); + $cell2content = $summary->submissiondraftscount; + $this->add_table_row_tuple($t, $cell1content, $cell2content); } // Submitted for grading. if ($summary->submissionsenabled) { - $this->add_table_row_tuple($t, get_string('numberofsubmittedassignments', 'assign'), - $summary->submissionssubmittedcount); + $cell1content = get_string('numberofsubmittedassignments', 'assign'); + $cell2content = $summary->submissionssubmittedcount; + $this->add_table_row_tuple($t, $cell1content, $cell2content); + if (!$summary->teamsubmission) { - $this->add_table_row_tuple($t, get_string('numberofsubmissionsneedgrading', 'assign'), - $summary->submissionsneedgradingcount); + $cell1content = get_string('numberofsubmissionsneedgrading', 'assign'); + $cell2content = $summary->submissionsneedgradingcount; + $this->add_table_row_tuple($t, $cell1content, $cell2content); } } $time = time(); if ($summary->duedate) { // Due date. + $cell1content = get_string('duedate', 'assign'); $duedate = $summary->duedate; if ($summary->courserelativedatesmode) { // Returns a formatted string, in the format '10d 10h 45m'. $diffstr = get_time_interval_string($duedate, $summary->coursestartdate); if ($duedate >= $summary->coursestartdate) { - $userduedate = get_string('relativedatessubmissionduedateafter', 'mod_assign', ['datediffstr' => $diffstr]); + $cell2content = get_string('relativedatessubmissionduedateafter', 'mod_assign', + ['datediffstr' => $diffstr]); } else { - $userduedate = get_string('relativedatessubmissionduedatebefore', 'mod_assign', ['datediffstr' => $diffstr]); + $cell2content = get_string('relativedatessubmissionduedatebefore', 'mod_assign', + ['datediffstr' => $diffstr]); } } else { - $userduedate = userdate($duedate); + $cell2content = userdate($duedate); } - $this->add_table_row_tuple($t, get_string('duedate', 'assign'), - $userduedate); + + $this->add_table_row_tuple($t, $cell1content, $cell2content); // Time remaining. + $cell1content = get_string('timeremaining', 'assign'); if ($summary->courserelativedatesmode) { - $due = get_string('relativedatessubmissiontimeleft', 'mod_assign'); + $cell2content = get_string('relativedatessubmissiontimeleft', 'mod_assign'); } else { - $due = ''; if ($duedate - $time <= 0) { - $due = get_string('assignmentisdue', 'assign'); + $cell2content = get_string('assignmentisdue', 'assign'); } else { - $due = format_time($duedate - $time); + $cell2content = format_time($duedate - $time); } } - $this->add_table_row_tuple($t, get_string('timeremaining', 'assign'), $due); + + $this->add_table_row_tuple($t, $cell1content, $cell2content); if ($duedate < $time) { + $cell1content = get_string('latesubmissions', 'assign'); $cutoffdate = $summary->cutoffdate; if ($cutoffdate) { if ($cutoffdate > $time) { - $late = get_string('latesubmissionsaccepted', 'assign', userdate($summary->cutoffdate)); + $cell2content = get_string('latesubmissionsaccepted', 'assign', userdate($summary->cutoffdate)); } else { - $late = get_string('nomoresubmissionsaccepted', 'assign'); + $cell2content = get_string('nomoresubmissionsaccepted', 'assign'); } - $this->add_table_row_tuple($t, get_string('latesubmissions', 'assign'), $late); + + $this->add_table_row_tuple($t, $cell1content, $cell2content); } } @@ -358,21 +379,23 @@ class mod_assign_renderer extends plugin_renderer_base { $o .= $this->output->box_end(); // Link to the grading page. - $o .= '
'; + $o .= html_writer::start_tag('center'); $o .= $this->output->container_start('submissionlinks'); $urlparams = array('id' => $summary->coursemoduleid, 'action' => 'grading'); $url = new moodle_url('/mod/assign/view.php', $urlparams); - $o .= '' . get_string('viewgrading', 'mod_assign') . ' '; + $o .= html_writer::link($url, get_string('viewgrading', 'mod_assign'), + ['class' => 'btn btn-secondary']); if ($summary->cangrade) { $urlparams = array('id' => $summary->coursemoduleid, 'action' => 'grader'); $url = new moodle_url('/mod/assign/view.php', $urlparams); - $o .= '' . get_string('grade') . ''; + $o .= html_writer::link($url, get_string('grade'), + ['class' => 'btn btn-primary ml-1']); } $o .= $this->output->container_end(); // Close the container and insert a spacer. $o .= $this->output->container_end(); - $o .= '
'; + $o .= html_writer::end_tag('center'); return $o; } @@ -384,7 +407,6 @@ class mod_assign_renderer extends plugin_renderer_base { * @return string */ public function render_assign_feedback_status(assign_feedback_status $status) { - global $DB, $CFG; $o = ''; $o .= $this->output->container_start('feedback'); @@ -394,30 +416,23 @@ class mod_assign_renderer extends plugin_renderer_base { // Grade. if (isset($status->gradefordisplay)) { - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('grade')); - $cell2 = new html_table_cell($status->gradefordisplay); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = get_string('grade'); + $cell2content = $status->gradefordisplay; + $this->add_table_row_tuple($t, $cell1content, $cell2content); // Grade date. - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('gradedon', 'assign')); - $cell2 = new html_table_cell(userdate($status->gradeddate)); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = get_string('gradedon', 'assign'); + $cell2content = userdate($status->gradeddate); + $this->add_table_row_tuple($t, $cell1content, $cell2content); } if ($status->grader) { // Grader. - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('gradedby', 'assign')); - $userdescription = $this->output->user_picture($status->grader) . - $this->output->spacer(array('width'=>30)) . - fullname($status->grader, $status->canviewfullnames); - $cell2 = new html_table_cell($userdescription); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = get_string('gradedby', 'assign'); + $cell2content = $this->output->user_picture($status->grader) . + $this->output->spacer(array('width' => 30)) . + fullname($status->grader, $status->canviewfullnames); + $this->add_table_row_tuple($t, $cell1content, $cell2content); } foreach ($status->feedbackplugins as $plugin) { @@ -427,8 +442,6 @@ class mod_assign_renderer extends plugin_renderer_base { !empty($status->grade) && !$plugin->is_empty($status->grade)) { - $row = new html_table_row(); - $cell1 = new html_table_cell($plugin->get_name()); $displaymode = assign_feedback_plugin_feedback::SUMMARY; $pluginfeedback = new assign_feedback_plugin_feedback($plugin, $status->grade, @@ -436,9 +449,9 @@ class mod_assign_renderer extends plugin_renderer_base { $status->coursemoduleid, $status->returnaction, $status->returnparams); - $cell2 = new html_table_cell($this->render($pluginfeedback)); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = $plugin->get_name(); + $cell2content = $this->render($pluginfeedback); + $this->add_table_row_tuple($t, $cell1content, $cell2content); } } @@ -662,32 +675,26 @@ class mod_assign_renderer extends plugin_renderer_base { $warningmsg = ''; if ($status->teamsubmissionenabled) { - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('submissionteam', 'assign')); + $cell1content = get_string('submissionteam', 'assign'); $group = $status->submissiongroup; if ($group) { - $cell2 = new html_table_cell(format_string($group->name, false, $status->context)); + $cell2content = format_string($group->name, false, $status->context); } else if ($status->preventsubmissionnotingroup) { if (count($status->usergroups) == 0) { $notification = new \core\output\notification(get_string('noteam', 'assign'), 'error'); $notification->set_show_closebutton(false); - $cell2 = new html_table_cell( - $this->output->render($notification) - ); $warningmsg = $this->output->notification(get_string('noteam_desc', 'assign'), 'error'); } else if (count($status->usergroups) > 1) { $notification = new \core\output\notification(get_string('multipleteams', 'assign'), 'error'); $notification->set_show_closebutton(false); - $cell2 = new html_table_cell( - $this->output->render($notification) - ); $warningmsg = $this->output->notification(get_string('multipleteams_desc', 'assign'), 'error'); } + $cell2content = $this->output->render($notification); } else { - $cell2 = new html_table_cell(get_string('defaultteam', 'assign')); + $cell2content = get_string('defaultteam', 'assign'); } - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + + $this->add_table_row_tuple($t, $cell1content, $cell2content); } if ($status->attemptreopenmethod != ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) { @@ -702,49 +709,38 @@ class mod_assign_renderer extends plugin_renderer_base { } } - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('attemptnumber', 'assign')); + $cell1content = get_string('attemptnumber', 'assign'); $maxattempts = $status->maxattempts; if ($maxattempts == ASSIGN_UNLIMITED_ATTEMPTS) { - $message = get_string('currentattempt', 'assign', $currentattempt); + $cell2content = get_string('currentattempt', 'assign', $currentattempt); } else { - $message = get_string('currentattemptof', 'assign', array('attemptnumber'=>$currentattempt, - 'maxattempts'=>$maxattempts)); + $cell2content = get_string('currentattemptof', 'assign', + array('attemptnumber' => $currentattempt, 'maxattempts' => $maxattempts)); } - $cell2 = new html_table_cell($message); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + + $this->add_table_row_tuple($t, $cell1content, $cell2content); } - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('submissionstatus', 'assign')); + $cell1content = get_string('submissionstatus', 'assign'); + $cell2attributes = []; if (!$status->teamsubmissionenabled) { if ($status->submission && $status->submission->status != ASSIGN_SUBMISSION_STATUS_NEW) { - $statusstr = get_string('submissionstatus_' . $status->submission->status, 'assign'); - $cell2 = new html_table_cell($statusstr); - $cell2->attributes = array('class'=>'submissionstatus' . $status->submission->status); + $cell2content = get_string('submissionstatus_' . $status->submission->status, 'assign'); + $cell2attributes = array('class' => 'submissionstatus' . $status->submission->status); } else { if (!$status->submissionsenabled) { - $cell2 = new html_table_cell(get_string('noonlinesubmissions', 'assign')); + $cell2content = get_string('noonlinesubmissions', 'assign'); } else { - $cell2 = new html_table_cell(get_string('noattempt', 'assign')); + $cell2content = get_string('noattempt', 'assign'); } } - $row->cells = array($cell1, $cell2); - $t->data[] = $row; } else { - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('submissionstatus', 'assign')); $group = $status->submissiongroup; if (!$group && $status->preventsubmissionnotingroup) { - $cell2 = new html_table_cell(get_string('nosubmission', 'assign')); + $cell2content = get_string('nosubmission', 'assign'); } else if ($status->teamsubmission && $status->teamsubmission->status != ASSIGN_SUBMISSION_STATUS_NEW) { $teamstatus = $status->teamsubmission->status; - $submissionsummary = get_string('submissionstatus_' . $teamstatus, 'assign'); - $groupid = 0; - if ($status->submissiongroup) { - $groupid = $status->submissiongroup->id; - } + $cell2content = get_string('submissionstatus_' . $teamstatus, 'assign'); $members = $status->submissiongroupmemberswhoneedtosubmit; $userslist = array(); @@ -761,156 +757,133 @@ class mod_assign_renderer extends plugin_renderer_base { if (count($userslist) > 0) { $userstr = join(', ', $userslist); $formatteduserstr = get_string('userswhoneedtosubmit', 'assign', $userstr); - $submissionsummary .= $this->output->container($formatteduserstr); + $cell2content .= $this->output->container($formatteduserstr); } - $cell2 = new html_table_cell($submissionsummary); - $cell2->attributes = array('class'=>'submissionstatus' . $status->teamsubmission->status); + $cell2attributes = array('class' => 'submissionstatus' . $status->teamsubmission->status); } else { - $cell2 = new html_table_cell(get_string('nosubmission', 'assign')); if (!$status->submissionsenabled) { - $cell2 = new html_table_cell(get_string('noonlinesubmissions', 'assign')); + $cell2content = get_string('noonlinesubmissions', 'assign'); } else { - $cell2 = new html_table_cell(get_string('nosubmission', 'assign')); + $cell2content = get_string('nosubmission', 'assign'); } } - $row->cells = array($cell1, $cell2); - $t->data[] = $row; } + $this->add_table_row_tuple($t, $cell1content, $cell2content, [], $cell2attributes); + // Is locked? if ($status->locked) { - $row = new html_table_row(); - $cell1 = new html_table_cell(); - $cell2 = new html_table_cell(get_string('submissionslocked', 'assign')); - $cell2->attributes = array('class'=>'submissionlocked'); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = ''; + $cell2content = get_string('submissionslocked', 'assign'); + $cell2attributes = array('class' => 'submissionlocked'); + $this->add_table_row_tuple($t, $cell1content, $cell2content, [], $cell2attributes); } // Grading status. - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('gradingstatus', 'assign')); - + $cell1content = get_string('gradingstatus', 'assign'); if ($status->gradingstatus == ASSIGN_GRADING_STATUS_GRADED || $status->gradingstatus == ASSIGN_GRADING_STATUS_NOT_GRADED) { - $cell2 = new html_table_cell(get_string($status->gradingstatus, 'assign')); + $cell2content = get_string($status->gradingstatus, 'assign'); } else { $gradingstatus = 'markingworkflowstate' . $status->gradingstatus; - $cell2 = new html_table_cell(get_string($gradingstatus, 'assign')); + $cell2content = get_string($gradingstatus, 'assign'); } if ($status->gradingstatus == ASSIGN_GRADING_STATUS_GRADED || $status->gradingstatus == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) { - $cell2->attributes = array('class' => 'submissiongraded'); + $cell2attributes = array('class' => 'submissiongraded'); } else { - $cell2->attributes = array('class' => 'submissionnotgraded'); + $cell2attributes = array('class' => 'submissionnotgraded'); } - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $this->add_table_row_tuple($t, $cell1content, $cell2content, [], $cell2attributes); $submission = $status->teamsubmission ? $status->teamsubmission : $status->submission; $duedate = $status->duedate; if ($duedate > 0) { // Due date. - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('duedate', 'assign')); - $cell2 = new html_table_cell(userdate($duedate)); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = get_string('duedate', 'assign'); + $cell2content = userdate($duedate); + $this->add_table_row_tuple($t, $cell1content, $cell2content); if ($status->view == assign_submission_status::GRADER_VIEW) { if ($status->cutoffdate) { // Cut off date. - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('cutoffdate', 'assign')); - $cell2 = new html_table_cell(userdate($status->cutoffdate)); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = get_string('cutoffdate', 'assign'); + $cell2content = userdate($status->cutoffdate); + $this->add_table_row_tuple($t, $cell1content, $cell2content); } } if ($status->extensionduedate) { // Extension date. - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('extensionduedate', 'assign')); - $cell2 = new html_table_cell(userdate($status->extensionduedate)); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = get_string('extensionduedate', 'assign'); + $cell2content = userdate($status->extensionduedate); + $this->add_table_row_tuple($t, $cell1content, $cell2content); $duedate = $status->extensionduedate; } // Time remaining. - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('timeremaining', 'assign')); + $cell1content = get_string('timeremaining', 'assign'); + $cell2attributes = []; if ($duedate - $time <= 0) { if (!$submission || $submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) { if ($status->submissionsenabled) { - $overduestr = get_string('overdue', 'assign', format_time($time - $duedate)); - $cell2 = new html_table_cell($overduestr); - $cell2->attributes = array('class'=>'overdue'); + $cell2content = get_string('overdue', 'assign', format_time($time - $duedate)); + $cell2attributes = array('class' => 'overdue'); } else { - $cell2 = new html_table_cell(get_string('duedatereached', 'assign')); + $cell2content = get_string('duedatereached', 'assign'); } } else { if ($submission->timemodified > $duedate) { - $latestr = get_string('submittedlate', + $cell2content = get_string('submittedlate', 'assign', format_time($submission->timemodified - $duedate)); - $cell2 = new html_table_cell($latestr); - $cell2->attributes = array('class'=>'latesubmission'); + $cell2attributes = array('class' => 'latesubmission'); } else { - $earlystr = get_string('submittedearly', + $cell2content = get_string('submittedearly', 'assign', format_time($submission->timemodified - $duedate)); - $cell2 = new html_table_cell($earlystr); - $cell2->attributes = array('class'=>'earlysubmission'); + $cell2attributes = array('class' => 'earlysubmission'); } } } else { - $cell2 = new html_table_cell(format_time($duedate - $time)); + $cell2content = format_time($duedate - $time); } - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $this->add_table_row_tuple($t, $cell1content, $cell2content, [], $cell2attributes); } // Show graders whether this submission is editable by students. if ($status->view == assign_submission_status::GRADER_VIEW) { - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('editingstatus', 'assign')); + $cell1content = get_string('editingstatus', 'assign'); if ($status->canedit) { - $cell2 = new html_table_cell(get_string('submissioneditable', 'assign')); - $cell2->attributes = array('class'=>'submissioneditable'); + $cell2content = get_string('submissioneditable', 'assign'); + $cell2attributes = array('class' => 'submissioneditable'); } else { - $cell2 = new html_table_cell(get_string('submissionnoteditable', 'assign')); - $cell2->attributes = array('class'=>'submissionnoteditable'); + $cell2content = get_string('submissionnoteditable', 'assign'); + $cell2attributes = array('class' => 'submissionnoteditable'); } - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $this->add_table_row_tuple($t, $cell1content, $cell2content, [], $cell2attributes); } // Grading criteria preview. if (!empty($status->gradingcontrollerpreview)) { - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('gradingmethodpreview', 'assign')); - $cell2 = new html_table_cell($status->gradingcontrollerpreview); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell1content = get_string('gradingmethodpreview', 'assign'); + $cell2content = $status->gradingcontrollerpreview; + $this->add_table_row_tuple($t, $cell1content, $cell2content, [], $cell2attributes); } // Last modified. if ($submission) { - $row = new html_table_row(); - $cell1 = new html_table_cell(get_string('timemodified', 'assign')); + $cell1content = get_string('timemodified', 'assign'); if ($submission->status != ASSIGN_SUBMISSION_STATUS_NEW) { - $cell2 = new html_table_cell(userdate($submission->timemodified)); + $cell2content = userdate($submission->timemodified); } else { - $cell2 = new html_table_cell('-'); + $cell2content = "-"; } - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $this->add_table_row_tuple($t, $cell1content, $cell2content); if (!$status->teamsubmission || $status->submissiongroup != false || !$status->preventsubmissionnotingroup) { foreach ($status->submissionplugins as $plugin) { @@ -921,8 +894,7 @@ class mod_assign_renderer extends plugin_renderer_base { $pluginshowsummary ) { - $row = new html_table_row(); - $cell1 = new html_table_cell($plugin->get_name()); + $cell1content = $plugin->get_name(); $displaymode = assign_submission_plugin_submission::SUMMARY; $pluginsubmission = new assign_submission_plugin_submission($plugin, $submission, @@ -930,9 +902,8 @@ class mod_assign_renderer extends plugin_renderer_base { $status->coursemoduleid, $status->returnaction, $status->returnparams); - $cell2 = new html_table_cell($this->render($pluginsubmission)); - $row->cells = array($cell1, $cell2); - $t->data[] = $row; + $cell2content = $this->render($pluginsubmission); + $this->add_table_row_tuple($t, $cell1content, $cell2content); } } } @@ -1028,11 +999,6 @@ class mod_assign_renderer extends plugin_renderer_base { public function render_assign_attempt_history(assign_attempt_history $history) { $o = ''; - $submittedstr = get_string('submitted', 'assign'); - $gradestr = get_string('grade'); - $gradedonstr = get_string('gradedon', 'assign'); - $gradedbystr = get_string('gradedby', 'assign'); - // Don't show the last one because it is the current submission. array_pop($history->submissions); @@ -1058,8 +1024,6 @@ class mod_assign_renderer extends plugin_renderer_base { } } - $editbtn = ''; - if ($submission) { $submissionsummary = userdate($submission->timemodified); } else { @@ -1073,9 +1037,9 @@ class mod_assign_renderer extends plugin_renderer_base { $t = new html_table(); if ($submission) { - $cell1 = new html_table_cell(get_string('submissionstatus', 'assign')); - $cell2 = new html_table_cell(get_string('submissionstatus_' . $submission->status, 'assign')); - $t->data[] = new html_table_row(array($cell1, $cell2)); + $cell1content = get_string('submissionstatus', 'assign'); + $cell2content = get_string('submissionstatus_' . $submission->status, 'assign'); + $this->add_table_row_tuple($t, $cell1content, $cell2content); foreach ($history->submissionplugins as $plugin) { $pluginshowsummary = !$plugin->is_empty($submission) || !$plugin->allow_submissions(); @@ -1084,16 +1048,15 @@ class mod_assign_renderer extends plugin_renderer_base { $plugin->has_user_summary() && $pluginshowsummary) { - $cell1 = new html_table_cell($plugin->get_name()); + $cell1content = $plugin->get_name(); $pluginsubmission = new assign_submission_plugin_submission($plugin, $submission, assign_submission_plugin_submission::SUMMARY, $history->coursemoduleid, $history->returnaction, $history->returnparams); - $cell2 = new html_table_cell($this->render($pluginsubmission)); - - $t->data[] = new html_table_row(array($cell1, $cell2)); + $cell2content = $this->render($pluginsubmission); + $this->add_table_row_tuple($t, $cell1content, $cell2content); } } } @@ -1124,21 +1087,21 @@ class mod_assign_renderer extends plugin_renderer_base { $t->data[] = new html_table_row(array($cell)); // Grade. - $cell1 = new html_table_cell($gradestr); - $cell2 = $grade->gradefordisplay; - $t->data[] = new html_table_row(array($cell1, $cell2)); + $cell1content = get_string('grade'); + $cell2content = $grade->gradefordisplay; + $this->add_table_row_tuple($t, $cell1content, $cell2content); // Graded on. - $cell1 = new html_table_cell($gradedonstr); - $cell2 = new html_table_cell(userdate($grade->timemodified)); - $t->data[] = new html_table_row(array($cell1, $cell2)); + $cell1content = get_string('gradedon', 'assign'); + $cell2content = userdate($grade->timemodified); + $this->add_table_row_tuple($t, $cell1content, $cell2content); // Graded by set to a real user. Not set can be empty or -1. if (!empty($grade->grader) && is_object($grade->grader)) { - $cell1 = new html_table_cell($gradedbystr); - $cell2 = new html_table_cell($this->output->user_picture($grade->grader) . - $this->output->spacer(array('width' => 30)) . fullname($grade->grader)); - $t->data[] = new html_table_row(array($cell1, $cell2)); + $cell1content = get_string('gradedby', 'assign'); + $cell2content = $this->output->user_picture($grade->grader) . + $this->output->spacer(array('width' => 30)) . fullname($grade->grader); + $this->add_table_row_tuple($t, $cell1content, $cell2content); } // Feedback from plugins. @@ -1148,13 +1111,14 @@ class mod_assign_renderer extends plugin_renderer_base { $plugin->has_user_summary() && !$plugin->is_empty($grade)) { - $cell1 = new html_table_cell($plugin->get_name()); $pluginfeedback = new assign_feedback_plugin_feedback( $plugin, $grade, assign_feedback_plugin_feedback::SUMMARY, $history->coursemoduleid, $history->returnaction, $history->returnparams ); - $cell2 = new html_table_cell($this->render($pluginfeedback)); - $t->data[] = new html_table_row(array($cell1, $cell2)); + + $cell1content = $plugin->get_name(); + $cell2content = $this->render($pluginfeedback); + $this->add_table_row_tuple($t, $cell1content, $cell2content); } } @@ -1164,7 +1128,6 @@ class mod_assign_renderer extends plugin_renderer_base { $o .= html_writer::table($t); } $o .= $this->box_end(); - $jsparams = array($containerid); $this->page->requires->yui_module('moodle-mod_assign-history', 'Y.one("#' . $containerid . '").history');