From d46fc8b3fb4a0fc99f6eb4742ff8ee3548556135 Mon Sep 17 00:00:00 2001 From: GabrielCWT <77312579+GabrielCWT@users.noreply.github.com> Date: Sat, 31 Aug 2024 10:58:00 +0800 Subject: [PATCH] feat: Add check to notification creation --- lib/cadet/assessments/assessments.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/cadet/assessments/assessments.ex b/lib/cadet/assessments/assessments.ex index 980736479..4ce8dec85 100644 --- a/lib/cadet/assessments/assessments.ex +++ b/lib/cadet/assessments/assessments.ex @@ -1021,7 +1021,12 @@ defmodule Cadet.Assessments do with {:status, :attempted} <- {:status, submission.status}, {:ok, updated_submission} <- update_submission_status(submission) do # Couple with update_submission_status and update_xp_bonus to ensure notification is sent - Notifications.write_notification_when_student_submits(submission) + submission = Repo.preload(submission, assessment: [:config]) + + if submission.assessment.config.is_manually_graded do + Notifications.write_notification_when_student_submits(submission) + end + # Send email notification to avenger %{notification_type: "assessment_submission", submission_id: updated_submission.id} |> Cadet.Workers.NotificationWorker.new()