Retrieve all unmarked assignments for a particular teacher

Retrieve all unmarked assignments for a particular teacher

by Bobby White -
Number of replies: 1

I am trying to retrieve all unmarked assignments for a particular teacher id, but it seems to return alot more results than it should.

Here is what I have for my query, is there anything that looks wrong?


SELECT * FROM mdl_grade_items AS gi

    INNER JOIN mdl_grade_grades AS g ON g.itemid = gi.id

    INNER JOIN mdl_context AS ct ON ct.instanceid = gi.courseid

    INNER JOIN mdl_role_assignments AS ra ON ra.contextid = ct.id

    WHERE ct.contextlevel = 50 AND ra.userid = [USERID HERE]

    AND gi.itemtype = 'mod' AND gi.itemmodule = 'assign'

    AND g.finalgrade IS NULL

Average of ratings: -
In reply to Bobby White

Re: Retrieve all unmarked assignments for a particular teacher

by Olumuyiwa Taiwo -
Picture of Plugin developers

Since you're interested in unmarked assignments, it may make sense to use assign_submission as your base table, look for rows where the status = 'submitted', and do an outer join with assign_grades on assignment and userid. You'll of course have to filter further using the userid, context and role stuff.