@James ,
I'm not positive I understood the question either. TBH, since I don't teach and I rarely get to use Canvas like most, or try to compare the API to CD, I didn't even see flag for “do not count towards final grade” in the OP as something from the UI/API, but as a field/value @hbarkes wanted to hunt down. I read the question as trying to remove rows that will not show up in the gradebook or to include only the assignments that are being counted toward the students grade. Which was the goal of my first reply.
In addition to omit_from_final_grade, in his thread @palvara2 mentions other scenarios where the assignment might not be counted, or need to be counted right now.
This query, returns assignment submissions with the conditions in my previous post.
SELECT
ad.workflow_state AS ad_workflow_state,
ad.grading_type,
sd.workflow_state AS sd_workflow_state,
sd.grade_state,
sd.published_grade
FROM submission_dim sd
JOIN assignment_dim ad ON ad.id = sd.assignment_id
JOIN course_dim cd ON cd.id = ad.course_id
WHERE cd.canvas_id = 1
AND ad.workflow_state = 'published'
AND ad.grading_type != 'not_graded'
AND sd.workflow_state IN ('graded', 'submitted')
This query, returns assignments that are not published and are not graded.
SELECT
ad.workflow_state AS ad_workflow_state,
ad.grading_type,
sd.workflow_state AS sd_workflow_state,
sd.grade_state,
sd.published_grade
FROM submission_dim sd
JOIN assignment_dim ad ON ad.id = sd.assignment_id
JOIN course_dim cd ON cd.id = ad.course_id
WHERE cd.canvas_id = 1
AND ad.workflow_state != 'published'
AND ad.grading_type = 'not_graded'
AND sd.workflow_state NOT IN ('graded', 'submitted')
The assignment is not available.
It's not in the gradebook.
This query, returns assignments that are not published anymore, may not be graded, but have been submitted.
SELECT DISTINCT
ad.workflow_state AS ad_workflow_state,
ad.grading_type,
sd.workflow_state AS sd_workflow_state,
sd.grade_state,
sd.published_grade
FROM submission_dim sd
JOIN assignment_dim ad ON ad.id = sd.assignment_id
JOIN course_dim cd ON cd.id = ad.course_id
WHERE 1=1
AND ad.workflow_state != 'published'
AND ad.grading_type != 'not_graded'
AND sd.workflow_state = 'submitted'
Finally, if we care about NULLs. (might require case on grading_type)
,ISNULL(sd.published_grade, 0) null_to_zero
Still not sure whether it satisfies the question.
However, now my question would be, is it possible for assignments marked with omit_from_final_grade to be missed with these conditions, and are there any other conditions we need to look for? That I can't do at the moment, because I'd have to find or make a test case, and I think it's bed time.
Personal victory here, our CD import starts at 8pm. I started writing this around 8:20 or so. At one point I wrote a bad query, but thought my table had been truncated, but that's not my workflow anymore. They are imported, and then the existing table is replaced with the new dump. So I was able to do this during import!!!