Skip to content

Commit

Permalink
MDL-34777 Accessibility: Add labels to input elements in gradebook
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Taneja committed Sep 20, 2012
1 parent b1fec41 commit 7400be1
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 38 deletions.
52 changes: 37 additions & 15 deletions grade/edit/tree/lib.php
Expand Up @@ -373,13 +373,16 @@ static function get_weight_input($item, $type) {

if ((($aggcoef == 'aggregationcoefweight' || $aggcoef == 'aggregationcoef') && $type == 'weight') ||
($aggcoef == 'aggregationcoefextraweight' && $type == 'extra')) {
return '<label class="accesshide" for="aggregationcoef_'.$item->id.'">'.get_string('extracreditvalue', 'grades', $item->itemname).'</label>'.
return '<label class="accesshide" for="aggregationcoef_'.$item->id.'">'.
get_string('extracreditvalue', 'grades', $item->itemname).'</label>'.
'<input type="text" size="6" id="aggregationcoef_'.$item->id.'" name="aggregationcoef_'.$item->id.'"
value="'.grade_edit_tree::format_number($item->aggregationcoef).'" />';
} elseif ($aggcoef == 'aggregationcoefextrasum' && $type == 'extra') {
$checked = ($item->aggregationcoef > 0) ? 'checked="checked"' : '';
return '<input type="hidden" name="extracredit_'.$item->id.'" value="0" />
<input type="checkbox" id="extracredit_'.$item->id.'" name="extracredit_'.$item->id.'" value="1" '."$checked />\n";
<label class="accesshide" for="extracredit_'.$item->id.'">'.
get_string('extracreditvalue', 'grades', $item->itemname).'</label>
<input type="checkbox" id="extracredit_'.$item->id.'" name="extracredit_'.$item->id.'" value="1" '."$checked />\n";
} else {
return '';
}
Expand Down Expand Up @@ -812,8 +815,9 @@ public function get_item_cell($item, $params) {
} elseif ($item->is_external_item()) {
$grademax = format_float($item->grademax, $item->get_decimals());
} else {
$grademax = '<label class="accesshide" for="grademax'.$item->id.'">'.get_string('grademax', 'grades').'</label>';
$grademax .= '<input type="text" size="6" id="grademax'.$item->id.'" name="grademax_'.$item->id.'" value="'.format_float($item->grademax, $item->get_decimals()).'" />';
$grademax = '<label class="accesshide" for="grademax'.$item->id.'">'.get_string('grademax', 'grades').'</label>
<input type="text" size="6" id="grademax'.$item->id.'" name="grademax_'.$item->id.'" value="'.
format_float($item->grademax, $item->get_decimals()).'" />';
}

$itemcell = clone($this->itemcell);
Expand Down Expand Up @@ -849,7 +853,10 @@ public function get_header_cell() {
public function get_category_cell($category, $levelclass, $params) {
$onlygradedcheck = ($category->aggregateonlygraded == 1) ? 'checked="checked"' : '';
$hidden = '<input type="hidden" name="aggregateonlygraded_'.$category->id.'" value="0" />';
$aggregateonlygraded ='<input type="checkbox" id="aggregateonlygraded_'.$category->id.'" name="aggregateonlygraded_'.$category->id.'" value="1" '.$onlygradedcheck . ' />';
$aggregateonlygraded = '<label class="accesshide" for="aggregateonlygraded_'.$category->id.'">'.
get_string('aggregateonlygraded', 'grades').'</label>
<input type="checkbox" id="aggregateonlygraded_'.$category->id.'" name="aggregateonlygraded_'.
$category->id.'" value="1" '.$onlygradedcheck . ' />';

if ($this->forced) {
$aggregateonlygraded = ($category->aggregateonlygraded) ? get_string('yes') : get_string('no');
Expand Down Expand Up @@ -886,7 +893,10 @@ public function get_header_cell() {
public function get_category_cell($category, $levelclass, $params) {
$subcatscheck = ($category->aggregatesubcats == 1) ? 'checked="checked"' : '';
$hidden = '<input type="hidden" name="aggregatesubcats_'.$category->id.'" value="0" />';
$aggregatesubcats = '<input type="checkbox" id="aggregatesubcats_'.$category->id.'" name="aggregatesubcats_'.$category->id.'" value="1" ' . $subcatscheck.' />';
$aggregatesubcats = '<label class="accesshide" for="aggregatesubcats_'.$category->id.'">'.
get_string('aggregatesubcats', 'grades').'</label>
<input type="checkbox" id="aggregatesubcats_'.$category->id.'" name="aggregatesubcats_'.$category->id.
'" value="1" ' . $subcatscheck.' />';

if ($this->forced) {
$aggregatesubcats = ($category->aggregatesubcats) ? get_string('yes') : get_string('no');
Expand Down Expand Up @@ -924,7 +934,10 @@ public function get_header_cell() {
public function get_category_cell($category, $levelclass, $params) {
$outcomescheck = ($category->aggregateoutcomes == 1) ? 'checked="checked"' : '';
$hidden = '<input type="hidden" name="aggregateoutcomes_'.$category->id.'" value="0" />';
$aggregateoutcomes = '<input type="checkbox" id="aggregateoutcomes_'.$category->id.'" name="aggregateoutcomes_'.$category->id.'" value="1" ' . $outcomescheck.' />';
$aggregateoutcomes = '<label class="accesshide" for="aggregateoutcomes_'.$category->id.'">'.
get_string('aggregateoutcomes', 'grades').'</label>
<input type="checkbox" id="aggregateoutcomes_'.$category->id.'" name="aggregateoutcomes_'.$category->id.
'" value="1" ' . $outcomescheck.' />';

if ($this->forced) {
$aggregateoutcomes = ($category->aggregateoutcomes) ? get_string('yes') : get_string('no');
Expand Down Expand Up @@ -966,8 +979,9 @@ public function get_header_cell() {
}

public function get_category_cell($category, $levelclass, $params) {
$droplow = '<label class="accesshide" for="droplow_'.$category->id.'">'.get_string('droplowestvalue', 'grades').'</label>';
$droplow .= '<input type="text" size="3" id="droplow_'.$category->id.'" name="droplow_'.$category->id.'" value="'.$category->droplow.'" />';
$droplow = '<label class="accesshide" for="droplow_' . $category->id.'">' . get_string('droplowestvalue', 'grades') . '</label>';
$droplow .= '<input type="text" size="3" id="droplow_' . $category->id . '" name="droplow_' . $category->id . '" value="'
. $category->droplow.'" />';

if ($this->forced) {
$droplow = $category->droplow;
Expand Down Expand Up @@ -1001,7 +1015,8 @@ public function get_header_cell() {

public function get_category_cell($category, $levelclass, $params) {
$keephigh = '<label class="accesshide" for="keephigh_'.$category->id.'">'.get_string('keephigh', 'grades').'</label>';
$keephigh .= '<input type="text" size="3" id="keephigh_'.$category->id.'" name="keephigh_'.$category->id.'" value="'.$category->keephigh.'" />';
$keephigh .= '<input type="text" size="3" id="keephigh_'.$category->id.'" name="keephigh_'.$category->id.'" value="'.
$category->keephigh.'" />';

if ($this->forced) {
$keephigh = $category->keephigh;
Expand Down Expand Up @@ -1048,8 +1063,10 @@ public function get_item_cell($item, $params) {
$itemcell->text = '&nbsp;';
return $itemcell;
}
$multfactor = '<label class="accesshide" for="multfactor'.$item->id.'">'.get_string('multfactorvalue', 'grades', $item->itemname).'</label>';
$multfactor .= '<input type="text" size="4" id="multfactor'.$item->id.'" name="multfactor_'.$item->id.'" value="'.grade_edit_tree::format_number($item->multfactor).'" />';
$multfactor = '<label class="accesshide" for="multfactor'.$item->id.'">'.
get_string('multfactorvalue', 'grades', $item->itemname).'</label>
<input type="text" size="4" id="multfactor'.$item->id.'" name="multfactor_'.$item->id.'" value="'.
grade_edit_tree::format_number($item->multfactor).'" />';

$itemcell->text = $multfactor;
return $itemcell;
Expand Down Expand Up @@ -1091,8 +1108,10 @@ public function get_item_cell($item, $params) {
return $itemcell;
}

$plusfactor = '<label class="accesshide" for="plusfactor_'. $item->id . '">'.get_string('plusfactorvalue', 'grades', $item->itemname).'</label>';
$plusfactor .= '<input type="text" size="4" id="plusfactor_'.$item->id.'" name="plusfactor_'.$item->id.'" value="'.grade_edit_tree::format_number($item->plusfactor).'" />';
$plusfactor = '<label class="accesshide" for="plusfactor_'. $item->id . '">'.
get_string('plusfactorvalue', 'grades', $item->itemname).'</label>
<input type="text" size="4" id="plusfactor_'.$item->id.'" name="plusfactor_'.$item->id.'" value="'.
grade_edit_tree::format_number($item->plusfactor).'" />';

$itemcell->text = $plusfactor;
return $itemcell;
Expand Down Expand Up @@ -1180,7 +1199,10 @@ public function get_item_cell($item, $params) {
$itemselect = '';

if ($params['itemtype'] != 'course' && $params['itemtype'] != 'category') {
$itemselect = '<input class="itemselect" type="checkbox" name="select_'.$params['eid'].'" onchange="toggleCategorySelector();"/>'; // TODO: convert to YUI handler
$itemselect = '<label class="accesshide" for="select_'.$params['eid'].'">'.
get_string('select', 'grades', $item->itemname).'</label>
<input class="itemselect" type="checkbox" name="select_'.$params['eid'].
'" onchange="toggleCategorySelector();"/>'; // TODO: convert to YUI handler
}
//html_writer::table() will wrap the item cell contents in a <TD> so don't do it here
return $itemselect;
Expand Down
6 changes: 4 additions & 2 deletions grade/report/grader/lib.php
Expand Up @@ -1036,7 +1036,8 @@ public function get_right_rows() {
if ($this->get_pref('quickgrading') and $grade->is_editable()) {
$value = format_float($gradeval, $decimalpoints);
$gradelabel = fullname($user) . ' ' . $item->itemname;
$itemcell->text .= '<label class="accesshide" for="grade_'.$userid.'_'.$item->id.'">'.get_string('useractivitygrade', 'gradereport_grader', $gradelabel).'</label>';
$itemcell->text .= '<label class="accesshide" for="grade_'.$userid.'_'.$item->id.'">'
.get_string('useractivitygrade', 'gradereport_grader', $gradelabel).'</label>';
$itemcell->text .= '<input size="6" tabindex="' . $tabindices[$item->id]['grade']
. '" type="text" class="text" title="'. $strgrade .'" name="grade_'
.$userid.'_' .$item->id.'" id="grade_'.$userid.'_'.$item->id.'" value="'.$value.'" />';
Expand All @@ -1049,7 +1050,8 @@ public function get_right_rows() {
// If quickfeedback is on, print an input element
if ($this->get_pref('showquickfeedback') and $grade->is_editable()) {
$feedbacklabel = fullname($user) . ' ' . $item->itemname;
$itemcell->text .= '<label class="accesshide" for="feedback_'.$userid.'_'.$item->id.'">'.get_string('useractivityfeedback', 'gradereport_grader', $feedbacklabel).'</label>';
$itemcell->text .= '<label class="accesshide" for="feedback_'.$userid.'_'.$item->id.'">'
.get_string('useractivityfeedback', 'gradereport_grader', $feedbacklabel).'</label>';
$itemcell->text .= '<input class="quickfeedback" tabindex="' . $tabindices[$item->id]['feedback'].'" id="feedback_'.$userid.'_'.$item->id
. '" size="6" title="' . $strfeedback . '" type="text" name="feedback_'.$userid.'_'.$item->id.'" value="' . s($grade->feedback) . '" />';
}
Expand Down
15 changes: 3 additions & 12 deletions grade/report/grader/module.js
Expand Up @@ -124,7 +124,6 @@ M.gradereport_grader.classes.report = function(Y, id, cfg, items, users, feedbac
this.items = items;
this.users = users;
this.feedback = feedback;
this.feedbacklabel = '';
this.table = Y.one('#user-grades');
this.grades = grades;

Expand Down Expand Up @@ -354,8 +353,8 @@ M.gradereport_grader.classes.ajax.prototype.make_editable = function(e) {
node = node.ancestor('td');
}
this.report.Y.detach('click', this.make_editable, node);
//alert(this.report.toSource());
if (this.current) {

if (this.current) {
// Current is already set!
this.process_editable_field(node);
return;
Expand Down Expand Up @@ -663,7 +662,7 @@ M.gradereport_grader.classes.ajax.prototype.submission_outcome = function(tid, o
// otherwise we will prompt the user to choose to use their value or the new value!
if (!this.current.has_changed() || confirm(M.str.gradereport_grader.ajaxfieldchanged)) {
this.current.set_grade(finalgrade);
this.current.grade.set('value', finalgrade);alert(this.current.node.toSource());
this.current.grade.set('value', finalgrade);
}
}
}
Expand Down Expand Up @@ -944,16 +943,11 @@ M.gradereport_grader.classes.textfield = function(report, node) {
this.gradespan = node.one('.gradevalue');
this.inputdiv = this.report.Y.Node.create('<div></div>');
this.editfeedback = this.report.ajax.showquickfeedback;
this.gradelabel = this.report.Y.Node.create('<label class="accesshide" for=""></label>');
this.grade = this.report.Y.Node.create('<input type="text" class="text" value="" />');
this.gradetype = 'value';
this.inputdiv.append(this.gradelabel);
this.inputdiv.append(this.grade);
if (this.report.ajax.showquickfeedback) {
this.feedbacklabel = this.report.Y.Node.create('<label class="accesshide" for=""></label>');
this.feedback = this.report.Y.Node.create('<input type="text" class="quickfeedback" value="" />');

this.inputdiv.append(this.feedbacklabel);
this.inputdiv.append(this.feedback);
}
};
Expand All @@ -964,7 +958,6 @@ M.gradereport_grader.classes.textfield.prototype.keyevents = [];
M.gradereport_grader.classes.textfield.prototype.editable = false;
M.gradereport_grader.classes.textfield.prototype.gradetype = null;
M.gradereport_grader.classes.textfield.prototype.grade = null;
M.gradereport_grader.classes.textfield.prototype.gradelabel = null;
M.gradereport_grader.classes.textfield.prototype.report = null;
M.gradereport_grader.classes.textfield.prototype.node = null;
M.gradereport_grader.classes.textfield.prototype.gradespam = null;
Expand All @@ -982,9 +975,7 @@ M.gradereport_grader.classes.textfield.prototype.replace = function() {
if (this.editfeedback) {
this.set_feedback(this.get_feedback());
}
//this.node.on('.test').innerHTML('test');
this.node.replaceChild(this.inputdiv, this.gradespan);
//alert(this.inputdiv.toSource());
this.grade.focus();
this.editable = true;
return this;
Expand Down
3 changes: 2 additions & 1 deletion lang/en/grades.php
Expand Up @@ -150,7 +150,7 @@
$string['dropdown'] = 'Dropdown menu';
$string['droplow'] = 'Drop the lowest';
$string['droplow_help'] = 'This setting enables a specified number of the lowest grades to be excluded from the aggregation.';
$string['droplowestvalue'] = 'Set the drop lowest grade value';
$string['droplowestvalue'] = 'Set drop lowest grade value';
$string['dropped'] = 'Dropped';
$string['dropxlowest'] = 'Drop X lowest';
$string['dropxlowestwarning'] = 'Note: If you use drop x lowest the grading assumes that all items in the category have the same point value. If point values differ results will be unpredictable';
Expand Down Expand Up @@ -534,6 +534,7 @@
$string['scaleconfirmdelete'] = 'Are you sure you wish to delete the scale "{$a}"?';
$string['scaledpct'] = 'Scaled %';
$string['seeallcoursegrades'] = 'See all course grades';
$string['select'] = 'Select {$a}';
$string['selectalloroneuser'] = 'Select all or one user';
$string['selectauser'] = 'Select a user';
$string['selectdestination'] = 'Select destination of {$a}';
Expand Down
6 changes: 4 additions & 2 deletions mod/assign/feedback/comments/locallib.php
Expand Up @@ -69,8 +69,10 @@ public function get_quickgrading_html($userid, $grade) {
}
}

return html_writer::tag('textarea', $commenttext, array('name'=>'quickgrade_comments_' . $userid,
'class'=>'quickgrade'));
return html_writer::tag('label', get_string('pluginname', 'assignfeedback_comments'),
array('for'=>'quickgrade_comments_' . $userid, 'class'=>'accesshide'))
. html_writer::tag('textarea', $commenttext,
array('name'=>'quickgrade_comments_' . $userid, 'id'=>'quickgrade_comments_' . $userid, 'class'=>'quickgrade'));
}

/**
Expand Down
9 changes: 5 additions & 4 deletions mod/assign/gradingtable.php
Expand Up @@ -158,9 +158,8 @@ public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $
if (!$this->is_downloading()) {
$columns[] = 'select';
$headers[] = get_string('select') .
'<div class="selectall"><input type="checkbox" name="selectall" title="' .
get_string('selectall') .
'"/></div>';
'<div class="selectall"><label class="accesshide" for="selectall">' . get_string('selectall') . '</label>
<input type="checkbox" id="selectall" name="selectall" title="' . get_string('selectall') . '"/></div>';

// Edit links.
$columns[] = 'edit';
Expand Down Expand Up @@ -513,7 +512,9 @@ function col_fullname($row) {
* @return string
*/
function col_select(stdClass $row) {
return '<input type="checkbox" name="selectedusers" value="' . $row->userid . '"/>';
return '<label class="accesshide" for="selectuser_' . $row->userid . '">' .
get_string('selectuser', 'assign', fullname($row)) . '</label>
<input type="checkbox" id=="selectuser_' . $row->userid . 'name="selectedusers" value="' . $row->userid . '"/>';
}

/**
Expand Down
1 change: 1 addition & 0 deletions mod/assign/lang/en/assign.php
Expand Up @@ -236,6 +236,7 @@
$string['sendnotifications'] = 'Notify graders about submissions';
$string['sendnotifications_help'] = 'If enabled, graders (usually teachers) receive a message whenever a student submits an assignment, early, on time and late. Message methods are configurable.';
$string['selectlink'] = 'Select...';
$string['selectuser'] = 'Select {$a}';
$string['sendlatenotifications'] = 'Notify graders about late submissions';
$string['sendlatenotifications_help'] = 'If enabled, graders (usually teachers) receive a message whenever a student submits an assignment late. Message methods are configurable.';
$string['sendsubmissionreceipts'] = 'Send submission receipt to students';
Expand Down
6 changes: 4 additions & 2 deletions mod/assign/locallib.php
Expand Up @@ -962,7 +962,8 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) {
$displaygrade = format_float($grade);
}
$o = '<label class="accesshide" for="quickgrade_' . $userid . '">' . get_string('usergrade', 'assign') . '</label>';
$o .= '<input type="text" id="quickgrade_' . $userid . '" name="quickgrade_' . $userid . '" value="' . $displaygrade . '" size="6" maxlength="10" class="quickgrade"/>';
$o .= '<input type="text" id="quickgrade_' . $userid . '" name="quickgrade_' . $userid . '" value="' . $displaygrade
. '" size="6" maxlength="10" class="quickgrade"/>';
$o .= '&nbsp;/&nbsp;' . format_float($this->get_instance()->grade,2);
$o .= '<input type="hidden" name="grademodified_' . $userid . '" value="' . $modified . '"/>';
return $o;
Expand All @@ -984,7 +985,8 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) {
}
}
if ($editing) {
$o = '<select name="quickgrade_' . $userid . '" class="quickgrade">';
$o = '<label class="accesshide" for="quickgrade_' . $userid . '">' . get_string('usergrade', 'assign') . '</label>';
$o .= '<select name="quickgrade_' . $userid . '" class="quickgrade">';
$o .= '<option value="-1">' . get_string('nograde') . '</option>';
foreach ($this->cache['scale'] as $optionid => $option) {
$selected = '';
Expand Down

0 comments on commit 7400be1

Please sign in to comment.