mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
some fixes to user report
This commit is contained in:
parent
a9d5bde75d
commit
b05e8f45dc
1 changed files with 45 additions and 6 deletions
|
@ -12,6 +12,9 @@ if (!$userid = optional_param('user', 0, PARAM_INT)) {
|
||||||
$userid = $USER->id;
|
$userid = $USER->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||||
|
// find total number of participants
|
||||||
|
$numusers = count(get_role_users(@implode(',', $CFG->gradebookroles), $context));
|
||||||
|
|
||||||
// construct the tree, this should handle sort order
|
// construct the tree, this should handle sort order
|
||||||
if ($gradetree = new grade_tree($courseid)) {
|
if ($gradetree = new grade_tree($courseid)) {
|
||||||
|
@ -56,6 +59,14 @@ if ($gradetree = new grade_tree($courseid)) {
|
||||||
|
|
||||||
// grade item is the 'object' of the grade tree
|
// grade item is the 'object' of the grade tree
|
||||||
$gradeitem = $gradeitemobj['object'];
|
$gradeitem = $gradeitemobj['object'];
|
||||||
|
|
||||||
|
// grade categories are returned as part of the tree
|
||||||
|
// skip them
|
||||||
|
if (get_class($gradeitem) == 'grade_category') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// row data to be inserted into table
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
$params->itemid = $gradeitem->id;
|
$params->itemid = $gradeitem->id;
|
||||||
|
@ -82,7 +93,23 @@ if ($gradetree = new grade_tree($courseid)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// prints the grade
|
/// prints the grade
|
||||||
$data[] = $grade_grades->finalgrade;
|
|
||||||
|
if ($gradeitem->scaleid) {
|
||||||
|
// using scales
|
||||||
|
if ($scale = get_record('scale', 'id', $gradeitem->scaleid)) {
|
||||||
|
$scales = explode(",", $scale->scale);
|
||||||
|
// reindex because scale is off 1
|
||||||
|
// invalid grade if gradeval < 1
|
||||||
|
if ((int) $grade_grades->finalgrade < 1) {
|
||||||
|
$data[] = '-';
|
||||||
|
} else {
|
||||||
|
$data[] = $scales[$grade_grades->finalgrade-1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// normal grade, or text, just display
|
||||||
|
$data[] = $grade_grades->finalgrade;
|
||||||
|
}
|
||||||
|
|
||||||
/// prints percentage
|
/// prints percentage
|
||||||
|
|
||||||
|
@ -110,7 +137,19 @@ if ($gradetree = new grade_tree($courseid)) {
|
||||||
$data[] = $percentage;
|
$data[] = $percentage;
|
||||||
|
|
||||||
/// prints rank
|
/// prints rank
|
||||||
$data[] = '';
|
if ($grade_grades->finalgrade) {
|
||||||
|
/// find the number of users with a higher grade
|
||||||
|
$sql = "SELECT COUNT(DISTINCT(userid))
|
||||||
|
FROM {$CFG->prefix}grade_grades
|
||||||
|
WHERE finalgrade > $grade_grades->finalgrade
|
||||||
|
AND itemid = $gradeitem->id";
|
||||||
|
$rank = count_records_sql($sql) + 1;
|
||||||
|
|
||||||
|
$data[] = "$rank/$numusers";
|
||||||
|
} else {
|
||||||
|
// no grade, no rank
|
||||||
|
$data[] = "-";
|
||||||
|
}
|
||||||
|
|
||||||
/// prints notes
|
/// prints notes
|
||||||
if (!empty($grade_text->feedback)) {
|
if (!empty($grade_text->feedback)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue