'.$excluded.grade_format_gradevalue($gradeval, $grade_item, true);
}
/// prints percentage
if ($grade_item->needsupdate) {
$data[] = ''.get_string('error').'';
} else {
$data[] = ''.grade_format_gradevalue($gradeval, $grade_item, true, GRADE_DISPLAY_TYPE_PERCENTAGE).'';
}
/// prints rank
if ($this->showrank) {
// TODO: this is broken if hidden grades present!!
if ($grade_item->needsupdate) {
$data[] = ''.get_string('error').'';
} 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 feedback
if (empty($grade_grade->feedback) or (!$canviewhidden and $grade_grade->is_hidden())) {
$data[] = '
';
} else {
$data[] = ''.format_text($grade_grade->feedback, $grade_grade->feedbackformat).'
';
}
$this->table->add_data($data);
}
return true;
}
/**
* Prints or returns the HTML from the flexitable.
* @param bool $return Whether or not to return the data instead of printing it directly.
* @return string
*/
function print_table($return=false) {
ob_start();
$this->table->print_html();
$html = ob_get_clean();
if ($return) {
return $html;
} else {
echo $html;
}
}
/**
* Processes the data sent by the form (grades and feedbacks).
* @var array $data
* @return bool Success or Failure (array of errors).
*/
function process_data($data) {
}
}
function grade_report_user_settings_definition(&$mform) {
global $CFG;
$options = array(-1 => get_string('default', 'grades'),
0 => get_string('hide'),
1 => get_string('show'));
if (empty($CFG->grade_report_user_showrank)) {
$options[-1] = get_string('defaultprev', 'grades', $options[0]);
} else {
$options[-1] = get_string('defaultprev', 'grades', $options[1]);
}
$mform->addElement('select', 'report_user_showrank', get_string('showrank', 'grades'), $options);
$mform->setHelpButton('report_user_showrank', array(false, get_string('showrank', 'grades'),
false, true, false, get_string('configshowrank', 'grades')));
$options = array(-1 => get_string('default', 'grades'),
0 => get_string('hide'),
1 => get_string('show'));
if (empty($CFG->grade_report_user_showhiddenitems)) {
$options[-1] = get_string('defaultprev', 'grades', $options[0]);
} else {
$options[-1] = get_string('defaultprev', 'grades', $options[1]);
}
$mform->addElement('select', 'report_user_showhiddenitems', get_string('showhiddenitems', 'grades'), $options);
$mform->setHelpButton('report_user_showhiddenitems', array(false, get_string('showhiddenitems', 'grades'),
false, true, false, get_string('configshowhiddenitems', 'grades')));
}
?>