MFC: MDL-11859 student rank and showing of hidden grade items are now configurable + fixed some incorrect include_once

This commit is contained in:
skodak
2007-10-21 12:57:35 +00:00
parent 94707762b5
commit d5f05bd60e
5 changed files with 76 additions and 27 deletions
+3 -3
View File
@@ -116,7 +116,7 @@ foreach (get_list_of_plugins('grade/report') as $plugin) {
if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php')) {
$settings = new admin_settingpage('gradereport'.$plugin, get_string('modulename', 'gradereport_'.$plugin));
include_once($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php');
include($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php');
$ADMIN->add('gradereports', $settings);
}
}
@@ -134,7 +134,7 @@ foreach (get_list_of_plugins('grade/import') as $plugin) {
}
$settings = new admin_settingpage('gradeimport'.$plugin, get_string('modulename', 'gradeimport_'.$plugin));
include_once($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php');
include($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php');
$ADMIN->add('gradeimports', $settings);
}
}
@@ -152,7 +152,7 @@ foreach (get_list_of_plugins('grade/export') as $plugin) {
}
$settings = new admin_settingpage('gradeexport'.$plugin, get_string('modulename', 'gradeexport_'.$plugin));
include_once($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php');
include($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php');
$ADMIN->add('gradeexports', $settings);
}
}
-1
View File
@@ -22,7 +22,6 @@
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
require_once($CFG->libdir.'/grade/constants.php');
$strinherit = get_string('inherit', 'grades');
$strpercentage = get_string('percentage', 'grades');
+37 -22
View File
@@ -87,16 +87,24 @@ class grade_report_user extends grade_report {
* Prepares the headers and attributes of the flexitable.
*/
function setup_table() {
global $CFG;
/*
* Table has 6 columns
*| pic | itemname/description | grade (grade_final) | percentage | rank | feedback |
* Table has 5-6 columns
*| pic | itemname/description | grade (grade_final) | percentage | rank (optional) | feedback |
*/
// setting up table headers
$tablecolumns = array('itemname', 'category', 'grade', 'percentage', 'rank', 'feedback');
$tableheaders = array($this->get_lang_string('gradeitem', 'grades'), $this->get_lang_string('category'), $this->get_lang_string('grade'),
$this->get_lang_string('percent', 'grades'), $this->get_lang_string('rank', 'grades'),
$this->get_lang_string('feedback'));
if (!empty($CFG->grade_userreport_showrank)) {
// TODO: this is broken if hidden grades present!!
$tablecolumns = array('itemname', 'category', 'grade', 'percentage', 'rank', 'feedback');
$tableheaders = array($this->get_lang_string('gradeitem', 'grades'), $this->get_lang_string('category'), $this->get_lang_string('grade'),
$this->get_lang_string('percent', 'grades'), $this->get_lang_string('rank', 'grades'),
$this->get_lang_string('feedback'));
} else {
$tablecolumns = array('itemname', 'category', 'grade', 'percentage', 'feedback');
$tableheaders = array($this->get_lang_string('gradeitem', 'grades'), $this->get_lang_string('category'), $this->get_lang_string('grade'),
$this->get_lang_string('percent', 'grades'), $this->get_lang_string('feedback'));
}
$this->table = new flexible_table('grade-report-user-'.$this->courseid);
@@ -150,6 +158,10 @@ class grade_report_user extends grade_report {
$grade_item =& $items[$itemid];
$grade_grade =& $grades[$itemid];
if (empty($CFG->grade_userreport_showhiddenitems) and !$canviewhidden and $grade_item->is_hidden()) {
continue;
}
if (in_array($itemid, $unknown)) {
$gradeval = null;
} else if (array_key_exists($itemid, $altered)) {
@@ -199,22 +211,25 @@ class grade_report_user extends grade_report {
}
/// prints rank
if ($grade_item->needsupdate) {
$data[] = '<span class="gradingerror">'.get_string('error').'</span>';
} else if (is_null($gradeval)) {
// no grade, no rank
$data[] = '-';
} else {
/// find the number of users with a higher grade
$sql = "SELECT COUNT(DISTINCT(userid))
FROM {$CFG->prefix}grade_grades
WHERE finalgrade > {$grade_grade->finalgrade}
AND itemid = {$grade_item->id}";
$rank = count_records_sql($sql) + 1;
$data[] = "$rank/$numusers";
if (!empty($CFG->grade_userreport_showrank)) {
// TODO: this is broken if hidden grades present!!
if ($grade_item->needsupdate) {
$data[] = '<span class="gradingerror">'.get_string('error').'</span>';
} else if (is_null($gradeval)) {
// no grade, no rank
$data[] = '-';
} else {
/// find the number of users with a higher grade
$sql = "SELECT COUNT(DISTINCT(userid))
FROM {$CFG->prefix}grade_grades
WHERE finalgrade > {$grade_grade->finalgrade}
AND itemid = {$grade_item->id}";
$rank = count_records_sql($sql) + 1;
$data[] = "$rank/$numusers";
}
}
/// prints notes
+32
View File
@@ -0,0 +1,32 @@
<?php // $Id$
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
/// Add settings for this module to the $settings object (it's already defined)
$settings->add(new admin_setting_configcheckbox('grade_userreport_showrank', get_string('showrank', 'grades'), get_string('configshowrank', 'grades'), 0, PARAM_INT));
$settings->add(new admin_setting_configcheckbox('grade_userreport_showhiddenitems', get_string('showhiddenitems', 'grades'), get_string('configshowhiddenitems', 'grades'), 0, PARAM_INT));
?>
+4 -1
View File
@@ -89,10 +89,12 @@ $string['configshoweyecons'] = 'Whether to show a show/hide icon near each grade
$string['configshowactivityicons'] = 'Show an activity icon next to each grade item linked to an activity, in the grader report.';
$string['configshowaverages'] = 'Show column averages in the grader report.';
$string['configshowgroups'] = 'Show group averages and means in the grader report.';
$string['configshowhiddenitems'] = 'Show hidden items in report even when user does not have moodle/grade:viewhidden capability. Visibility of hidden grades is not affected by this setting.';
$string['configshowlocks'] = 'Whether to show a lock/unlock icon near each grade.';
$string['configshowfeedback'] = 'Whether to show a feedback icon (for adding/editing) near each grade.';
$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['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).';
@@ -388,11 +390,12 @@ $string['showcalculations'] = 'Show calculations';
$string['showeyecons'] = 'Show show/hide icons';
$string['showfeedback'] = 'Show feedback';
$string['showgroups'] = 'Show groups';
$string['showhiddenitems'] = 'Show Hidden Items';
$string['showhiddenitems'] = 'Show hidden items';
$string['showlocks'] = 'Show locks';
$string['shownooutcomes'] = 'Hide outcomes';
$string['shownumberofgrades'] = 'Show number of grades in averages';
$string['showranges'] = 'Show ranges';
$string['showrank'] = 'Show rank';
$string['showuserimage'] = 'Show user profile images';
$string['sitewide'] = 'Site-wide';
$string['sort'] = 'sort';