Skip to content

Commit 28fc352

Browse files
committed
Use effective student ID when publishing grading
1 parent 096b728 commit 28fc352

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/cadet/assessments/assessments.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ defmodule Cadet.Assessments do
1212
Notification,
1313
Notifications,
1414
User,
15+
Teams,
1516
Team,
1617
TeamMember,
1718
CourseRegistration,
@@ -1211,6 +1212,13 @@ defmodule Cadet.Assessments do
12111212
# allows staff to unpublish own assessment
12121213
bypass = role in @bypass_closed_roles and submission.student_id == course_reg_id
12131214

1215+
effective_student_id =
1216+
if is_nil(submission.student_id) do
1217+
Teams.get_first_member(submission.team_id).student_id
1218+
else
1219+
submission.student_id
1220+
end
1221+
12141222
with {:submission_found?, true} <- {:submission_found?, is_map(submission)},
12151223
{:status, :submitted} <- {:status, submission.status},
12161224
{:is_manually_graded?, true} <-
@@ -1219,7 +1227,7 @@ defmodule Cadet.Assessments do
12191227
{:allowed_to_publish?, true} <-
12201228
{:allowed_to_publish?,
12211229
role == :admin or bypass or
1222-
Cadet.Accounts.Query.avenger_of?(cr, submission.student_id)} do
1230+
Cadet.Accounts.Query.avenger_of?(cr, effective_student_id)} do
12231231
{:ok, submission}
12241232
end
12251233
end

0 commit comments

Comments
 (0)