MDL-15887 Implemented new setting

This commit is contained in:
nicolasconnault
2008-10-08 10:56:10 +00:00
parent 9a4ba0a430
commit 783425fc96
5 changed files with 45 additions and 16 deletions
+38 -14
View File
@@ -59,6 +59,11 @@ class grade_report_user extends grade_report {
*/
var $showrank;
/**
* show grade percentages
*/
var $showpercentage;
/**
* Show hidden items even when user does not have required cap
*/
@@ -76,6 +81,7 @@ class grade_report_user extends grade_report {
parent::grade_report($courseid, $gpr, $context);
$this->showrank = grade_get_setting($this->courseid, 'report_user_showrank', $CFG->grade_report_user_showrank);
$this->showpercentage = grade_get_setting($this->courseid, 'report_user_showpercentage', $CFG->grade_report_user_showpercentage);
$this->showhiddenitems = grade_get_setting($this->courseid, 'report_user_showhiddenitems', $CFG->grade_report_user_showhiddenitems);
$switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
@@ -105,18 +111,25 @@ class grade_report_user extends grade_report {
*/
// setting up table headers
$tablecolumns = array('itemname', 'category', 'grade');
$tableheaders = array($this->get_lang_string('gradeitem', 'grades'),
$this->get_lang_string('category'),
$this->get_lang_string('grade'));
if ($this->showpercentage) {
$tablecolumns[] = 'percentage';
$tableheaders[] = $this->get_lang_string('percentage', 'grades');
}
if ($this->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'));
$tablecolumns[] = 'rank';
$tableheaders[] = $this->get_lang_string('rank');
}
$tablecolumns[] = 'feedback';
$tableheaders[] = $this->get_lang_string('feedback');
$this->table = new flexible_table('grade-report-user-'.$this->courseid);
$this->table->define_columns($tablecolumns);
@@ -245,11 +258,13 @@ class grade_report_user extends grade_report {
}
/// prints percentage
if ($grade_item->needsupdate) {
$data[] = '<span class="'.$hidden.$class.'gradingerror">'.get_string('error').'</span>';
if ($this->showpercentage) {
if ($grade_item->needsupdate) {
$data[] = '<span class="'.$hidden.$class.'gradingerror">'.get_string('error').'</span>';
} else {
$data[] = '<span class="'.$hidden.$class.'">'.grade_format_gradevalue($gradeval, $grade_item, true, GRADE_DISPLAY_TYPE_PERCENTAGE).'</span>';
} else {
$data[] = '<span class="'.$hidden.$class.'">'.grade_format_gradevalue($gradeval, $grade_item, true, GRADE_DISPLAY_TYPE_PERCENTAGE).'</span>';
}
}
/// prints rank
@@ -327,7 +342,16 @@ function grade_report_user_settings_definition(&$mform) {
}
$mform->addElement('select', 'report_user_showrank', get_string('showrank', 'grades'), $options);
$mform->setHelpButton('report_user_showrank', array('showrank', get_string('showrank', 'grades'), 'grade'));
$mform->setHelpButton('report_user_showrank', array('showrank', get_string('showrank', 'grades'), 'grade'));
if (empty($CFG->grade_report_user_showpercentage)) {
$options[-1] = get_string('defaultprev', 'grades', $options[0]);
} else {
$options[-1] = get_string('defaultprev', 'grades', $options[1]);
}
$mform->addElement('select', 'report_user_showpercentage', get_string('showpercentage', 'grades'), $options);
$mform->setHelpButton('report_user_showpercentage', array('showpercentage', get_string('showpercentage', 'grades'), 'grade'));
$options = array(-1 => get_string('default', 'grades'),
0 => get_string('hide'),
@@ -341,7 +365,7 @@ function grade_report_user_settings_definition(&$mform) {
}
$mform->addElement('select', 'report_user_showhiddenitems', get_string('showhiddenitems', 'grades'), $options);
$mform->setHelpButton('report_user_showhiddenitems', array('showhiddenitems', get_string('showhiddenitems', 'grades'), 'grade'));
$mform->setHelpButton('report_user_showhiddenitems', array('showhiddenitems', get_string('showhiddenitems', 'grades'), 'grade'));
}
function grade_report_user_profilereport($course, $user) {
+1
View File
@@ -26,6 +26,7 @@
/// Add settings for this module to the $settings object (it's already defined)
$settings->add(new admin_setting_configcheckbox('grade_report_user_showrank', get_string('showrank', 'grades'), get_string('configshowrank', 'grades'), 0, PARAM_INT));
$settings->add(new admin_setting_configcheckbox('grade_report_user_showpercentage', get_string('showpercentage', 'grades'), get_string('configshowpercentage', 'grades'), 1, PARAM_INT));
$options = array(0 => get_string('shownohidden', 'grades'),
1 => get_string('showhiddenuntilonly', 'grades'),
+2
View File
@@ -105,6 +105,7 @@ $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'] = 'Whether to show the number of grades used when calculating the mean in brackets after each average, for example 45 (34).';
$string['configshowranges'] = 'Whether to show the range of grades for each column in an additional row.';
$string['configshowpercentage'] = 'Whether to show the percentage value of each grade item.';
$string['configshowrank'] = 'Whether to show the position of the user in relation to the rest of the class, for each grade item.';
$string['configshowuseridnumber'] = 'Whether to show user id numbers in an additional column.';
$string['configshowuserimage'] = 'Whether to show the user\'s profile image next to the name in the grader report.';
@@ -456,6 +457,7 @@ $string['showlocks'] = 'Show locks';
$string['shownohidden'] = 'No hidden';
$string['shownooutcomes'] = 'Hide outcomes';
$string['shownumberofgrades'] = 'Show number of grades in averages';
$string['showpercentage'] = 'Show percentage';
$string['showquickfeedback'] = 'Show Quick Feedback';
$string['showranges'] = 'Show ranges';
$string['showrank'] = 'Show rank';
@@ -0,0 +1,2 @@
<h1>Show percentage</h1>
<p>Whether to show the percentage value of each grade item.</p>
+2 -2
View File
@@ -1,2 +1,2 @@
<h1>Show rank</h1>
<p>Whether to show the position of the user in relation to the rest of the class, for each grade item.</p>
<h1>Show percentage</h1>
<p>Whether to show the percentage value of each grade item.</p>