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.
Part of #727.
Summary
Add a
mailto:reply link to the quiz email — for courses whoseCourse.imap_connectionis 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 rendersemails/quiz.txt,emails/quiz.html, and (if AMP-enabled)emails/quiz_amp.html.mailto_link, computed only whencontent.course.imap_connection_idis set.emails/quiz.htmlandemails/quiz.txt(both are non-interactive fallbacks today — a plain "click here" link).Behavior
quiz <token>— sametokenvalue already used to buildlink(seeDeliverySchedule.generate_link(),django_email_learning/models/deliveries.py).quiz.questionsfiltered toquestion_ids(same filteringemails/quiz_amp.htmlalready does so the mailto body matches exactly what an AMP-capable client would show), render the question text and its answers as[ ]checkbox lines. Usequestion.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.mailto:href (line breaks, special characters).mailto:body prefill well either, and the web link is the universal fallback).Out of scope (see #727 for the other half)
Tests
tests/services/command_models/test_send_quiz_command.py: assert the mailto link/subject/body appear in the rendered email when the course has animap_connection, and are absent when it doesn't.is_multiple_choice() == Trueand one withFalseto confirm the phrasing differs correctly.