feat: Add quiz_created and quiz_updated live events - #2646
Open
jasonfill wants to merge 2 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_updatedbecause:assignment_updatedwould never fire for them.access_code,time_limit,shuffle_answers,ip_filter,require_lockdown_browser, etc. are quiz-only columns thatassignment_updatedhas no awareness of.due_at,lock_at, orunlock_atchange, the quiz pushes those to its associated assignment (which firesassignment_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 emitassignment_override_created/assignment_override_updatedevents natively in Canvas.Model callbacks
Quizzes::Quizmodel additions:after_save :fire_quiz_created_event— new records only, skips migrations, emits insideafter_transaction_commitafter_save :fire_quiz_updated_event— fires when any field inQUIZ_EVENT_FIELDSchanges, skips new records and migrationsQUIZ_EVENT_FIELDS(21 fields):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_limitdue_at,lock_at,unlock_atLive event methods
Canvas::LiveEvents.quiz_created(quiz)/.quiz_updated(quiz)— shared payload viaget_quiz_datawith full quiz settingsaccess_codeis emitted as a boolean (does not expose the actual code)Data Services schemas
Canvas and Caliper event schemas added for both
quiz_createdandquiz_updated, registered inDataServicesEventsLoaderunder the"basic"category.Files changed
app/models/quizzes/quiz.rblib/canvas/live_events.rbdoc/api/data_services/data_services_events_loader.rbdoc/api/data_services/json/caliper/event-types/quiz_created.jsondoc/api/data_services/json/caliper/event-types/quiz_updated.jsondoc/api/data_services/json/canvas/event-types/quiz_created.jsondoc/api/data_services/json/canvas/event-types/quiz_updated.jsonspec/lib/canvas/live_events_spec.rbspec/models/quizzes/quiz_spec.rbTest plan
quiz_createdevent fires with correct payloadtime_limit,access_code,ip_filter) — verifyquiz_updatedevent firesdue_at,lock_at,unlock_at) — verifyquiz_updatedevent firestitle) — verify noquiz_updatedeventaccess_codeis emitted as boolean, not the actual code value