fix(tests/essays): stable share links, live teacher-side sync, external media CSP - #531
Merged
Merged
Conversation
…al media CSP Stabilize assignment share links across modal reopens and close several student→teacher sync/parse gaps found while auditing the hand-in path. - TestAssignmentModal: reconcile teacherKeys against persisted test_assignments rows on open (gated so auto-save can't race and duplicate a row). Reopening now re-serves the SAME link and upserts the SAME row instead of minting a new nanoid — which handed out a different URL each time, piled up duplicate rows, and (for a placement-generator test) orphaned a student's in-progress placement_sessions run, keyed on the assignment id. - GradeStudent essay modal: reuse this student's own persisted teacherKey so its link is stable too (guarded to the student's own row, never the fallback). - useOnlineEssaySubmissions: refetch on tab focus/visibility. essay_submissions is not in the realtime publication (unlike student_tests), so a student handing in online never updated the teacher's roster badges until a reload. - useLiveSessionTelemetry: gate the best-effort live-event broadcast on the channel actually being joined, silencing realtime-js's repeated "send() is falling back to REST API" warning on pre-join proctor events (events are buffered and flushed at submit regardless, so nothing is lost). - CSP (deploy/docker configs): add media-src and widen img-src to https so external audio/image stimulus URLs (e.g. archive.org) load — the configs had no media-src, so <audio> fell back to default-src 'self' and all external media was blocked outright. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ks-test-save-c0476d # Conflicts: # deploy/apache-hestiacp.conf # deploy/apache-virtualmin.conf # deploy/nginx-hestiacp.conf # deploy/nginx-virtualmin.conf # docker/nginx.conf # docker/nginx.prod.conf # src/hooks/useLiveSessionTelemetry.ts
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Summary
Audits the student→teacher hand-in path and fixes link-stability and sync/parse desyncs found along the way.
1. Stable assignment share links (tests + essays)
TestAssignmentModalminted a freshnanoidteacherKey per student on every mount. BecausesaveTestAssignmentupserts byid, reopening the modal handed out a different URL each time, piled up duplicatetest_assignmentsrows, and — worst case — orphaned a placement-generator student's in-progressplacement_sessionsrun (keyed on the assignment id). Now reconciles keys against the persisted rows on open (viafetchTestAssignmentTeacherKeys), gated so the DB auto-save can't race ahead and create a duplicate. Reopening re-serves the same link and upserts the same row.2. Teacher-side sync/parse audit
student_testsis realtime-published + subscribed + partial-hydratable, and generator/placement submissions render viaaskedQuestionSnapshots+levelPath. No change needed.essay_submissionsis not in the realtime publication anduseOnlineEssaySubmissionsfetched once on mount, so a student handing in online never refreshed the teacher's roster badges. Now refetches on tab focus/visibilitychange.3.
Realtime send() … falling back to REST APIwarning (student side)Benign (delivery still succeeds over REST), but noisy — proctor events fire it before the channel joins.
useLiveSessionTelemetrynow gates the best-effort live-event broadcast on the channel being joined; events are buffered and flushed at submit regardless.4. External media (archive.org audio) blocked by CSP
The deploy/docker CSPs had no
media-src, so<audio>fell back todefault-src 'self'and all external audio/image stimulus URLs were blocked. Addedmedia-src 'self' https: data: blob:and widenedimg-srctohttps:across all 7 configs.Reviewer notes
deploy/.htaccessis auto-deployed by thedeploy-hestiacpjob; the*-hestiacp.conf/*-virtualmin.confvhost templates are not.Tests
TestAssignmentModaltest for persisted-key reuse; updated the two modal test mocks withfetchTestAssignmentTeacherKeys.🤖 Generated with Claude Code