Skip to content

Comments

Fix user retrieval to use Canvas API instead of Course API#237

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-2aeb7edf-ec39-4318-bf0e-13774400efc4
Draft

Fix user retrieval to use Canvas API instead of Course API#237
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-2aeb7edf-ec39-4318-bf0e-13774400efc4

Conversation

Copy link
Contributor

Copilot AI commented Oct 3, 2025

Problem

The code was using course.get_user() to retrieve user objects when formatting submission information. This method requires the user to be enrolled in the course, which causes failures when trying to retrieve information about teachers or teaching assistants who have been removed from the course but still have graded submissions in the system.

Solution

Changed the code to use canvas.get_user() instead of course.get_user(). The key difference:

  • course.get_user() calls /api/v1/courses/:course_id/users/:id - requires course enrollment
  • canvas.get_user() calls /api/v1/users/:id - retrieves any user from the Canvas instance

Changes

Modified src/canvaslms/cli/submissions.nw:

  1. Updated format_submission() function to accept a canvas parameter and use it to retrieve the student user object via canvas.get_user(submission.user_id)

  2. Updated resolve_grader() function to accept a canvas parameter and use it to retrieve the grader user object via canvas.get_user(submission.grader_id)

  3. Updated all call sites (3 locations) to pass the canvas parameter through the function call chain

Both methods have identical signatures and return types, so this change maintains backward compatibility while expanding functionality to handle edge cases where users are no longer enrolled in the course.

Impact

  • Teachers and TAs who have been removed from courses can now be properly identified in submission metadata
  • More robust handling of grading workflows
  • No breaking changes to existing functionality

Fixes #236

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Request users from Canvas, instead of course</issue_title>
<issue_description>The only option we have as the code is written currently, is to try to get the
user from the course ([[course.get_user]]). But we should really get the user
from a Canvas object, [[canvas.get_user]].

If using [[get_user(...)]] on a course object, then the user must exist in the
course. However, that's not necessarily true. So we should get it from a
[[Canvas]] object, that is, from the system rather than just the course.

But as mentioned, right now we can only do it through the course. This isn't a
problem as long as none of the teachers or teaching assistants are removed.
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #236

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: dbosk <237222+dbosk@users.noreply.github.com>
Copilot AI changed the title [WIP] Request users from Canvas, instead of course Fix user retrieval to use Canvas API instead of Course API Oct 3, 2025
Copilot AI requested a review from dbosk October 3, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request users from Canvas, instead of course

2 participants