Skip to content

feat: Add quiz_created and quiz_updated live events - #2646

Open
jasonfill wants to merge 2 commits into
instructure:masterfrom
SmarterServices:feature/quiz-assignment-updated-live-event
Open

feat: Add quiz_created and quiz_updated live events#2646
jasonfill wants to merge 2 commits into
instructure:masterfrom
SmarterServices:feature/quiz-assignment-updated-live-event

Conversation

@jasonfill

Copy link
Copy Markdown

Note

This could not be fully tested due to limited access to the live event service via the open source distribution.

Summary

Emits live events when classic quizzes are created or when quiz settings/availability are modified. This is a dedicated quiz-level event rather than an extension of assignment_updated because:

  1. Not all quizzes have assignments — practice quizzes and ungraded surveys have no associated Assignment record, so assignment_updated would never fire for them.
  2. Quiz-specific fields don't exist on Assignment — settings like access_code, time_limit, shuffle_answers, ip_filter, require_lockdown_browser, etc. are quiz-only columns that assignment_updated has no awareness of.
  3. Availability date changes on the quiz need to be captured at the quiz level. When due_at, lock_at, or unlock_at change, the quiz pushes those to its associated assignment (which fires assignment_updated), but for non-graded quiz types this is the only event that fires.

Note: Adding new "Assign To" blocks (AssignmentOverrides) does NOT trigger quiz_updated — those are separate records and already emit assignment_override_created/assignment_override_updated events natively in Canvas.

Model callbacks

Quizzes::Quiz model additions:

  • after_save :fire_quiz_created_event — new records only, skips migrations, emits inside after_transaction_commit
  • after_save :fire_quiz_updated_event — fires when any field in QUIZ_EVENT_FIELDS changes, skips new records and migrations

QUIZ_EVENT_FIELDS (21 fields):

  • Quiz-specific settings: access_code, allowed_attempts, anonymous_submissions, cant_go_back, disable_timer_autosubmission, hide_correct_answers_at, hide_results, ip_filter, one_question_at_a_time, one_time_results, require_lockdown_browser, require_lockdown_browser_for_results, scoring_policy, show_correct_answers, show_correct_answers_at, show_correct_answers_last_attempt, shuffle_answers, time_limit
  • Availability dates: due_at, lock_at, unlock_at

Live event methods

  • Canvas::LiveEvents.quiz_created(quiz) / .quiz_updated(quiz) — shared payload via get_quiz_data with full quiz settings
  • access_code is emitted as a boolean (does not expose the actual code)

Data Services schemas

Canvas and Caliper event schemas added for both quiz_created and quiz_updated, registered in DataServicesEventsLoader under the "basic" category.

Files changed

File Status
app/models/quizzes/quiz.rb Modified
lib/canvas/live_events.rb Modified
doc/api/data_services/data_services_events_loader.rb Modified
doc/api/data_services/json/caliper/event-types/quiz_created.json New
doc/api/data_services/json/caliper/event-types/quiz_updated.json New
doc/api/data_services/json/canvas/event-types/quiz_created.json New
doc/api/data_services/json/canvas/event-types/quiz_updated.json New
spec/lib/canvas/live_events_spec.rb Modified
spec/models/quizzes/quiz_spec.rb Modified

Test plan

  • Create a classic quiz — verify quiz_created event fires with correct payload
  • Update quiz settings (time_limit, access_code, ip_filter) — verify quiz_updated event fires
  • Update availability dates (due_at, lock_at, unlock_at) — verify quiz_updated event fires
  • Update non-event fields (title) — verify no quiz_updated event
  • Verify access_code is emitted as boolean, not the actual code value
  • Verify no events fire during content migrations

jasonfill added 2 commits July 6, 2026 10:06
Emit live events when classic quizzes are created
or when quiz-specific settings are modified.

Includes Canvas and Caliper event schemas and
model callbacks with after_transaction_commit.

flag=none

test plan:
- create a classic quiz, verify quiz_created event
- update quiz settings (time_limit, access_code),
  verify quiz_updated event fires
- update non-quiz fields (title), verify no event
- verify access_code is emitted as boolean
Add due_at, lock_at, unlock_at to QUIZ_EVENT_FIELDS
so quiz_updated fires when availability changes.

flag=none

test plan:
- update due_at on a quiz, verify quiz_updated fires
- update lock_at/unlock_at, verify quiz_updated fires
- update title only, verify no event fires
@jasonfill jasonfill changed the title Feature/quiz assignment updated live event feat: Add quiz_created and quiz_updated live events Jul 6, 2026
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