Skip to content

Commit

Permalink
MDL-46662 grader: Improve course header and aggregation accessibility
Browse files Browse the repository at this point in the history
Deprecated unused grader collapse icon function.
  • Loading branch information
Zachary Durber authored and zbdd committed Feb 4, 2015
1 parent 4c27f52 commit 2350b3f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 7 deletions.
57 changes: 53 additions & 4 deletions grade/report/grader/lib.php
Expand Up @@ -793,8 +793,7 @@ public function get_right_rows($displayaverages) {
$categorycell = new html_table_cell();
$categorycell->attributes['class'] = 'category ' . $catlevel;
$categorycell->colspan = $colspan;
$categorycell->text = shorten_text($element['object']->get_name());
$categorycell->text .= $this->get_collapsing_icon($element);
$categorycell->text = $this->get_course_header($element);
$categorycell->header = true;
$categorycell->scope = 'col';

Expand Down Expand Up @@ -832,8 +831,10 @@ public function get_right_rows($displayaverages) {
'id' => $this->course->id,
'item' => 'grade',
'itemid' => $element['object']->id));
$singleview = $OUTPUT->action_icon($url, new pix_icon('t/editstring', get_string('singleview', 'grades',
$element['object']->get_name())));
$singleview = $OUTPUT->action_icon(
$url,
new pix_icon('t/editstring', get_string('singleview', 'grades', $element['object']->itemname))
);
}

$itemcell->colspan = $colspan;
Expand Down Expand Up @@ -1495,6 +1496,49 @@ public function get_right_avg_row($rows=array(), $grouponly=false) {
return $rows;
}

/**
* Given element category, create a collapsible icon and
* course header.
*
* @param object $element
* @return string HTML
*/
protected function get_course_header($element) {
global $OUTPUT;

$icon = '';
// If object is a category, display expand/contract icon.
if ($element['type'] == 'category') {
// Load language strings.
$strswitchminus = $this->get_lang_string('aggregatesonly', 'grades');
$strswitchplus = $this->get_lang_string('gradesonly', 'grades');
$strswitchwhole = $this->get_lang_string('fullmode', 'grades');

$url = new moodle_url($this->gpr->get_return_url(null, array('target' => $element['eid'], 'sesskey' => sesskey())));

if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) {
$url->param('action', 'switch_plus');
$icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_plus', $strswitchplus), null, null);
$showing = get_string('showingaggregatesonly', 'grades');
} else if (in_array($element['object']->id, $this->collapsed['gradesonly'])) {
$url->param('action', 'switch_whole');
$icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_whole', $strswitchwhole), null, null);
$showing = get_string('showinggradesonly', 'grades');
} else {
$url->param('action', 'switch_minus');
$icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_minus', $strswitchminus), null, null);
$showing = get_string('showingfullmode', 'grades');
}
}

$name = shorten_text($element['object']->get_name());
$courseheader = html_writer::tag('span', $name, array('id' => 'courseheader'));
$courseheader .= html_writer::label($showing, 'courseheader', false, array('class' => 'accesshide'));
$courseheader .= $icon;

return $courseheader;
}

/**
* Given a grade_category, grade_item or grade_grade, this function
* figures out the state of the object and builds then returns a div
Expand Down Expand Up @@ -1555,11 +1599,16 @@ protected function get_icons($element) {

/**
* Given a category element returns collapsing +/- icon if available
*
* @deprecated since Moodle 2.9 MDL-46662 - please do not use this function any more.
* @todo MDL-49021 This will be deleted in Moodle 3.1
* @see grade_report_grader::get_course_header()
* @param object $element
* @return string HTML
*/
protected function get_collapsing_icon($element) {
global $OUTPUT;
debugging('get_collapsing_icon is deprecated, please use get_course_header instead.', DEBUG_DEVELOPER);

$icon = '';
// If object is a category, display expand/contract icon
Expand Down
2 changes: 2 additions & 0 deletions grade/report/upgrade.txt
@@ -1,5 +1,7 @@
This files describes API changes in /grade/report/*,
information provided here is intended especially for developers.
=== 2.9 ===
* Deprecating grade_report_grader:get_collapsing_icon.

=== 2.8.2 ===
* gradereport_singleview::__construct doesn't need groupid parameter anymore, so it was renamed to $unused.
Expand Down
9 changes: 6 additions & 3 deletions lang/en/grades.php
Expand Up @@ -47,7 +47,7 @@
This setting determines whether empty grades are not included in the aggregation or are counted as minimal grades, for example 0 for an assignment graded between 0 and 100.';
$string['aggregateoutcomes'] = 'Include outcomes in aggregation';
$string['aggregateoutcomes_help'] = 'If enabled, outcomes are included in the aggregation. This may result in an unexpected category total.';
$string['aggregatesonly'] = 'Aggregates only';
$string['aggregatesonly'] = 'Change to aggregates only';
$string['aggregatesum'] = 'Natural';
$string['aggregateweightedmean'] = 'Weighted mean of grades';
$string['aggregateweightedmean2'] = 'Simple weighted mean of grades';
Expand Down Expand Up @@ -227,7 +227,7 @@
$string['forelementtypes'] = 'for the selected {$a}';
$string['forstudents'] = 'For students';
$string['full'] = 'Full';
$string['fullmode'] = 'Full view';
$string['fullmode'] = 'Change to full view';
$string['generalsettings'] = 'General settings';
$string['grade'] = 'Grade';
$string['gradeadministration'] = 'Grade administration';
Expand Down Expand Up @@ -311,7 +311,7 @@
$string['grades'] = 'Grades';
$string['gradesforuser'] = 'Grades for {$a->user}';
$string['singleview'] = 'Single view for {$a}';
$string['gradesonly'] = 'Grades only';
$string['gradesonly'] = 'Change to grades only';
$string['gradessettings'] = 'Grade settings';
$string['gradetype'] = 'Grade type';
$string['gradetype_help'] = 'There are 4 grade types:
Expand Down Expand Up @@ -614,6 +614,9 @@
$string['showfeedback_help'] = 'Show the feedback column?';
$string['showgrade'] = 'Show grades';
$string['showgrade_help'] = 'Show the grade column?';
$string['showingaggregatesonly'] = 'Showing aggregates only';
$string['showingfullmode'] = 'Showing full view';
$string['showinggradesonly'] = 'Showing grades only';
$string['showlettergrade'] = 'Show letter grades';
$string['showlettergrade_help'] = 'Show the letter grade column?';
$string['showrange'] = 'Show ranges';
Expand Down

0 comments on commit 2350b3f

Please sign in to comment.