Skip to content

Generate mailto: reply link with prefilled quiz body in quiz emails #728

Description

@payamnj

Part of #727.

Summary

Add a mailto: reply link to the quiz email — for courses whose Course.imap_connection is set — with a URL-encoded, prefilled subject and body so a learner can answer and submit a quiz by replying to the email, without needing an AMP-capable client.

Where this plugs in

  • SendQuizCommand (django_email_learning/services/command_models/send_quiz_command.py) builds the render context (quiz, link, question_ids, token, etc.) and renders emails/quiz.txt, emails/quiz.html, and (if AMP-enabled) emails/quiz_amp.html.
  • Add a new context value, e.g. mailto_link, computed only when content.course.imap_connection_id is set.
  • Render into both emails/quiz.html and emails/quiz.txt (both are non-interactive fallbacks today — a plain "click here" link).

Behavior

  • Subject: quiz <token> — same token value already used to build link (see DeliverySchedule.generate_link(), django_email_learning/models/deliveries.py).
  • Body: for each question in quiz.questions filtered to question_ids (same filtering emails/quiz_amp.html already does so the mailto body matches exactly what an AMP-capable client would show), render the question text and its answers as [ ] checkbox lines. Use question.is_multiple_choice() to phrase the instruction per question ("select the correct answer" vs. "select all correct answers"). End with a short instruction to mark [x] and reply/send.
  • URL-encode subject and body appropriately for a mailto: href (line breaks, special characters).
  • Keep the existing web link as-is in both templates — the mailto link is additive, not a replacement (some clients don't support mailto: body prefill well either, and the web link is the universal fallback).

Out of scope (see #727 for the other half)

  • The IMAP-side parsing/handling of the reply itself.

Tests

  • Extend tests/services/command_models/test_send_quiz_command.py: assert the mailto link/subject/body appear in the rendered email when the course has an imap_connection, and are absent when it doesn't.
  • Cover a question with is_multiple_choice() == True and one with False to confirm the phrasing differs correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions