Skip to content

Qualtrics-gated teacher onboarding (studies app) - #58

Open
hcientist wants to merge 1 commit into
mainfrom
qualtrics_onboarding
Open

hcientist wants to merge 1 commit into
mainfrom
qualtrics_onboarding

Conversation

@hcientist

Copy link
Copy Markdown
Member

Implements Lab-Lab-Lab/cloud-architecture-dev-ops#11.

Researcher flow

  1. In Django admin, Study participants → Add: enter the teacher's email and the study, then add rows of pieces with the activities to use for each.
  2. On save, the teacher's account is created if needed: no usable password yet, added to the Teacher group, email marked verified. The teacher is then emailed that study's Qualtrics survey link, carrying an opaque pid.
  3. Qualtrics posts consent to /api/qualtrics/{slug}/consent, then redirects to /s/{slug}/onboard?pid=…. If consent is on record and the teacher has no password, they're sent to allauth's set-password page.
  4. When the teacher creates a course, their planned pieces and activities are assigned to it, as long as consent is on record.

What's in it

  • New teleband.studies app with three models:
    • Study: one row per study, with Qualtrics IDs, the env var name of its secret, consent version, and a JSON config.
    • StudyParticipant: one row per person per study, keyed by pid. Named this way so it isn't confused with courses' Enrollment.
    • PlannedPiece: the pieces and activities chosen for a teacher.
  • Qualtrics callbacks (consent, declined):
    • the study must exist and be recruiting
    • X-Study-Secret is compared in constant time before the body is read; the env var can hold comma-separated values for rotation
    • the pid must belong to that study
    • repeated calls are idempotent
    • condition is assigned by the app (balanced) or by Qualtrics (validated against the study's list)
  • Participant pages:
    • /s/{slug}/join: eligibility (exclude_if_enrolled_in), max_enrollment, reuse of an unfinished sign-up, optional anonymous entry
    • /s/{slug}/onboard: checks for about 15s, then shows a "Check again" button
    • /s/{slug}/withdraw: logged-in participant withdraws
  • Admin action to resend invitations to pending participants.
  • New setting STUDIES_APP_HOME_URL (env var): where enrolled users who already have a password are sent.

Notes for reviewers

  • The onboard link works as a set-password link for a teacher who hasn't set one yet. That's the same trust model as a password-reset email, and it stops working once a password is set.
  • withdraw uses a Django login session; the frontend would need an API version.
  • Not included: verifying each consent against the Qualtrics API, the nightly job for participants still pending, middleware restricting each study's pages, and post-complete callbacks.

Testing

  • 20 new tests in teleband/studies/tests/ pass.
  • teleband/users/tests/test_admin.py::test_add and test_drf_views.py::test_me fail, but they fail the same way on main.

🤖 Generated with Claude Code

Researchers invite a teacher from Django admin (email + study + pieces and
activities per piece). The teacher is emailed that study's Qualtrics survey
link carrying an opaque per-study pid. Qualtrics reports consent server-to-
server (per-study shared secret), then redirects to /s/{slug}/onboard, which
sends a consented teacher without a password to allauth's set-password page.
Planned pieces/activities are assigned to courses the teacher creates.

Implements Lab-Lab-Lab/cloud-architecture-dev-ops#11.

Co-Authored-By: Claude Opus 5.5 <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