Skip to content

Commit

Permalink
fix: Fix creation of empty submission for teams
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielCWT committed Oct 14, 2024
1 parent de0f910 commit 8796fb7
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions lib/cadet/jobs/autograder/grading_job.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,28 @@ defmodule Cadet.Autograder.GradingJob do
|> where([_, tm], tm.student_id == ^student_id)
|> Repo.one()

if !team do
# Student is not in any team
# Create new team just for the student
team =
%Team{}
|> Team.changeset(%{
assessment_id: assessment.id
team =
if !team do
# Student is not in any team
# Create new team just for the student
team =
%Team{}
|> Team.changeset(%{
assessment_id: assessment.id
})
|> Repo.insert!()

%TeamMember{}
|> TeamMember.changeset(%{
team_id: team.id,
student_id: student_id
})
|> Repo.insert!()

%TeamMember{}
|> TeamMember.changeset(%{
team_id: team.id,
student_id: student_id
})
|> Repo.insert!()
end
team
else
team
end

%Submission{}
|> Submission.changeset(%{
Expand Down

0 comments on commit 8796fb7

Please sign in to comment.