diff --git a/mod/assign/module.js b/mod/assign/module.js index f0ee769b8b2..70a1d609c6a 100644 --- a/mod/assign/module.js +++ b/mod/assign/module.js @@ -163,59 +163,65 @@ M.mod_assign.init_grading_options = function(Y) { }; M.mod_assign.init_plugin_summary = function(Y, subtype, type, submissionid) { - suffix = subtype + '_' + type + '_' + submissionid; - classname = 'contract_' + suffix; - contract = Y.one('.' + classname); + var suffix = subtype + '_' + type + '_' + submissionid; + var classname = 'contract_' + suffix; + var contract = Y.one('.' + classname); if (contract) { contract.on('click', function(e) { - img = e.target; - imgclasses = img.getAttribute('class').split(' '); - for (i = 0; i < imgclasses.length; i++) { - classname = imgclasses[i]; + e.preventDefault(); + var link = e.target; + var linkclasses = link.getAttribute('class').split(' '); + var thissuffix = ''; + for (var i = 0; i < linkclasses.length; i++) { + classname = linkclasses[i]; if (classname.indexOf('contract_') == 0) { thissuffix = classname.substr(9); } } - fullclassname = 'full_' + thissuffix; - full = Y.one('.' + fullclassname); + var fullclassname = 'full_' + thissuffix; + var full = Y.one('.' + fullclassname); if (full) { full.hide(false); } - summaryclassname = 'summary_' + thissuffix; - summary = Y.one('.' + summaryclassname); + var summaryclassname = 'summary_' + thissuffix; + var summary = Y.one('.' + summaryclassname); if (summary) { summary.show(false); + summary.one('a.expand_' + thissuffix).focus(); } }); } classname = 'expand_' + suffix; - expand = Y.one('.' + classname); + var expand = Y.one('.' + classname); - full = Y.one('.full_' + suffix); + var full = Y.one('.full_' + suffix); if (full) { full.hide(false); full.toggleClass('hidefull'); } if (expand) { expand.on('click', function(e) { - img = e.target; - imgclasses = img.getAttribute('class').split(' '); - for (i = 0; i < imgclasses.length; i++) { - classname = imgclasses[i]; + e.preventDefault(); + var link = e.target; + var linkclasses = link.getAttribute('class').split(' '); + var thissuffix = ''; + for (var i = 0; i < linkclasses.length; i++) { + classname = linkclasses[i]; if (classname.indexOf('expand_') == 0) { thissuffix = classname.substr(7); } } - summaryclassname = 'summary_' + thissuffix; - summary = Y.one('.' + summaryclassname); + var summaryclassname = 'summary_' + thissuffix; + var summary = Y.one('.' + summaryclassname); if (summary) { summary.hide(false); } - fullclassname = 'full_' + thissuffix; + var fullclassname = 'full_' + thissuffix; full = Y.one('.' + fullclassname); if (full) { full.show(false); + full.one('a.contract_' + thissuffix).focus(); } }); } -} +}; diff --git a/mod/assign/renderer.php b/mod/assign/renderer.php index 4d9bbe4319f..120d5ef213d 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; } @@ -268,35 +278,40 @@ 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) { if ($summary->warnofungroupedusers) { $o .= $this->output->notification(get_string('ungroupedusers', '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); } } @@ -304,27 +319,31 @@ class mod_assign_renderer extends plugin_renderer_base { if ($summary->duedate) { // Due date. $duedate = $summary->duedate; - $this->add_table_row_tuple($t, get_string('duedate', 'assign'), - userdate($duedate)); + $cell1content = get_string('duedate', 'assign'); + $cell2content = userdate($duedate); + $this->add_table_row_tuple($t, $cell1content, $cell2content); // Time remaining. - $due = ''; + $cell1content = get_string('timeremaining', 'assign'); 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) { $cutoffdate = $summary->cutoffdate; if ($cutoffdate) { + $cell1content = get_string('latesubmissions', 'assign'); if ($cutoffdate > $time) { - $late = get_string('latesubmissionsaccepted', 'assign', userdate($summary->cutoffdate)); + $cell2content = get_string('latesubmissionsaccepted', 'assign', + userdate($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); } } @@ -335,21 +354,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; } @@ -361,7 +382,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'); @@ -371,30 +391,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) { @@ -404,8 +417,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, @@ -413,9 +424,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); } } @@ -639,32 +650,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) { @@ -679,49 +684,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(); @@ -738,156 +732,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) { @@ -898,8 +869,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, @@ -907,9 +877,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); } } } @@ -1002,11 +971,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); @@ -1032,8 +996,6 @@ class mod_assign_renderer extends plugin_renderer_base { } } - $editbtn = ''; - if ($submission) { $submissionsummary = userdate($submission->timemodified); } else { @@ -1047,9 +1009,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(); @@ -1058,16 +1020,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); } } } @@ -1098,21 +1059,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. @@ -1122,13 +1083,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); } } @@ -1138,7 +1100,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'); @@ -1173,8 +1134,14 @@ class mod_assign_renderer extends plugin_renderer_base { $icon = $this->output->pix_icon('t/preview', $previewstr); $expandstr = get_string('viewfull', 'assign'); - $options = array('class'=>'expandsummaryicon expand_' . $classsuffix); - $o .= $this->output->pix_icon('t/switch_plus', $expandstr, null, $options); + $expandicon = $this->output->pix_icon('t/switch_plus', $expandstr); + $options = array( + 'class' => 'expandsummaryicon expand_' . $classsuffix, + 'aria-label' => $expandstr, + 'role' => 'button', + 'aria-expanded' => 'false' + ); + $o .= html_writer::link('', $expandicon, $options); $jsparams = array($submissionplugin->plugin->get_subtype(), $submissionplugin->plugin->get_type(), @@ -1202,11 +1169,16 @@ class mod_assign_renderer extends plugin_renderer_base { $o .= $this->output->box_end(); if ($showviewlink) { $o .= $this->output->box_start('boxaligncenter hidefull full_' . $classsuffix); - $classes = 'expandsummaryicon contract_' . $classsuffix; - $o .= $this->output->pix_icon('t/switch_minus', - get_string('viewsummary', 'assign'), - null, - array('class'=>$classes)); + $collapsestr = get_string('viewsummary', 'assign'); + $options = array( + 'class' => 'expandsummaryicon contract_' . $classsuffix, + 'aria-label' => $collapsestr, + 'role' => 'button', + 'aria-expanded' => 'true' + ); + $collapseicon = $this->output->pix_icon('t/switch_minus', $collapsestr); + $o .= html_writer::link('', $collapseicon, $options); + $o .= $submissionplugin->plugin->view($submissionplugin->submission); $o .= $this->output->box_end(); } @@ -1278,8 +1250,14 @@ class mod_assign_renderer extends plugin_renderer_base { $icon = $this->output->pix_icon('t/preview', $previewstr); $expandstr = get_string('viewfull', 'assign'); - $options = array('class'=>'expandsummaryicon expand_' . $classsuffix); - $o .= $this->output->pix_icon('t/switch_plus', $expandstr, null, $options); + $expandicon = $this->output->pix_icon('t/switch_plus', $expandstr); + $options = array( + 'class' => 'expandsummaryicon expand_' . $classsuffix, + 'aria-label' => $expandstr, + 'role' => 'button', + 'aria-expanded' => 'false' + ); + $o .= html_writer::link('', $expandicon, $options); $jsparams = array($feedbackplugin->plugin->get_subtype(), $feedbackplugin->plugin->get_type(), @@ -1304,11 +1282,16 @@ class mod_assign_renderer extends plugin_renderer_base { $o .= $this->output->box_end(); if ($showviewlink) { $o .= $this->output->box_start('boxaligncenter hidefull full_' . $classsuffix); - $classes = 'expandsummaryicon contract_' . $classsuffix; - $o .= $this->output->pix_icon('t/switch_minus', - get_string('viewsummary', 'assign'), - null, - array('class'=>$classes)); + $collapsestr = get_string('viewsummary', 'assign'); + $options = array( + 'class' => 'expandsummaryicon contract_' . $classsuffix, + 'aria-label' => $collapsestr, + 'role' => 'button', + 'aria-expanded' => 'true' + ); + $collapseicon = $this->output->pix_icon('t/switch_minus', $collapsestr); + $o .= html_writer::link('', $collapseicon, $options); + $o .= $feedbackplugin->plugin->view($feedbackplugin->grade); $o .= $this->output->box_end(); } diff --git a/mod/assign/styles.css b/mod/assign/styles.css index 9f5ba96a57b..79bb00e91f4 100644 --- a/mod/assign/styles.css +++ b/mod/assign/styles.css @@ -187,10 +187,13 @@ } .path-mod-assign .expandsummaryicon { - cursor: pointer; display: none; } +.path-mod-assign .expandsummaryicon i { + pointer-events: none; +} + .path-mod-assign.jsenabled .expandsummaryicon { display: inline; }