Skip to content

Investigate and fix incorrect Canvas assignment due dates, add logging for overrides#451

Open
cycomachead wants to merge 1 commit into
mainfrom
cycomachead/144-fix-canvas-due-dates-logging/1
Open

Investigate and fix incorrect Canvas assignment due dates, add logging for overrides#451
cycomachead wants to merge 1 commit into
mainfrom
cycomachead/144-fix-canvas-due-dates-logging/1

Conversation

@cycomachead

Copy link
Copy Markdown
Contributor

General Info

Changes

Canvas omits the all_dates array (the source of the base due date) from its API response when an assignment has more than ~25 overrides. Without a base date, the sync was falling back to the root-level due_at/lock_at fields, which Canvas can populate from an override — resulting in due dates that are later than the real assignment due date.

Root cause fix: Skip overwriting due_date and late_due_date on subsequent syncs when an assignment has ≥ 25 overrides and no explicit base date is present. New assignments are unaffected (dates are always set on first sync), and non-Canvas LMS integrations (e.g. Gradescope) are unaffected via safe defaults in BaseAssignment.

Key changes:

  • SyncAllCourseAssignmentsJob: Added OVERRIDE_DATE_LIMIT = 25 constant and skip_due_date_update? guard. Name and other fields continue to sync normally even when date updates are skipped.
  • Lmss::Canvas::Assignment: Exposes overrides_count (size of the overrides array) and base_date? (whether Canvas returned an explicit base date).
  • Lmss::BaseAssignment: Added default implementations (overrides_count = 0, base_date? = true) so other LMS integrations are never affected by the guard.
  • Logging: A warn is emitted when a due date update is skipped (showing stored vs. Canvas-reported dates). An info is emitted for any override-bearing assignment whose dates are updated, so we can continue monitoring for incorrect dates.
  • CanvasSpecHelpers: Fixed build_canvas_assignment so passing base_date: nil correctly models Canvas omitting the base date, rather than deriving one.

Testing

Added RSpec contexts to sync_all_course_assignments_job_spec.rb covering:

  • Many overrides + no base_date: Existing assignment's due dates are preserved on re-sync; name still updates. New assignment still gets dates set. Skip is logged with a warn.
  • Many overrides + base_date present: Due dates are correctly updated from the base date even when override count is high.

All new and existing specs should be run against a database-backed environment before merging.

Documentation

No additional documentation required.

Checklist

  • Name of branch corresponds to story

Superconductor Ticket Implementation | App Preview | Guided Review

Canvas omits the base date from the API response when an assignment has
more than 25 overrides, causing the sync to fall back to incorrect
override-derived dates.

- Skip updating due dates on subsequent syncs if an assignment has >= 25
  overrides and no explicit base date is present.
- Add logging to track skipped updates and monitor override data.
- Update Lmss::Canvas::Assignment to track override counts and base
  date presence.
- Ensure non-Canvas LMS integrations remain unaffected.

Co-authored-by: Claude Code <noreply@anthropic.com>
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