Skip to content

Commit

Permalink
fix: Fix unintended auto-publishing of autograder (#1165)
Browse files Browse the repository at this point in the history
* fix: Auto-publish only when is_manually_graded is false for the autograder

* chore: Format files
  • Loading branch information
GabrielCWT authored Aug 31, 2024
1 parent 4e19a57 commit e84c941
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/cadet/jobs/autograder/grading_job.ex
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@ defmodule Cadet.Autograder.GradingJob do
assessment = Repo.get(Assessment, submission.assessment_id)
assessment_config = Repo.get_by(AssessmentConfig, id: assessment.config_id)
is_grading_auto_published = assessment_config.is_grading_auto_published
is_manually_graded = assessment_config.is_manually_graded

if Assessments.is_fully_autograded?(submission_id) and is_grading_auto_published do
if Assessments.is_fully_autograded?(submission_id) and is_grading_auto_published and
not is_manually_graded do
Assessments.publish_grading(submission_id)
end
end
Expand Down
20 changes: 17 additions & 3 deletions test/cadet/jobs/autograder/grading_job_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ defmodule Cadet.Autograder.GradingJobTest do
describe "#force_grade_individual_submission, all programming questions" do
setup do
course = insert(:course)
assessment_config = insert(:assessment_config, %{course: course})

assessment_config =
insert(:assessment_config, %{
course: course,
is_grading_auto_published: true,
is_manually_graded: false
})

assessments =
insert_list(3, :assessment, %{
Expand Down Expand Up @@ -416,7 +422,11 @@ defmodule Cadet.Autograder.GradingJobTest do
course = insert(:course)

assessment_config =
insert(:assessment_config, %{course: course, is_grading_auto_published: true})
insert(:assessment_config, %{
course: course,
is_grading_auto_published: true,
is_manually_graded: false
})

assessments =
insert_list(3, :assessment, %{
Expand Down Expand Up @@ -648,7 +658,11 @@ defmodule Cadet.Autograder.GradingJobTest do
course = insert(:course)

assessment_config =
insert(:assessment_config, %{course: course, is_grading_auto_published: true})
insert(:assessment_config, %{
course: course,
is_grading_auto_published: true,
is_manually_graded: false
})

assessments =
insert_list(3, :assessment, %{
Expand Down

0 comments on commit e84c941

Please sign in to comment.