Skip to content

Commit b8860d7

Browse files
committed
fix: #157 fix second quiz submission event
1 parent f340730 commit b8860d7

3 files changed

Lines changed: 19 additions & 24 deletions

File tree

django_email_learning/platform/api/serializers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,11 @@ def from_django_model(enrollment: Enrollment) -> "EnrollmentResponse":
450450
)
451451
)
452452
for delivery in enrollment.content_deliveries.all(): # type: ignore[attr-defined]
453+
schedule_no = 0
453454
for schedule in delivery.delivery_schedules.filter(
454455
status=DeliveryStatus.DELIVERED
455456
):
457+
schedule_no += 1
456458
events.append(
457459
Event(
458460
type=EventType.CONTENT_SENT,
@@ -471,12 +473,13 @@ def from_django_model(enrollment: Enrollment) -> "EnrollmentResponse":
471473
quiz_attempts = delivery.quiz_submissions.all().order_by(
472474
"submitted_at"
473475
)
474-
if not schedule.failed_attempts:
476+
attempt = None
477+
if schedule_no == 1:
475478
attempt = quiz_attempts.first()
476479
attempt_number = 1
477-
else:
478-
attempt_number = schedule.failed_attempts + 1
479-
attempt = quiz_attempts[attempt_number - 1 : 1].first()
480+
elif schedule_no > 1:
481+
attempt_number = schedule_no
482+
attempt = quiz_attempts[attempt_number - 1 :].first()
480483
if attempt:
481484
events.append(
482485
Event(

django_email_learning/templates/emails/quiz.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{% translate "Dear Learner," %}
55

6-
{% blocktranslate with with deadline_days=quiz.deadline_days %}Your quiz is now available for completion. You have {{ deadline_days }} days from today to submit your responses.{% endblocktranslate %}
6+
{% blocktranslate with deadline_days=quiz.deadline_days %}Your quiz is now available for completion. You have {{ deadline_days }} days from today to submit your responses.{% endblocktranslate %}
77

88
{% blocktranslate with score=quiz.required_score %}To successfully pass this quiz, you must achieve a minimum score of {{ score }}.{% endblocktranslate %}
99

frontend/package-lock.json

Lines changed: 11 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)