Skip to content

Commit

Permalink
feat(retain-old-grading-data-option): copy automated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavrao145 committed Oct 3, 2024
1 parent 1c34413 commit c7a46c7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
35 changes: 30 additions & 5 deletions app/jobs/submissions_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,50 @@ def copy_old_grading_data(new_submission, grouping)
.where(remark_request_submitted_at: nil)
.last

collections = [
result_data = [
{ old: old_result.annotations, new: new_result.annotations },
{ old: old_result.marks, new: new_result.marks },
{ old: old_result.extra_marks, new: new_result.extra_marks }
]

collections.each do |collection|
result_data.each do |result_set|
# get rid of the existing empty records so we can replace them
collection[:new].all.destroy_all
result_set[:new].destroy_all

collection[:old].each do |item|
result_set[:old].each do |item|
item_dup = item.dup
item_dup.result_id = new_result.id
item_dup.save

add_warning_messages(item_dup.errors.full_messages) if item_dup.errors.present?
end
end

old_submission.test_runs.each do |test_run|
test_run_dup = test_run.dup
test_run_dup.submission_id = new_submission.id
test_run_dup.save

# don't continue if there are errors at this point
return add_warning_messages(test_run_dup.errors.full_messages) if test_run_dup.errors.present?

test_run.test_group_results.each do |test_group_result|
test_group_result_dup = test_group_result.dup
test_group_result_dup.test_run_id = test_run_dup.id
test_group_result_dup.save

# don't continue if there are errors at this point
return add_warning_messages(test_group_result_dup.errors.full_messages) if test_group_result_dup.errors.present?

test_group_result.test_results.each do |test_result|
test_result_dup = test_result.dup
test_result_dup.test_group_result_id = test_group_result_dup.id
test_result_dup.save

add_warning_messages(test_result_dup.errors.full_messages) if test_result_dup.errors.present?
end
end
end
end

def perform(groupings, apply_late_penalty: true, **options)
Expand All @@ -59,7 +85,6 @@ def perform(groupings, apply_late_penalty: true, **options)
new_submission = Submission.create_by_revision_identifier(grouping, options[:revision_identifier])
end

# here is where we would copy over old grading data
if options[:retain_existing_grading]
copy_old_grading_data(new_submission, grouping)
end
Expand Down
4 changes: 2 additions & 2 deletions config/locales/views/submissions/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ en:
full_overwrite_warning: Collecting and grading this revision will overwrite any previous collections/grading done for this group on this assignment. Are you sure you want to do this?
manual_collection: Manual Collection
override_existing: Recollect previously collected submissions?
partial_overwrite_warning: Original marks and annotations will be retained upon collecting this revision, but all remark data and autotest results from previous collections/grading will still be lost for this group on this assignment. Are you sure you want to do this?
partial_overwrite_warning: Original marks, annotations, and test results will be retained upon collecting this revision, but all remark data from previous collections/grading will still be lost for this group on this assignment. Are you sure you want to do this?
progress: "%{count}/%{size} submissions collected"
results_loss_warning: This action identifies the version of files to grade for each selected group. Instructors and TAs can begin grading after files are collected.
retain_existing_grading: Retain existing grading data (marks and annotations)
retain_existing_grading: Retain existing grading data (marks, annotations, and test results)
retain_existing_grading_warning_html: 'Retain existing grading data <strong>(Warning: without selecting this option, all old grading data for the collected submissions will be lost)</strong>'
scanned_exam_latest_warning: For scanned exams, the latest submitted file version for each selected group is used regardless of the due date.
status:
Expand Down

0 comments on commit c7a46c7

Please sign in to comment.