Skip to content

Add reg-canvas: Canvas API support for grades, roster and content - #41

Merged
agiacalone merged 1 commit into
mainfrom
feat/canvas-api
Oct 21, 2026
Merged

agiacalone merged 1 commit into
mainfrom
feat/canvas-api

Conversation

@agiacalone

Copy link
Copy Markdown
Owner

Summary

Adds reg-canvas, so lectern can use the Canvas API instead of manual exports, uploads and pastes. CSULB ATS issued a personal token on 2026-10-21.

Read commands

  • whoami checks the token.
  • courses --bind writes each section's canvas.course-id into its class note. When a class number recurs across years, the Canvas term name decides.
  • grades-export writes the gradebook in Canvas's own export layout, so reg-lms-grades-import and reg-gradebook export-canvas --template take it unchanged. The per-group subtotal columns are left out; no tool reads them.
  • roster-check compares Canvas enrolments with the registrar roster, for census week.

Write commands (each is a dry run until --apply)

  • grades-push applies an overlay CSV, changed cells only. A blank cell never clears a grade, and a file whose assignment IDs belong to another course is refused.
  • announce posts announcements, such as the files reg-c50 post writes.
  • discussion and assignment create items unpublished. assignment --lab N takes its name and points from the vault.
  • syllabus refuses a file without the class note's serial.
  • The three content commands skip a title that already exists.

Token and data handling

  • canvas_api is the only module that reads the token. It reads ~/.config/lectern/canvas-token and refuses the file if group or other can read it. It never takes the token from argv or the environment.
  • The token is sent only to the configured host. Redirects are refused, because urllib would forward the Authorization header. The token is scrubbed from every error.
  • Standard library only, so runtime dependencies are unchanged.
  • Scores come from the submissions endpoint, but only score fields are kept. Submission content is dropped on arrival. Exports are written mode 600.

Docs

New runbook docs/canvas-api.md: how the pieces fit, setup, every command, data scope and troubleshooting. The README, SKILL.md, AGENTS.md and docs/canvas-grades-workflow.md describe the API path, and each repeats the dry-run rule on purpose.

Testing

  • pytest: 680 passed, including 28 new tests in tests/test_canvas.py (fake transport, no network).
  • Live reads on 2026-10-21 against the three Fa26 sections. The 326 §03 export matched the last manual export on all 71 students and every identity column. Score differences came from grading done since then.
  • Live writes in the sandbox course: an unpublished discussion and an unpublished assignment, both checked and then deleted.
  • grades-push and announce have unit tests only. The sandbox has no students to grade, and an announcement notifies students immediately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N64GRxn3cQDJKAJLdfrso2

CSULB ATS issued a personal Canvas token on 2026-10-21. Until now every
Canvas step was a manual export, upload or paste.

canvas_api is the only module that reads the token. It reads it from a
mode-600 file, sends it only to the configured host, refuses redirects
and scrubs it from errors. It uses only the standard library.

reg-canvas adds read commands (whoami, courses --bind, grades-export,
roster-check) and write commands (grades-push, announce, discussion,
assignment, syllabus). Every write is a dry run until --apply.
grades-export keeps only score fields from the submissions endpoint and
writes exports mode 600.

The README, SKILL.md, AGENTS.md and docs describe the API path. The
dry-run rule is repeated in each of them on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N64GRxn3cQDJKAJLdfrso2
@agiacalone
agiacalone merged commit 1455200 into main Oct 21, 2026
4 checks passed
@agiacalone
agiacalone deleted the feat/canvas-api branch October 21, 2026 17:19
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.

1 participant