Moodle

Gradebook: overall average includes "no submission"

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9.1
  • Fix Version/s: STABLE backlog
  • Component/s: Gradebook
  • Labels:
    None
  • Environment:
    WAMP + vista
  • Affected Branches:
    MOODLE_19_STABLE

Description

Moodle ? CF101 ? Grades ? Report ? Grader report ? Grader report
Overall average (Submissions) row should not include user without submission (see "Geo Quizzy" column on the attached screen capture)

Activity

Hide
John T. Macklin added a comment -

I have found a simple solution to this the results of the Grader Report compared to the Quiz Report can actually differ based on Roles settings . What can cause issues here is a student in the Grader Report can actually be counted twice by function get_avghtml in grade/report/grader/lib.php .

In the code there is a SQL call on line 964 which calculates $ungraded_counts. This value is then used to do the averages based on the formula $mean_count = $totalcount - $ungraded_count; In the SQL query for ungraded_count I discovered a student can be counted twice if ungraded and a memeber of both two separate graded roles. What this can do is to increase the ungraded student count from one to two for any ungraded student belonging to two separate graded roles .

In the actual SQL query $ungraded_counts = get_records_sql($SQL);
on line 980 selects each ungraded student by roles on line 973 which can result in double count when an ungraded student is in both graded roles.

If you look at Grades General Settings on a site experiencing this issue
you will usually find an additional Graded Role which is custom. The solution is to make sure that only student groups are graded and get in the habit of not adding a student to two separate graded roles at the same time.

This may not be the case for every site however; I have found that usually this is the case when averages are not coming out correct in the Grader Report. The site I experienced this issue on was running Moodle 1.9.4 (Build: 20090128). It will most likely be beneficial to change the SQL query on line 973 to make sure ungraded students are not being pulled from two roles thus creating a false student count which will affect overall averages.

Show
John T. Macklin added a comment - I have found a simple solution to this the results of the Grader Report compared to the Quiz Report can actually differ based on Roles settings . What can cause issues here is a student in the Grader Report can actually be counted twice by function get_avghtml in grade/report/grader/lib.php . In the code there is a SQL call on line 964 which calculates $ungraded_counts. This value is then used to do the averages based on the formula $mean_count = $totalcount - $ungraded_count; In the SQL query for ungraded_count I discovered a student can be counted twice if ungraded and a memeber of both two separate graded roles. What this can do is to increase the ungraded student count from one to two for any ungraded student belonging to two separate graded roles . In the actual SQL query $ungraded_counts = get_records_sql($SQL); on line 980 selects each ungraded student by roles on line 973 which can result in double count when an ungraded student is in both graded roles. If you look at Grades General Settings on a site experiencing this issue you will usually find an additional Graded Role which is custom. The solution is to make sure that only student groups are graded and get in the habit of not adding a student to two separate graded roles at the same time. This may not be the case for every site however; I have found that usually this is the case when averages are not coming out correct in the Grader Report. The site I experienced this issue on was running Moodle 1.9.4 (Build: 20090128). It will most likely be beneficial to change the SQL query on line 973 to make sure ungraded students are not being pulled from two roles thus creating a false student count which will affect overall averages.
Hide
John T. Macklin added a comment -

Something like this could help prevent this situation with averages:

// Limit Grade Book Roles to return only the first element
function gradedroles(){ gr_roles = explode (",",$this->gradebookroles) return gr_roles[0]; }

$SQL = "SELECT gi.id, COUNT(u.id) AS count
FROM {$CFG->prefix}grade_items gi
CROSS JOIN {$CFG->prefix}user u
JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id
LEFT OUTER JOIN {$CFG->prefix}grade_grades g ON (g.itemid = gi.id AND g.userid = u.id AND g.finalgrade IS NOT NULL)
$groupsql
WHERE gi.courseid = $this->courseid
AND ra.roleid in ($this->gradedroles())
AND ra.contextid ".get_related_contexts_string($this->context)."
AND g.id IS NULL
$groupwheresql
GROUP BY gi.id";

Show
John T. Macklin added a comment - Something like this could help prevent this situation with averages: // Limit Grade Book Roles to return only the first element function gradedroles(){ gr_roles = explode (",",$this->gradebookroles) return gr_roles[0]; } $SQL = "SELECT gi.id, COUNT(u.id) AS count FROM {$CFG->prefix}grade_items gi CROSS JOIN {$CFG->prefix}user u JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id LEFT OUTER JOIN {$CFG->prefix}grade_grades g ON (g.itemid = gi.id AND g.userid = u.id AND g.finalgrade IS NOT NULL) $groupsql WHERE gi.courseid = $this->courseid AND ra.roleid in ($this->gradedroles()) AND ra.contextid ".get_related_contexts_string($this->context)." AND g.id IS NULL $groupwheresql GROUP BY gi.id";
Hide
Petr Škoda (skodak) added a comment -

assigning to author of this averaging code

Show
Petr Škoda (skodak) added a comment - assigning to author of this averaging code
Hide
Joe Murphy added a comment -

Confirming that this bug still exists in 1.9.10.

Show
Joe Murphy added a comment - Confirming that this bug still exists in 1.9.10.
Hide
Andrew Davis added a comment -

Hello. I am closing this issue. Bug fixing for non-security related bugs in 1.9 has ended. http://docs.moodle.org/dev/Releases#Moodle_1.9

I strongly recommend that anyone using 1.9 upgrade as soon as possible.

Although I cannot point you to a specific issue in 2.x there were a number of issues fixed to do with roles and grades which may have resolved this issue.

Finally, this setting may be of interest for anyone experiencing odd behavior in this area. http://docs.moodle.org/20/en/Grade_categories#Aggregate_only_non-empty_grades

I do not believe this issue is present in more recent versions of Moodle however if I am incorrect please open a new issue against the version you are using.

Show
Andrew Davis added a comment - Hello. I am closing this issue. Bug fixing for non-security related bugs in 1.9 has ended. http://docs.moodle.org/dev/Releases#Moodle_1.9 I strongly recommend that anyone using 1.9 upgrade as soon as possible. Although I cannot point you to a specific issue in 2.x there were a number of issues fixed to do with roles and grades which may have resolved this issue. Finally, this setting may be of interest for anyone experiencing odd behavior in this area. http://docs.moodle.org/20/en/Grade_categories#Aggregate_only_non-empty_grades I do not believe this issue is present in more recent versions of Moodle however if I am incorrect please open a new issue against the version you are using.

People

Dates

  • Created:
    Updated:
    Resolved: