Moodle 3.1.3. This is a bit vague, but I'm hoping someone might have seen this before so please bear with me.
The complaint was that in a group submission assignment, some teachers could see a student as marked and for other teachers the same student was not marked (for multiple students). With debugging on, sure enough, multiple instances of...
Did you remember to make the first column something unique in your call to get_records? Duplicate value '24597' found in column 'id'.
- line 1097 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()
- line 1593 of /lib/tablelib.php: call to mysqli_native_moodle_database->get_records_sql()
- line 1614 of /lib/tablelib.php: call to table_sql->query_db()
- line 1439 of /mod/assign/renderer.php: call to table_sql->out()
- line 1235 of /mod/assign/renderer.php: call to mod_assign_renderer->flexible_table()
- line 319 of /lib/outputrenderers.php: call to mod_assign_renderer->render_assign_grading_table()
- line 3795 of /mod/assign/locallib.php: call to plugin_renderer_base->render()
- line 3869 of /mod/assign/locallib.php: call to assign->view_grading_table()
- line 572 of /mod/assign/locallib.php: call to assign->view_grading_page()
- line 52 of /mod/assign/view.php: call to assign->view()
With a minimum of digging, this was talking about this bit of SQL..
SELECT
u.id,u.picture,u.firstname,u.lastname,u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.imagealt,u.email, u.id as userid, s.status as status, s.id as submissionid, s.timecreated as firstsubmission, s.timemodified as timesubmitted, s.attemptnumber as attemptnumber, g.id as gradeid, g.grade as grade, g.timemodified as timemarked, g.timecreated as firstmarked, uf.mailed as mailed, uf.locked as locked, uf.extensionduedate as extensionduedate, uf.workflowstate as workflowstate, uf.allocatedmarker as allocatedmarker , um.id as recordid
FROM {user} u
LEFT JOIN {assign_submission} s
ON u.id = s.userid
AND s.assignment = :assignmentid1
AND s.latest = 1
LEFT JOIN {assign_grades} g
ON u.id = g.userid
AND g.assignment = :assignmentid2 LEFT JOIN (SELECT mxg.userid, MAX(mxg.attemptnumber) AS maxattempt
FROM {assign_grades} mxg
WHERE mxg.assignment = :assignmentid4
GROUP BY mxg.userid) gmx
ON u.id = gmx.userid
AND g.attemptnumber = gmx.maxattempt LEFT JOIN {assign_user_flags} uf
ON u.id = uf.userid
AND uf.assignment = :assignmentid3 LEFT JOIN {assign_user_mapping} um
ON u.id = um.userid
AND um.assignment = :assignmentid5
WHERE u.id IN (:user17,:user18,:user19,:user20,:user21)
ORDER BY userid ASC
Having substituted some parameters (for a single submission group) on my dev site, and run the query this is returned (select cut down a lot for clarity)...
+-----+--------+--------------+---------------+---------+----------+----------+
| id | userid | submissionid | attemptnumber | gradeid | grade | recordid |
+-----+--------+--------------+---------------+---------+----------+----------+
| 709 | 709 | 2202 | 5 | 1269 | 56.66667 | 96 |
| 709 | 709 | 2202 | 5 | 1270 | -1.00000 | 96 |
| 709 | 709 | 2202 | 5 | 1271 | -1.00000 | 96 |
| 709 | 709 | 2202 | 5 | 1272 | -1.00000 | 96 |
| 709 | 709 | 2202 | 5 | 1273 | -1.00000 | 96 |
| 709 | 709 | 2202 | 5 | 1274 | -1.00000 | 96 |
| 716 | 716 | 2214 | 5 | 1280 | -1.00000 | 22 |
| 716 | 716 | 2214 | 5 | 1281 | 56.66667 | 22 |
| 716 | 716 | 2214 | 5 | 1282 | -1.00000 | 22 |
| 726 | 726 | 2229 | 5 | 1288 | -1.00000 | 28 |
| 726 | 726 | 2229 | 5 | 1289 | 56.66667 | 28 |
| 726 | 726 | 2229 | 5 | 1290 | -1.00000 | 28 |
| 746 | 746 | 2256 | 5 | 1302 | 56.66667 | 71 |
| 770 | 770 | 2285 | 5 | 1318 | 56.66667 | 60 |
+-----+--------+--------------+---------------+---------+----------+----------+
So, it is indeed pulling multiple results for some students. The problem appears to be caused by the record 'Grade = -1'. I have no idea what that means or is doing in the data...
Any thoughts?