Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
Found this content helpful? Log in or sign up to leave a like!
I have some code that I have used for a while now which gathers information on students' weekly academic progress. Lately - roughly a month or so ago - I started to notice a problem in that code.
I use this line of python to get a list of the assignments for a given user:
assignments = user.get_assignments(course_id, include = 'all_dates')
In the past, this worked perfectly, returning a paginated list of all of the assignments that the user was assigned to.
However, when this method is used with certain courses (but not all!), instead of only returning the assignments which are assigned to that user, it returns all assignments.
I have double-checked to make sure that the assignments are assigned to the correct course sections, and that students are not in multiple sections, but I can't figure out what is causing this to happen.
Any insight at all is much appreciated.
Solved! Go to Solution.
Be as it may, it might help to file a case to see if Instructure Engineering does or does not see the get request for the assignment list endpoint returning all the assignments (assigned or not) for the entire course for a particular student as a bug in the API itself. Once that is vetted, you may find that your original approach could be successful. You could point them to this discussion thread in the community.
Can you share the exact URL you're using to request this data? Does it behave correctly if you use a service like Postman/etc to retrieve the data?
Sorry, but I am pretty ignorant of how this API actually works.
I just use the python module canvasapi and don't use any other service like Postman.
The python method I am using (user.get_assignments()) appears to use this GET call:
GET /api/v1/users/:user_id/courses/:course_id/assignments
When I check students' pages directly, however, they aren't being assigned to any incorrect assignments. So, it seems to be something to do with the API call.
The really odd thing for me is that it only happens with a handful of courses, even though I run this program for 1000+ students in 150+ separate Canvas courses. (Unfortunately, those handful of courses happen to have very large enrollment numbers, so it affects quite a lot of students.) It also only became a problem recently (past two months or so). I have been using this method for two years to get info on students' assignments.
Could there be something about these courses' settings, or the way that they have set up their course sections, that is causing the API to pull all assignments, not just those assigned to the user in question?
Have you tried passing in the course id to the python module's get_assignments() method?
https://canvasapi.readthedocs.io/en/stable/keyword-args.html
Yes!
I first retrieve a list of all of the user's courses (in order to get course title, etc., that I can't get from the assignments or enrollments themselves). Then, once I have that list, I iterate through each of the user's courses using the course id to retrieve the assignments for each individual course that the user is assigned to.
I will disclose...that I don't have any large enrollment courses where I work.
For the record are the users' assignment lists super long? What are some of the consistent common variables with respect to the courses themselves that you have observed? The course roster you had mentioned is a higher enrollment count? For those courses, what's the average assignment list length you would see?
I'd be interested in seeing a snippet of the code you have started with and perhaps test it on one of our courses over here to see we have the same issue.... If it's a suspected problem with the canvas api wrapper, maybe switch over to using the requests module and see if it does the same thing?
By high enrollment, I really just mean ~50 students per class.
However, the assignment lists in these particular classes are very long, 150 - 200, even up to 300 assignments for each student. Perhaps that is the issue.
Here's the relevant bit of my code: (That assignment list for each course that you get at the end is returned so that another function can sort through the relevant assignments to get scores, determine what is missing, etc.)
--------------------------------------------------
user = find_student(ssid)
semester_end = datetime.strptime('2025-01-18', '%Y-%m-%d')
try:
courses = user_courses(user, include = ['current_grading_period_scores', 'total_scores'])
except Exception:
return
for course in courses:
course_id = course.id
assignments = user.get_assignments(course_id, include = 'all_dates')
assignment_list = list()
for x in assignments:
if x.published is False:
continue
time_stamp = x.due_at # This time stamp needs to be converted into a datetime object and the timezone corrected.
if time_stamp is None:
try:
time_stamp = x.all_dates[0]['due_at']
if time_stamp is None:
continue
except Exception:
continue
ts_object = datetime.strptime(f'{time_stamp[:10]} {time_stamp[11:19]}', '%Y-%m-%d %H:%M:%S')
due_date = ts_object - timedelta(hours=7)#Correcting the timezone
if due_date <= semester_end:
continue
else:
assignment_list.append([x, due_date])
Okay,
The only way I could take this idea and run with it in my environment is to choose a specific student in a class that has a lot of assignments and run it against their assignment list.
There is an unreferenced function user_courses() that I assume gets a list of courses based on a user which I replaced with user.get_courses()
Leaving some of your code intact (but commented out) I found what I thought would be a good test case by manually identifying a specific student who had a list of 225 across 5 courses with one of the courses with an enrollment of 50+ students. I'm not sure where your Python environment is (are you using a framework such as Flask or Django?), but here is my locally run .py code:
from canvasapi import Canvas
API_KEY = input("Enter your Key: ")
API_URL = input("Enter Canvas Instance URL: ")
canvas = Canvas(API_URL,API_KEY)
user_id = # Hard-code Canvas ID of Student here
user = canvas.get_user(user_id)
assignment_list = []
course_count = 0
courses = user.get_courses()
#user.get_courses(user, include = ['current_grading_period_scores', 'total_scores'])
for course in courses:
course_count += 1
course_id = course.id
assignments = user.get_assignments(course_id, include = 'all_dates')
for x in assignments:
print(x)
assignment_list.append(x.name)
# if x.published is False:
# continue
# time_stamp = x.due_at # This time stamp needs to be converted into a datetime object and the timezone corrected.
# if time_stamp is None:
# try:
# time_stamp = x.all_dates[0]['due_at']
# if time_stamp is None:
# continue
# except Exception:
# continue
# due_date = ts_object - timedelta(hours=7)#Correcting the timezone
# if due_date <= semester_end:
# continue
# else:
# assignment_list.append([x, due_date])
print(f'Course count: {course_count}')
print(f'Total Assignment Count: {len(assignment_list)}')
'''===Begin Output
QUIZ 1 (16342868)
QUIZ 2 (16342869)
QUIZ 3 (16342867)
QUIZ 4 (16342865)
FINAL EXAM (16342866)
WEEK 1 DISCUSSION (16342886)
WEEK 2 DISCUSSIONS (16342885)
WEEK 4 DISCUSSION (16342883)
WEEK 5 DISCUSSION (16342882)
WEEK 7 DISCUSSION (16342880)
WEEK 8 DISCUSSION (16342879)
WEEK 10 DISCUSSION (16342878)
WEEK 11 DISCUSSION (16342876)
WEEK 13 DISCUSSION (16342875)
WEEK 14 DISCUSSION (16342874)
WEEK 15 DISCUSSION (16342872)
WEEK 16 DISCUSSION (16342870)
TERM PAPER (16342888)
Practice RLB Quiz - Requires Respondus LockDown Browser + Webcam (16337445)
Chap 9 (C) Quiz Muscle Physiology (16337384)
Ch 11 (A) Intro to NS Quiz (16337424)
Ch 11 (B) Neurophysiology Quiz (16337367)
Chapter 12 (C) Brain Quiz 2 (16337405)
Chapter 12 (A and B) SCord Quiz (16337396)
Ch 14 Lec Quiz 1 (16337376)
Ch 14 Lec Quiz 2 (16337420)
BIO 201 Final Exam - Requires Respondus LockDown Browser + Webcam (16337371)
Lab Quiz 10 (Lab 22: Nervous System) - Requires Respondus LockDown Browser + Webcam (16337441)
Lab Quiz 11 (Lab 23: Brain) - Requires Respondus LockDown Browser + Webcam (16337409)
Final Letter Grade (16337487)
LECTURE TEST 1 - Chapters 1, 2, 3 - Requires Respondus LockDown Browser + Webcam (16337382)
LECTURE TEST 2 - Chapters 5, 6, 8, 9 - Requires Respondus LockDown Browser + Webcam (16337421)
Extra credit Quiz on Greek & Latin Origins of Skull Bones & Markings (16337486)
Extra Credit Quiz on Greek & Latin Origins of Axial Skeleton Bones & Markings (16337483)
Recorded Extra Credit for Axial Skeleton Bone Names (16337510)
Ch 12 (C) Cranial Nerves Quiz 3 (16337438)
Extra Credit Quiz on Greek & Latin Origins of Upper Extremity Bones & Markings (16337485)
Extra Credit Quiz on Greek & Latin Origins of Lower Extremity Bones & Markings (16337484)
Recorded Extra credit on Upper Extremity (16337511)
Recorded extra credit for lower extremity (16337512)
Lab Quiz 12 (Lab 24: Special Senses) - Requires Respondus LockDown Browser + Webcam (16337399)
LECTURE TEST 3 Ch 11 and 12; Cranial Nerves - Requires Respondus LockDown Browser + Webcam (16337414)
Lab 1: Metric Review Completed Lab Exercises Upload (16337497)
Lab 1: Metric System Review Submission Quiz (16337379)
Lab 2: Microscopy Completed Lab Exercises Upload (16337502)
Lab 2: Microscopy Lab Exercises Submission Quiz (16337387)
Lab 3: Cell Division Completed Lab Exercises Upload (16337503)
Lab 3: Cell Division Lab Submission Quiz (16337392)
Lab 5: Histology of Epithelial Tissue Completed Lab Exercises Upload (16337504)
Lab 5: Histology of Epithelial Tissue Submission Quiz (16337412)
Lab 6: Histology of Connective Tissue Completed Lab Exercises Upload (16337505)
Lab 6: Histology of Connective Tissue Submission Quiz (16337369)
Lab 7: Histology of Muscle Tissue Completed Lab Exercise Upload (16337506)
Lab 7: Histology of Muscle Tissue Lab Exercise Submission Quiz (16337386)
Lab 8: Skin Completed Lab Exercises Upload (16337507)
Lab 8: Skin Lab Exercises Submission Quiz (16337378)
Lab 9: Intro to Skeleton Completed Lab Exercises Upload (16337508)
Lab 9: Intro to Skeleton Lab Exercises Submission Quiz (16337415)
Lab 10: Skull Completed Lab Exercises Upload (16337488)
Lab 10: Skull Lab Exercises Submission Quiz (16337380)
Lab 11: Axial Skeleton Completed Lab Exercises Upload (16337489)
Lab 11: Axial Skeleton Lab Exercise Submission Quiz (16337374)
Lab 12: Upper Extremity Bones Completed Lab Exercises Upload (16337490)
Lab 12: Upper Extremity Bones Lab Exercises Submission Quiz (16337373)
Lab 13: Lower Extremity Bones Completed Lab Exercises Upload (16337491)
Lab 13: Lower Extremity Bones Lab Exercises Submission Quiz (16337418)
Lab 14: Joints Completed Lab Exercises Upload (16337492)
Lab 14: Joints Lab Exercises Submission Quiz (16337368)
Lab 16: Introduction to Skeletal Muscles Completed Lab Exercises Upload (16337493)
Lab 16: Introduction to Skeletal Muscles Lab Exercises Submission Quiz (16337446)
Lab 17: Upper Extremity Muscles Completed Lab Exercises Upload (16337494)
Lab 17: Upper Extremity Muscles Lab Exercise Submission Quiz (16337385)
Lab 18: Shoulder and Pectoral Girdle Muscles Completed Lab Exercises Upload (16337495)
Lab 18: Shoulder and Pectoral Girdle Muscles Lab Exercises Submission Quiz (16337419)
Lab 19: Lower Extremity Muscles Completed Lab Exercises Upload (16337496)
Lab 19: Lower Extremity Muscles Lab Exercise Submission Quiz (16337428)
Lab 20: Torso and Head Muscles Completed Lab Exercises Upload (16337498)
Lab 20: Torso and Head Muscles Lab Exercise Submission Quiz (16337404)
Lab 22: Nervous System Lab Exercise Submission Quiz (16337416)
Lab 22: Nervous System Completed Lab Exercises Upload (16337499)
Lab 23: Brain Lab Exercises Submission Quiz (16337383)
Lab 23: Brain Completed Lab Exercises Upload (16337500)
Lab 24: Special Senses Lab Exercises Submission Quiz (16337377)
Lab 24: Special Senses Completed Lab Exercises Upload (16337501)
Introduce Yourself Discussion worth 10 extra credit points (16337448)
CH 1 Lecture Notes (16337449)
CH 2 (A) Lecture Notes (16337467)
CH 2 (B) Lecture Notes (16337468)
CH 3 Lecture Notes (16337471)
CH 5 Lec Notes (16337472)
CH 6 Lec Notes (16337474)
CH 8 Lec Notes (16337476)
CH 9 (A) Intro Muscle Lec Notes (16337477)
CH 9 (B) Lec Notes Muscle Sliding Filament (16337480)
CH 9 (C) Lec Notes Muscle Physiology (16337482)
CH 11 (A) Intro to NS Lec Notes (16337451)
CH 11 (B) Neurophysiology Lec Notes (16337453)
CH 12 (A) Spinal Cord Basics Lec Notes (16337456)
CH 12 (B) SPCORD MENINGE/NERVE Lec Notes (16337457)
CH 12 (C) Brain & Cranial Nerves Lec Notes (16337459)
CH 12 (D) Meninges Lec Notes (16337461)
CH 14 Lec Notes (16337465)
Chapter 1 Lec Quiz (16337400)
Chapter 2 (A) Lec Quiz 1 (16337411)
Chapter 2 (A) Lec Quiz 2 (16337435)
Chapter 2 (B) Lec Quiz 3 (16337402)
Chapter 2 (B) Lec Quiz 4 (16337443)
Chapter 3 Lec Quiz 1 (16337423)
Chapter 5 Lec Quiz (16337430)
Chapter 6 Lec Quiz (16337370)
Chapter 8 Lec Quiz (16337410)
Ch 9 (A) IntroMuscle Lec Quiz (16337391)
Chap 9 (B) Sliding Filament Lec Quiz (16337393)
Chapter 12 (C) Brain Quiz 1 (16337408)
Lab Quiz 1 (Labs 1-3) - Requires Respondus LockDown Browser + Webcam (16337372)
Lab Quiz 2 (Lab 5) - Requires Respondus LockDown Browser + Webcam (16337403)
Lab Quiz 3 (Lab 6-7) - Requires Respondus LockDown Browser + Webcam (16337398)
Lab Quiz 4 (Lab 10: Skull) - Requires Respondus LockDown Browser + Webcam (16337406)
Lab Quiz 1 (Labs 1-3) - Requires Respondus LockDown Browser + Webcam (16337372)
Lab Quiz 2 (Lab 5) - Requires Respondus LockDown Browser + Webcam (16337403)
Lab Quiz 3 (Lab 6-7) - Requires Respondus LockDown Browser + Webcam (16337398)
Lab Quiz 4 (Lab 10: Skull) - Requires Respondus LockDown Browser + Webcam (16337406)
Lab Quiz 5 (Lab 11-12: Axial Skeleton and Arm) - Requires Respondus LockDown Browser + Webcam (16337381)
Lab Quiz 6 (Lab 13: Lower Extremity Bones) - Requires Respondus LockDown Browser + Webcam (16337407)
Lab Quiz 7: Upper Extremity, Shoulder, and Pectoral Girdle Muscles (Labs 17-18) - Requires Respondus LockDown Browser + Webcam (16337417)
Lab Quiz 8: Lower Extremity Muscles (Lab-19) - Requires Respondus LockDown Browser + Webcam (16337422)
Lab Quiz 9: Head and Torso Muscles (Lab 20) - Requires Respondus LockDown Browser + Webcam (16337433)
Lab Practical Exam 1 - Requires Respondus LockDown Browser + Webcam (16337375)
Lab Practical Exam 2 - Requires Respondus LockDown Browser + Webcam (16337395)
Lab Practical Exam 3 (Muscles) - Requires Respondus LockDown Browser + Webcam (16337389)
Lab Practical 4 (Nervous System, Brain, Eye, Ear) Labs 22, 23, and 24 - Requires Respondus LockDown Browser + Webcam (16337401)
Syllabus Acknowledgement Quiz (16531322)
Recorded Extra Credit Latin & Greek Activity (16337509)
Video Lesson Assignment 2B: Rational Exponent Expressions (16464564)
Video Lesson Assignment 2C: Multiply, Add, & Subtract Radical Expressions (16464566)
Video Lesson Assignment 2D: Divide Radical Expressions (16464569)
Video Lesson Assignment 2E: Solve Radical & Rational Exponent Equations (16464575)
Video Lesson Assignment 2F: Radical Functions (16464580)
Exam 1 Review Guide (16464581)
Quiz 3 ( Based on 1C & 1D) (16464684)
Roll Call Attendance (16683658)
Syllabus & Calendar of Due Dates - Confirmations (16464534)
Syllabus Quiz (16464536)
Video Lesson Assignment Unit P: Pre-Requisites (16464538)
Homework Assignment Unit P: Pre-Requisites (16464539)
Homework Assignment 1A: Rates of Change & Difference Quotient (16464541)
Homework Assignment 1B: Composition of Functions (16464542)
Homework Assignment 1C: Inverse Functions (16464543)
Homework Assignment 1D: Essential Elements from Graphs of Functions (16464544)
Homework Assignment 1E: Graphs of Functions (16464546)
Homework Assignment 1F: Transformations of Functions (16464550)
Homework Assignment 2A: Simplify Radical Expressions & Complex Numbers (16464562)
Homework Assignment 2B: Rational Exponent Expressions (16464563)
Homework Assignment 2C: Multiply, Add, & Subtract Radical Expressions (16464565)
Homework Assignment 2D: Divide Radical Expressions (16464568)
Homework Assignment 2E: Solve Radical & Rational Exponent Equations (16464571)
Homework Assignment 2F: Radical Functions (16464579)
Homework Assignment 3A: Quadratic Functions (16464583)
Homework Assignment 3B: Higher-Order Polynomial Functions (16464584)
Homework Assignment 3C: Dividing Polynomials (16464585)
Homework Assignment 3D: ALL Zeros of Polynomials Algebraically (16464586)
Homework Assignment 3E: Using Zeros to Write Equations of Polynomials (16464587)
Exam 2 Review (16464595)
Homework Assignment 4A: Simplify & Multiply Rational Expressions (16464596)
Homework Assignment 4B: Add & Subtract Rational Expressions (16464597)
Homework Assignment 4C: Simplify Complex Rational Expressions (16464598)
Homework Assignment 4D: Solve Rational Equations (16464599)
Homework Assignment 4E: Graphs of Rational Functions (16464600)
Homework Assignment 5A: Introduction to Exponential & Logarithmic Functions (16464604)
Homework Assignment 5B: Properties of Logarithms (16464605)
Exam 4 Review (16631090)
Homework Assignment 5C: Solving Exponential Equations (16464607)
Homework Assignment 5D: Solving Logarithmic Equations (16464609)
Homework Assignment 6A: Solving Absolute Value Equations (16464618)
Homework Assignment 6B: Solving Linear & Quadratic Inequalities (16464621)
Homework Assignment 6C: Systems of Linear Equations in 2 & 3 Variables (16464626)
Homework Assignment 6D: Review of Solving ALL Equations (16464632)
Exam 3 (Unit 4) Review Guide (16464646)
Final Exam Review Guide 2025 (16464657)
Exam 1 (16464582)
Exam 2 ( Units 2&3 ) (16464594)
Exam 3 ( Unit 4) (16464649)
Exam 4 ( Units 5,6) (16540810)
Exam 4 (Units 5,6) (16631131)
Final Exam (16464663)
Quiz 1 ( based on Unit P ) (16464553)
Quiz 2 ( Based on 1A & 1B) (16464556)
Quiz 3 ( Based on 1C & 1D) (16464559)
Quiz 4 ( Based on 1 E &1F ) (16464561)
Quiz 3A (16464588)
Quiz 3B (16464589)
Quiz 3C (16464591)
Quiz 3D (16464592)
Quiz 3E (16464593)
Quiz 4A & 4B (16464601)
Quiz 4C & 4D (16464602)
Quiz 4E (16464603)
Quiz 5 A (16464613)
Quiz 5B (16464614)
Quiz 5C &5 D (16464615)
Quiz 6A & 6B (16464636)
Quiz 6 C & 6 D (16464641)
Quiz 2A (16631454)
Quiz 2B,2C (16631455)
Quiz 2D (16631456)
Quiz 2E (16631457)
Quiz 2F (16631458)
Eligibility Affidavit & Time Accountability for the NJCAA: Form I & II (4660357)
Upload Current Photo to Canvas (4660372)
Permission to use Photo & Quote (4660364)
High School Transcript or GED (4660360)
Official CollegeTranscripts (4660363)
Pre-Financial Plan Agreement Form (7791059)
NJCAA Amateurism Questonnaire (4660361)
Transfer Tracking Form (4660370)
NJCAA Transfer Waiver Form (4660362)
MCCCD FERPA for NJCAA (12518169)
Mandatory Travel Forms (4660371)
Scholarship Contract & Signature forms (4660355)
Understanding and Acknowledgements (4660356)
Pre-Participation Physical Examination (4660365)
Submission of Completed Eligibility Packet (4660369)
Graduation deadline (11047829)
Eligibility Check Sheets (4660358)
Roll Call Attendance (4660368)
Course count: 5
Total Assignment Count: 225
===End Output==='''
What are your thoughts? Does this at all address your issue, or have I missed it completely?
Oh goodness. Sorry for overlooking that.
user_courses() is a function I wrote which does use the method user.get_courses(), the only difference is I add some additional filtering to ensure I am only looking at academic courses for the correct enrollment term.
I think that the problem I am seeing is probably tied to the large assignment lists. Because, while your test case produced 225 assignments across 5 courses, my students have hundreds of assignments in a single course.
To further clarify, my school uses course sections to identify different academic tracks. Students are assigned to an academic track at the time of enrollment. Then, when they are added to a Canvas course, they are assigned to the appropriate course section.
In addition, differentiated versions of each assignment are assigned to each section. (So, Example Assignment A-G would be assigned to the A-G course section, while Example Assignment Grad would be assigned to the Grad section.)
In these particular courses, where hundreds of assignments are being assigned each semester (and they are year long courses), the resulting error is that, in addition to those hundreds of assignments which a student should be correctly assigned to, when I pull their list of assignments, their lists will also include hundreds of assignments belonging to other course sections.
Here are two example courses for the same student, one course with this error, the other without.
Course 1 (World Literature)
Total Assignments for the student: 474
Total Published Assignments for the current semester assigned to the student: 40 (seen below)
W21D2 SYK: JLC Quiz 1 (Grad-Op.2) (223678)
W22D2 SYK: JLC Quiz 2 (Grad-Opt2) (225113)
W19D2 SYK: Ultimate Anthology Final (218084)
W20D1 SYK: JLC Exit Ticket (A-G/Grad) (222860)
W22D2 SYK: Exit Ticket (Grad) (225108)
LP3 Entire Notebook Check (218083)
W20D2 Learn: Notebook Check (222863)
W21D2 Learn: Notebook Check (223672)
W20D1 Learn: China Research (AG/Grad) (222856)
W22D2 Learn: Notebook Check (225101)
W20D2 Practice: JLC Chapter 1 & 2 Reading Questions (Grad-Opt.2) (222865)
W21D1 Practice: JLC Chapter 3 & 4 Reading Questions (Grad-Op.2) (223665)
Mid Year Reading Survey (223148)
W21D2 Practice: JLC Chapter 5 & 6 Reading Questions (Grad-Op.2) (223675)
W22D1 Practice: JLC Chapter 7 & 8 Reading Questions (Grad-Op.2) (225097)
W22D2 Practice: JLC Chapter 9 & 10 Reading Questions (Grad-Op.2) (225104)
LP3 Entire Notebook Check (218083)
W20D2 Learn: Notebook Check (222863)
W21D2 Learn: Notebook Check (223672)
W20D1 Learn: China Research (AG/Grad) (222856)
W20D1 Learn: KWL (all) (222859)
W20D1 Learn: China Research (Op2) (222858)
W20D1 Learn: China Research (M2/M3) (222857)
W22D2 Learn: Notebook Check (225101)
W20D2 Practice: JLC Chapter 1 & 2 Reading Questions (A-G) (222864)
W20D2 Practice: JLC Chapter 1 & 2 Reading Questions (Grad-Opt.2) (222865)
W20D2 Practice: JLC Chapter 1 & 2 Reading Questions (M2/M3) (222866)
W21D1 Practice: JLC Chapter 3 & 4 Reading Questions (A-G) (223664)
W21D2 Practice: JLC Chapter 5 & 6 Reading Questions (A-G) (223674)
W21D1 Practice: JLC Chapter 3 & 4 Reading Questions (Grad-Op.2) (223665)
W21D1 Practice: JLC Chapter 3 & 4 Reading Questions (M2/M3) (223666)
Mid Year Reading Survey (223148)
W21D2 Practice: JLC Chapter 5 & 6 Reading Questions (Grad-Op.2) (223675)
W21D2 Practice: JLC Chapter 5 & 6 Reading Questions (M2/M3) (223676)
W22D1 Practice: JLC Chapter 7 & 8 Reading Questions (A-G) (225096)
W22D1 Practice: JLC Chapter 7 & 8 Reading Questions (Grad-Op.2) (225097)
W22D1 Practice: JLC Chapter 7 & 8 Reading Questions (M2/M3) (225098)
W22D2 Practice: JLC Chapter 9 & 10 Reading Questions (A-G) (225103)
W22D2 Practice: JLC Chapter 9 & 10 Reading Questions (Grad-Op.2) (225104)
W22D2 Practice: JLC Chapter 9 & 10 Reading Questions (M2/M3) (225105)
This student belongs to the course section 'Grad', but they are also receiving assignments that belong to A-G, Opt-2, and M2/M3 course sections as well.
In contrast, here is that same student's assignment list for a different course.
Course 2 (World History)
Total Assignments for the student: 94
Total Published Assignments for the current semester assigned to the student: 16 (seen below)
W19 D2 SYK: LP 3 Unit Test (Grad) (218025)
W20D1 SYK: Exit Ticket (All) (222849)
W21D1 SYK: Exit Ticket (A-G/Grad) (223513)
W21D2 SYK: The Mongol's Impact (Grad) (224754)
W22D1 SYK: Exit Ticket (A-G, Grad) (225076)
W19 D2 Full Notebook Check (218022)
W20D2 Learn: Notebook Check (All) (222853)
W21D2 Learn: Notebook Check (All) (223517)
W22D2 Learn: Notebook Check (All) (225089)
W19 D2 Practice: Islam Webquest (A-G/Grad) (218023)
W20D2 Extend: All the Khan's Horses (Grad, Opt.2, M2/M3) (222852)
W21D1 Extend: Sorqoqtani Beki - Graphic Biography (Grad, Opt.2, M2/M3) (223507)
W20D1: Practice Videos on the Mongols (A-G/Grad) (222850)
W21D2 Practice: Video: The Last Chief of the Comanches (A-G/Grad) (223524)
W22D1 Extend: Mongol and Comanche Comparison Paragraph (Grad/Opt 2) (225075)
W22D2 Practice: Mongol Influence Research Paragraph (A-G/Grad) (225090)
24.25 Lompoc HS World history
In the above list, we do see some additional section names ('A-G', 'Opt-2') but only when in combination with 'Grad', because the assignment was given to both sections.
So what it sounds like to me (correct me if I'm wrong), is that your code isn't necessarily erroring out, but instead is returning unexpected results? I'm afraid I don't have an equivalent course of that complexity to test against. What are you expecting to find if the results you are getting are unexpected? It might help to reduce your problem to a smaller chunk of the problem and make sure that part is expected and focus on another part of the problem that is not expected, and then repeat until the whole thing is getting the correct results.
That's exactly right. The problem I am having is unexpected results. For less complex courses, it is returning exactly what I am looking for: those assignments which are assigned to them in their course section. In those especially complex courses, however, it is returning all assignments for all course sections.
I'm not sure how to reduce the problem to a smaller chunk, since the get_assignments() method returns all assignments for the whole course, and that's what I don't know how to control. Because, once I get that list, I can work on filtering out the nonsense results. But, I am hoping to avoid that in the first place.
Oh okay. So maybe there's a parameter that will narrow down the list to just the assignments responsible for the student that has yet to be considered. I see you've attempted at least one filter (all_dates). There may be a clue in the developer tools on the browser on what Canvas is using to get the entire assignment list for a particular user that only includes the differentiated assignments for the currently logged in user. Try masquerading as a student, expose the developer tools and look at the GET request(s) for when the student navigates to the assignments tab. Like I said, I don't have an equivalent complex course to replicate your exact situation, but I can try it on a small scale. If I come up with anything, I'll return to this thread with my result.
Without any additional parameters, user.get_assignments(course_id) should already only include the assignments for that user based on their course section. And that's what is returned for almost all of the courses that I try it on. It's just these 4-5 courses which have an exceptionally large number of assignments where it seems to not only be pulling that particular user's assignments, but all assignments as well.
I haven't seen any other parameters that could help, but will keep looking, and will probably try to put in a help ticket.
Hi @DOGutierrez,
I could perhaps suggest a different appraoch to figuring out the problem, since debugging the API responses isn't exactly an easy task. For the student who you think get too many results, what happens if you act as one of those students in the UI and try to access one of the assignments you don't think they should be assigned? If they can access the assignment page in the UI, that would then rule out the API specifically as a problem and point to something else.
I'm wondering if there are perhaps some additional concluded enrollments for these handful of students (in different sections) giving them access to more than their current/active section role would. It's only a theory in my head right now, but maybe something you haven't explored yet.
-Chris
When I use the Canvas masquerade to see what it looks like for a student on the UI, those spurious assignments don't appear at all (not on their Calendar, Modules, or Grades pages). Likewise, they aren't showing up in the gradebook for the teacher's account, and everyone appears to be in their correct sections (with no lingering enrollments hiding in those sections).
Be as it may, it might help to file a case to see if Instructure Engineering does or does not see the get request for the assignment list endpoint returning all the assignments (assigned or not) for the entire course for a particular student as a bug in the API itself. Once that is vetted, you may find that your original approach could be successful. You could point them to this discussion thread in the community.
Thanks for all your help.
To participate in the Instructure Community, you need to sign up or log in:
Sign In