MDL-13238 - Optionally show the user's idnumber in the grader report. Merged from MOODLE_19_STABLE.
This commit is contained in:
+58
-10
@@ -211,7 +211,7 @@ class grade_report_grader extends grade_report {
|
||||
$gradestr = new object();
|
||||
$gradestr->username = fullname($user);
|
||||
$gradestr->itemname = $grade_item->get_name();
|
||||
$warnings[] = get_string($errorstr, 'grades', $gradestr);
|
||||
$warnings[] = get_string($errorstr, 'grades', $gradestr);
|
||||
}
|
||||
|
||||
} else if ($data_type == 'feedback') {
|
||||
@@ -299,7 +299,7 @@ class grade_report_grader extends grade_report {
|
||||
global $CFG;
|
||||
|
||||
if (is_numeric($this->sortitemid)) {
|
||||
$sql = "SELECT u.id, u.firstname, u.lastname, u.imagealt, u.picture
|
||||
$sql = "SELECT u.id, u.firstname, u.lastname, u.imagealt, u.picture, u.idnumber
|
||||
FROM {$CFG->prefix}grade_grades g RIGHT OUTER JOIN
|
||||
{$CFG->prefix}user u ON (u.id = g.userid AND g.itemid = $this->sortitemid)
|
||||
LEFT JOIN {$CFG->prefix}role_assignments ra ON u.id = ra.userid
|
||||
@@ -323,7 +323,7 @@ class grade_report_grader extends grade_report {
|
||||
}
|
||||
$roles = explode(',', $this->gradebookroles);
|
||||
$this->users = get_role_users($roles, $this->context, false,
|
||||
'u.id, u.firstname, u.lastname', 'u.'.$this->sortitemid .' '. $this->sortorder . $sort2,
|
||||
'u.id, u.firstname, u.lastname, u.idnumber', 'u.'.$this->sortitemid .' '. $this->sortorder . $sort2,
|
||||
false, $this->currentgroup, $this->page * $this->get_pref('studentsperpage'), $this->get_pref('studentsperpage'));
|
||||
|
||||
}
|
||||
@@ -505,6 +505,7 @@ class grade_report_grader extends grade_report {
|
||||
$strsortdesc = $this->get_lang_string('sortdesc', 'grades');
|
||||
$strfirstname = $this->get_lang_string('firstname');
|
||||
$strlastname = $this->get_lang_string('lastname');
|
||||
$showuseridnumber = $this->get_pref('showuseridnumber');
|
||||
|
||||
if ($this->sortitemid === 'lastname') {
|
||||
if ($this->sortorder == 'ASC') {
|
||||
@@ -546,8 +547,30 @@ class grade_report_grader extends grade_report {
|
||||
$headerhtml .= '<th class="header c'.$columncount++.'" scope="col"><a href="'.$this->baseurl.'&sortitemid=firstname">'
|
||||
. $strfirstname . '</a> '
|
||||
. $firstarrow. '/ <a href="'.$this->baseurl.'&sortitemid=lastname">' . $strlastname . '</a>'. $lastarrow .'</th>';
|
||||
} else {
|
||||
$headerhtml .= '<td class="cell c'.$columncount++.' topleft"> </td>';
|
||||
if ($showuseridnumber) {
|
||||
if ('idnumber' == $this->sortitemid) {
|
||||
if ($this->sortorder == 'ASC') {
|
||||
$idnumberarrow = print_arrow('up', $strsortasc, true);
|
||||
} else {
|
||||
$idnumberarrow = print_arrow('down', $strsortdesc, true);
|
||||
}
|
||||
} else {
|
||||
$idnumberarrow = '';
|
||||
}
|
||||
$headerhtml .= '<th class="header c'.$columncount++.' useridnumber" scope="col"><a href="'.$this->baseurl.'&sortitemid=idnumber">'
|
||||
. get_string('idnumber') . '</a> ' . $idnumberarrow . '</th>';
|
||||
}
|
||||
} else {
|
||||
$colspan='';
|
||||
if ($showuseridnumber) {
|
||||
$colspan = 'colspan="2" ';
|
||||
}
|
||||
|
||||
$headerhtml .= '<td '.$colspan.'class="cell c'.$columncount++.' topleft"> </td>';
|
||||
|
||||
if ($showuseridnumber) {
|
||||
$columncount++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($row as $columnkey => $element) {
|
||||
@@ -639,6 +662,7 @@ class grade_report_grader extends grade_report {
|
||||
$strgrade = $this->get_lang_string('grade');
|
||||
$gradetabindex = 1;
|
||||
$showuserimage = $this->get_pref('showuserimage');
|
||||
$showuseridnumber = $this->get_pref('showuseridnumber');
|
||||
$numusers = count($this->users);
|
||||
|
||||
// Preload scale objects for items with a scaleid
|
||||
@@ -689,6 +713,11 @@ class grade_report_grader extends grade_report {
|
||||
.'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->course->id.'">'
|
||||
.fullname($user).'</a></th>';
|
||||
|
||||
if ($showuseridnumber) {
|
||||
$studentshtml .= '<th class="header c'.$columncount++.' useridnumber" onclick="set_row(this.parentNode.rowIndex);">'.
|
||||
$user->idnumber.'</a></th>';
|
||||
}
|
||||
|
||||
foreach ($this->gtree->items as $itemid=>$unused) {
|
||||
$item =& $this->gtree->items[$itemid];
|
||||
$grade = $this->grades[$userid][$item->id];
|
||||
@@ -765,7 +794,7 @@ class grade_report_grader extends grade_report {
|
||||
|
||||
$scales = explode(",", $scale->scale);
|
||||
// reindex because scale is off 1
|
||||
|
||||
|
||||
// MDL-12104 some previous scales might have taken up part of the array
|
||||
// so this needs to be reset
|
||||
$scaleopt = array();
|
||||
@@ -880,6 +909,7 @@ class grade_report_grader extends grade_report {
|
||||
$averagesdecimalpoints = $this->get_pref('averagesdecimalpoints');
|
||||
$meanselection = $this->get_pref('meanselection');
|
||||
$shownumberofgrades = $this->get_pref('shownumberofgrades');
|
||||
$showuseridnumber = $this->get_pref('showuseridnumber');
|
||||
|
||||
$avghtml = '';
|
||||
$avgcssclass = 'avg';
|
||||
@@ -926,9 +956,17 @@ class grade_report_grader extends grade_report {
|
||||
}
|
||||
}
|
||||
|
||||
$avghtml = '<tr class="' . $avgcssclass . ' r'.$this->rowcount++.'"><th class="header c0" scope="row">'.$straverage.'</th>';
|
||||
$columncount=0;
|
||||
$colspan='';
|
||||
if ($showuseridnumber) {
|
||||
$colspan = 'colspan="2" ';
|
||||
}
|
||||
|
||||
$columncount=1;
|
||||
$avghtml = '<tr class="' . $avgcssclass . ' r'.$this->rowcount++.'"><th class="header c0" '.$colspan.'scope="row">'.$straverage.'</th>';
|
||||
|
||||
if ($showuseridnumber) {
|
||||
$columncount++;
|
||||
}
|
||||
|
||||
$gsql = str_replace('u.id', 'ra.userid', $groupsql); // hack
|
||||
|
||||
@@ -1014,16 +1052,26 @@ class grade_report_grader extends grade_report {
|
||||
*/
|
||||
function get_rangehtml() {
|
||||
global $USER;
|
||||
$showuseridnumber = $this->get_pref('showuseridnumber');
|
||||
|
||||
$scalehtml = '';
|
||||
if ($this->get_pref('showranges')) {
|
||||
$rangesdisplaytype = $this->get_pref('rangesdisplaytype');
|
||||
$rangesdecimalpoints = $this->get_pref('rangesdecimalpoints');
|
||||
|
||||
$columncount=0;
|
||||
$colspan='';
|
||||
if ($showuseridnumber) {
|
||||
$colspan = 'colspan="2" ';
|
||||
}
|
||||
|
||||
$scalehtml = '<tr class="r'.$this->rowcount++.'">'
|
||||
. '<th class="header c0 range" scope="row">'.$this->get_lang_string('range','grades').'</th>';
|
||||
. '<th class="header c0 range" '.$colspan.'scope="row">'.$this->get_lang_string('range','grades').'</th>';
|
||||
|
||||
if ($showuseridnumber) {
|
||||
$columncount++;
|
||||
}
|
||||
|
||||
$columncount = 1;
|
||||
foreach ($this->gtree->items as $itemid=>$unused) {
|
||||
$item =& $this->gtree->items[$itemid];
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ class grader_report_preferences_form extends moodleform {
|
||||
// $preferences['prefgeneral']['enableajax'] = $checkbox_default;
|
||||
|
||||
$preferences['prefshow']['showuserimage'] = $checkbox_default;
|
||||
$preferences['prefshow']['showuseridnumber'] = $checkbox_default;
|
||||
$preferences['prefshow']['showactivityicons'] = $checkbox_default;
|
||||
$preferences['prefshow']['showranges'] = $checkbox_default;
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ $settings->add(new admin_setting_configcheckbox('grade_report_showranges', get_s
|
||||
$settings->add(new admin_setting_configcheckbox('grade_report_showuserimage', get_string('showuserimage', 'grades'),
|
||||
get_string('configshowuserimage', 'grades'), 1));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('grade_report_showuseridnumber', get_string('showuseridnumber', 'grades'),
|
||||
get_string('configshowuseridnumber', 'grades'), 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('grade_report_showactivityicons', get_string('showactivityicons', 'grades'),
|
||||
get_string('configshowactivityicons', 'grades'), 1));
|
||||
|
||||
|
||||
@@ -132,6 +132,11 @@
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
.grade-report-grader table#user-grades th.useridnumber {
|
||||
border-width:0px 0px 1px 1px;
|
||||
border-style:solid;
|
||||
}
|
||||
|
||||
.grade-report-grader table#user-grades th.categoryitem,
|
||||
.grade-report-grader table#user-grades th.courseitem,
|
||||
.grade-report-grader table#user-grades td.topleft {
|
||||
@@ -174,6 +179,10 @@
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.grade-report-grader table#user-grades td.useridnumber {
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.grade-report-grader table#user-grades td {
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ $string['configshowfeedback'] = 'Whether to show a feedback icon (for adding/edi
|
||||
$string['configshownumberofgrades'] = 'Shows the number of grades being aggregated next to each average, between brackets. Example: 45 (34).';
|
||||
$string['configshowranges'] = 'Display a row showing the range of possible for each grading item in the grader report.';
|
||||
$string['configshowrank'] = 'Show rank for each item.';
|
||||
$string['configshowuseridnumber'] = 'Whether to show the user\'s idnumber as an extra column in the grader report.';
|
||||
$string['configshowuserimage'] = 'Whether to show the user\'s profile image next to the name in the grader report.';
|
||||
$string['configstudentsperpage'] = 'The number of students to display per page in the grader report.';
|
||||
$string['configstudentsperpagedefault'] = 'The number of students to display per page in the grader report. Leave this field empty to use the site default (currently $a).';
|
||||
@@ -427,6 +428,7 @@ $string['shownooutcomes'] = 'Hide outcomes';
|
||||
$string['shownumberofgrades'] = 'Show number of grades in averages';
|
||||
$string['showranges'] = 'Show ranges';
|
||||
$string['showrank'] = 'Show rank';
|
||||
$string['showuseridnumber'] = 'Show user idnumber';
|
||||
$string['showuserimage'] = 'Show user profile images';
|
||||
$string['showverbose'] = 'Show $a->category$a->itemmodule $a->itemname';
|
||||
$string['sitewide'] = 'Site-wide';
|
||||
|
||||
Reference in New Issue
Block a user