Skip to content

Commit

Permalink
fix: Auto publish for non-autograded assessments (#1157)
Browse files Browse the repository at this point in the history
* fix: Auto publish for non-autograded assessments

* chore: Formatting
  • Loading branch information
GabrielCWT authored Aug 22, 2024
1 parent e6a9618 commit af06c66
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/cadet/assessments/assessments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2409,16 +2409,23 @@ defmodule Cadet.Assessments do
submission =
Submission
|> join(:inner, [s], a in assoc(s, :assessment))
|> preload([_, a], assessment: a)
|> preload([_, a], assessment: {a, :config})
|> Repo.get(submission_id)

is_grading_auto_published = submission.assessment.config.is_grading_auto_published

with {:answer_found?, true} <- {:answer_found?, is_map(answer)},
{:status, true} <-
{:status, answer.submission.status == :submitted or is_own_submission},
{:valid, changeset = %Ecto.Changeset{valid?: true}} <-
{:valid, Answer.grading_changeset(answer, attrs)},
{:ok, _} <- Repo.update(changeset) do
update_xp_bonus(submission)

if is_grading_auto_published and is_fully_graded?(submission_id) do
publish_grading(submission_id)
end

{:ok, nil}
else
{:answer_found?, false} ->
Expand Down

0 comments on commit af06c66

Please sign in to comment.