Skip to content

Commit

Permalink
Fix: Make sure released submissions are not recollectable (#7254)
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavrao145 authored Oct 4, 2024
1 parent 485b867 commit 8b23f9d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### 🐛 Bug fixes

- Fix incorrect calculation of token penalties when submissions are on time (#7216)
- Ensured submissions that have been released cannot be recollected from the repo browser (#7254)
- Fix bug where renaming a group to an existing group in a different assignment resulted in incorrect repository mapping (#7224)

### 🔧 Internal changes
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ def populate_file_manager
def manually_collect_and_begin_grading
assignment = Assignment.find_by(id: params[:assignment_id])
@grouping = assignment.groupings.find(params[:grouping_id])

unless @grouping.current_submission_used.nil?
released = @grouping.current_submission_used.results.exists?(released_to_students: true)

if released
flash_message(:error, I18n.t('submissions.collect.could_not_collect_released'))
return redirect_to repo_browser_course_assignment_submissions_path(current_course, assignment,
grouping_id: @grouping.id)
end
end

@revision_identifier = params[:current_revision_identifier]
apply_late_penalty = if params[:apply_late_penalty].nil?
false
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/submissions/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ en:
collect_due_date: Collect most recent files submitted before the due date, including any late period.
collection_options: Collection options
collection_time: Collection time
could_not_collect_released: Could not collect submission because it has already been released.
could_not_collect_some_due: Could not collect submissions for some groupings and assignment %{assignment_identifier} - the collection date has not been reached for these groupings.
could_not_collect_some_released: Could not collect submissions for some groupings and assignment %{assignment_identifier} - the submission has already been released.
manual_collection: Manual Collection
Expand Down
36 changes: 34 additions & 2 deletions spec/controllers/submissions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,45 @@
end

describe '#manually_collect_and_begin_grading' do
before do
it 'should respond with 302' do
post_as grader, :manually_collect_and_begin_grading,
params: { course_id: course.id, assignment_id: @assignment.id, grouping_id: @grouping.id,
current_revision_identifier: revision_identifier }

expect(response).to have_http_status :found
end

it 'should not flash any error messages' do
post_as grader, :manually_collect_and_begin_grading,
params: { course_id: course.id, assignment_id: @assignment.id, grouping_id: @grouping.id,
current_revision_identifier: revision_identifier }

expect(flash[:error]).to be_nil
end

it('should respond with 302') { expect(response).to have_http_status :found }
context 'When a grouping\'s submission has already been released' do
before do
# mark the existing submission as released
last_result = @grouping1.current_submission_used.get_latest_result
last_result.update!(released_to_students: true)
end

it 'should respond with 302' do
post_as grader, :manually_collect_and_begin_grading,
params: { course_id: course.id, assignment_id: @assignment.id, grouping_id: @grouping1.id,
current_revision_identifier: revision_identifier }

expect(response).to have_http_status :found
end

it 'should flash an error message' do
post_as grader, :manually_collect_and_begin_grading,
params: { course_id: course.id, assignment_id: @assignment.id, grouping_id: @grouping1.id,
current_revision_identifier: revision_identifier }

expect(flash[:error]).to eq(["<p>#{I18n.t('submissions.collect.could_not_collect_released')}</p>"])
end
end
end

describe '#update submissions' do
Expand Down

0 comments on commit 8b23f9d

Please sign in to comment.