Skip to content

Commit

Permalink
Use effective student ID when publishing grading
Browse files Browse the repository at this point in the history
  • Loading branch information
RichDom2185 committed Oct 4, 2024
1 parent 096b728 commit 28fc352
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/cadet/assessments/assessments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule Cadet.Assessments do
Notification,
Notifications,
User,
Teams,
Team,
TeamMember,
CourseRegistration,
Expand Down Expand Up @@ -1211,6 +1212,13 @@ defmodule Cadet.Assessments do
# allows staff to unpublish own assessment
bypass = role in @bypass_closed_roles and submission.student_id == course_reg_id

effective_student_id =
if is_nil(submission.student_id) do
Teams.get_first_member(submission.team_id).student_id
else
submission.student_id
end

with {:submission_found?, true} <- {:submission_found?, is_map(submission)},
{:status, :submitted} <- {:status, submission.status},
{:is_manually_graded?, true} <-
Expand All @@ -1219,7 +1227,7 @@ defmodule Cadet.Assessments do
{:allowed_to_publish?, true} <-
{:allowed_to_publish?,
role == :admin or bypass or
Cadet.Accounts.Query.avenger_of?(cr, submission.student_id)} do
Cadet.Accounts.Query.avenger_of?(cr, effective_student_id)} do
{:ok, submission}
end
end
Expand Down

0 comments on commit 28fc352

Please sign in to comment.