File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -2409,16 +2409,23 @@ defmodule Cadet.Assessments do
24092409 submission =
24102410 Submission
24112411 |> join ( :inner , [ s ] , a in assoc ( s , :assessment ) )
2412- |> preload ( [ _ , a ] , assessment: a )
2412+ |> preload ( [ _ , a ] , assessment: { a , :config } )
24132413 |> Repo . get ( submission_id )
24142414
2415+ is_grading_auto_published = submission . assessment . config . is_grading_auto_published
2416+
24152417 with { :answer_found? , true } <- { :answer_found? , is_map ( answer ) } ,
24162418 { :status , true } <-
24172419 { :status , answer . submission . status == :submitted or is_own_submission } ,
24182420 { :valid , changeset = % Ecto.Changeset { valid?: true } } <-
24192421 { :valid , Answer . grading_changeset ( answer , attrs ) } ,
24202422 { :ok , _ } <- Repo . update ( changeset ) do
24212423 update_xp_bonus ( submission )
2424+
2425+ if is_grading_auto_published and is_fully_graded? ( submission_id ) do
2426+ publish_grading ( submission_id )
2427+ end
2428+
24222429 { :ok , nil }
24232430 else
24242431 { :answer_found? , false } ->
You can’t perform that action at this time.
0 commit comments