From d867927ac0ce101235da19803dd2cca948946c39 Mon Sep 17 00:00:00 2001 From: Gabriel Chang <77312579+GabrielCWT@users.noreply.github.com> Date: Sat, 31 Aug 2024 11:05:14 +0800 Subject: [PATCH] feat: Add check to notification creation (#1167) --- 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()