Skip to content

Add subcommand to enroll users in a course#227

Draft
dbosk wants to merge 1 commit intomasterfrom
enroll-users-in-course
Draft

Add subcommand to enroll users in a course#227
dbosk wants to merge 1 commit intomasterfrom
enroll-users-in-course

Conversation

@dbosk
Copy link
Owner

@dbosk dbosk commented Sep 15, 2025

No description provided.

@dbosk dbosk requested a review from Copilot September 15, 2025 07:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new subcommand to the canvaslms CLI tool for enrolling users in Canvas courses. The functionality allows administrators to enroll users by specifying their Canvas ID, SIS user ID, integration ID, or email address along with their desired role.

Key changes:

  • Added enroll subcommand with support for multiple user identifier types
  • Implemented user lookup by email address through Canvas accounts API
  • Added role mapping for Canvas enrollment types (student, teacher, TA, observer)

course.enroll_user(user,
enrollment_type=role)
except canvasapi.exceptions.CanvasException as err:
import pdb; pdb.set_trace()
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug breakpoint should not be included in production code. Remove this line before merging.

Suggested change
import pdb; pdb.set_trace()

Copilot uses AI. Check for mistakes.
params={"search_term": email}
)
except canvasapi.exceptions.CanvasException as err:
import pdb; pdb.set_trace()
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug breakpoint should not be included in production code. Remove this line before merging.

Suggested change
import pdb; pdb.set_trace()

Copilot uses AI. Check for mistakes.
We want to ensure that we only have one user.
So we should have gotten a JSON list with one user.
<<get [[user]] from [[canvas]]>>=
respone_json = response.json()
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable name has a typo: 'respone_json' should be 'response_json'.

Suggested change
respone_json = response.json()
response_json = response.json()

Copilot uses AI. Check for mistakes.
We want to ensure that we only have one user.
So we should have gotten a JSON list with one user.
<<get [[user]] from [[canvas]]>>=
respone_json = response.json()
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using undefined variable 'response_json' due to the typo in line 895. This will cause a NameError at runtime.

Suggested change
respone_json = response.json()
response_json = response.json()

Copilot uses AI. Check for mistakes.
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.

2 participants