Skip to content

Commit

Permalink
MDL-15887 Implemented new setting
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Oct 8, 2008
1 parent 9a4ba0a commit 783425f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 16 deletions.
52 changes: 38 additions & 14 deletions grade/report/user/lib.php
Expand Up @@ -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
*/
Expand All @@ -76,6 +81,7 @@ function grade_report_user($courseid, $gpr, $context, $userid) {
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);
Expand Down Expand Up @@ -105,18 +111,25 @@ function setup_table() {
*/

// 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);
Expand Down Expand Up @@ -245,11 +258,13 @@ function fill_table() {
}

/// 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
Expand Down Expand Up @@ -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'),
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions grade/report/user/settings.php
Expand Up @@ -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'),
Expand Down
2 changes: 2 additions & 0 deletions lang/en_utf8/grades.php
Expand Up @@ -105,6 +105,7 @@
$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.';
Expand Down Expand Up @@ -456,6 +457,7 @@
$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';
Expand Down
2 changes: 2 additions & 0 deletions lang/en_utf8/help/grade/showpercentage.html
@@ -0,0 +1,2 @@
<h1>Show percentage</h1>
<p>Whether to show the percentage value of each grade item.</p>
4 changes: 2 additions & 2 deletions lang/en_utf8/help/grade/showrank.html
@@ -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>

0 comments on commit 783425f

Please sign in to comment.