Skip to content

Commit 5585c16

Browse files
committed
fix: #504 display quizdata response in amp quiz
1 parent 08eea60 commit 5585c16

3 files changed

Lines changed: 119 additions & 6 deletions

File tree

django_email_learning/personalised/api/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ def post(self, request, *args, **kwargs): # type: ignore[no-untyped-def]
489489
)
490490
if (
491491
not source_origin
492-
or urllib.parse.unquote(source_origin) != email_sender_service.from_email
492+
or urllib.parse.unquote(source_origin).lower()
493+
not in email_sender_service.from_email.lower()
493494
):
494495
return JsonResponse(
495496
{

django_email_learning/templates/emails/quiz_amp.html

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,75 @@
4545
display: block;
4646
padding: 4px;
4747
}
48+
.quiz-feedback {
49+
margin-top: 20px;
50+
padding: 16px;
51+
border: 1px solid #e6e6e6;
52+
border-radius: 8px;
53+
background: #fafafa;
54+
}
55+
.quiz-feedback-title {
56+
margin: 0 0 12px;
57+
font-weight: 700;
58+
font-size: 18px;
59+
}
60+
.quiz-feedback-question {
61+
margin-bottom: 16px;
62+
padding-bottom: 14px;
63+
border-bottom: 1px solid #ececec;
64+
}
65+
.quiz-feedback-question:last-child {
66+
margin-bottom: 0;
67+
padding-bottom: 0;
68+
border-bottom: none;
69+
}
70+
.quiz-feedback-answer {
71+
display: block;
72+
padding: 8px 10px;
73+
border: 1px solid #ddd;
74+
border-radius: 6px;
75+
margin: 6px 0;
76+
line-height: 1.4;
77+
}
78+
.quiz-feedback-answer-icon {
79+
display: inline-block;
80+
width: 20px;
81+
font-weight: 700;
82+
}
83+
.quiz-feedback-answer-text {
84+
display: inline;
85+
}
86+
.quiz-feedback-chip {
87+
display: inline-block;
88+
margin-left: 8px;
89+
padding: 1px 6px;
90+
border-radius: 10px;
91+
font-size: 12px;
92+
line-height: 1.4;
93+
border: 1px solid #3d8b40;
94+
color: #2f6f33;
95+
background: #e6f4ea;
96+
}
97+
.quiz-feedback-answer-correct-selected {
98+
border-color: #4caf50;
99+
background: #d9f2db;
100+
color: #1f5f22;
101+
}
102+
.quiz-feedback-answer-correct {
103+
border-color: #82c784;
104+
background: #eef8ef;
105+
color: #2f6f33;
106+
}
107+
.quiz-feedback-answer-selected-wrong {
108+
border-color: #ef9a9a;
109+
background: #fdecec;
110+
color: #b71c1c;
111+
}
112+
.quiz-feedback-answer-neutral {
113+
border-color: #ddd;
114+
background: #f5f5f5;
115+
color: #555;
116+
}
48117
{% endblock %}
49118

50119
{% block content %}
@@ -93,10 +162,6 @@ <h2 class="email-title">{{ quiz.title }}</h2>
93162
</p>
94163
</div>
95164

96-
<div hidden [hidden]="!formState.submitted">
97-
{% translate "Your answers have been submitted. Please wait while we calculate your score." %}
98-
</div>
99-
100165
<div submit-success>
101166
<template type="amp-mustache">
102167
{% templatetag openvariable %}message{% templatetag closevariable %}<br />
@@ -107,6 +172,53 @@ <h2 class="email-title">{{ quiz.title }}</h2>
107172
</p>
108173
{% templatetag openvariable %}/is_invalidated{% templatetag closevariable %}
109174
{% templatetag openvariable %}/passed{% templatetag closevariable %}
175+
176+
{% templatetag openvariable %}#quiz_data{% templatetag closevariable %}
177+
<div class="quiz-feedback">
178+
<p class="quiz-feedback-title">{% templatetag openvariable %}title{% templatetag closevariable %}</p>
179+
{% templatetag openvariable %}#questions{% templatetag closevariable %}
180+
<div class="quiz-feedback-question">
181+
<p class="question">{% templatetag openvariable %}text{% templatetag closevariable %}</p>
182+
183+
{% templatetag openvariable %}#answers{% templatetag closevariable %}
184+
{% templatetag openvariable %}#is_correct{% templatetag closevariable %}
185+
{% templatetag openvariable %}#user_selected{% templatetag closevariable %}
186+
<div class="quiz-feedback-answer quiz-feedback-answer-correct-selected">
187+
<span class="quiz-feedback-answer-icon">&#10003;</span>
188+
<span class="quiz-feedback-answer-text">{% templatetag openvariable %}text{% templatetag closevariable %}</span>
189+
<span class="quiz-feedback-chip">{% translate "Correct answer" %}</span>
190+
</div>
191+
{% templatetag openvariable %}/user_selected{% templatetag closevariable %}
192+
193+
{% templatetag openvariable %}^user_selected{% templatetag closevariable %}
194+
<div class="quiz-feedback-answer quiz-feedback-answer-correct">
195+
<span class="quiz-feedback-answer-icon">&#10003;</span>
196+
<span class="quiz-feedback-answer-text">{% templatetag openvariable %}text{% templatetag closevariable %}</span>
197+
<span class="quiz-feedback-chip">{% translate "Correct answer" %}</span>
198+
</div>
199+
{% templatetag openvariable %}/user_selected{% templatetag closevariable %}
200+
{% templatetag openvariable %}/is_correct{% templatetag closevariable %}
201+
202+
{% templatetag openvariable %}^is_correct{% templatetag closevariable %}
203+
{% templatetag openvariable %}#user_selected{% templatetag closevariable %}
204+
<div class="quiz-feedback-answer quiz-feedback-answer-selected-wrong">
205+
<span class="quiz-feedback-answer-icon">&#10007;</span>
206+
<span class="quiz-feedback-answer-text">{% templatetag openvariable %}text{% templatetag closevariable %}</span>
207+
</div>
208+
{% templatetag openvariable %}/user_selected{% templatetag closevariable %}
209+
210+
{% templatetag openvariable %}^user_selected{% templatetag closevariable %}
211+
<div class="quiz-feedback-answer quiz-feedback-answer-neutral">
212+
<span class="quiz-feedback-answer-icon">&#9675;</span>
213+
<span class="quiz-feedback-answer-text">{% templatetag openvariable %}text{% templatetag closevariable %}</span>
214+
</div>
215+
{% templatetag openvariable %}/user_selected{% templatetag closevariable %}
216+
{% templatetag openvariable %}/is_correct{% templatetag closevariable %}
217+
{% templatetag openvariable %}/answers{% templatetag closevariable %}
218+
</div>
219+
{% templatetag openvariable %}/questions{% templatetag closevariable %}
220+
</div>
221+
{% templatetag openvariable %}/quiz_data{% templatetag closevariable %}
110222
</template>
111223
</div>
112224

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "django-email-learning"
3-
version = "0.5.6"
3+
version = "0.5.7"
44
description = "A platform for creating and delivering learning materials via email within a Django application. It provides tools for content management, user role-based administration, and scheduler integration for automated content delivery."
55
authors = [
66
{name = "Payam Najafizadeh",email = "payam.nj@gmail.com"}

0 commit comments

Comments
 (0)