Skip to content

Commit

Permalink
Actually use submission series
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Jun 14, 2024
1 parent b4083d0 commit 117f73c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
5 changes: 4 additions & 1 deletion app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ def edit
format.html do
if @submission.course.nil?
redirect_to activity_url(@submission.exercise, anchor: 'submission-card', edit_submission: @submission)
else
elsif @submission.series.nil?
Rails.logger.debug 'Redirecting to course_activity_url==========================================================='

Check warning on line 99 in app/controllers/submissions_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/submissions_controller.rb#L98-L99

Added lines #L98 - L99 were not covered by tests
redirect_to course_activity_url(@submission.course, @submission.exercise, anchor: 'submission-card', edit_submission: @submission)
else
redirect_to course_series_activity_url(@submission.course, @submission.series, @submission.exercise, anchor: 'submission-card', edit_submission: @submission)

Check warning on line 102 in app/controllers/submissions_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/submissions_controller.rb#L102

Added line #L102 was not covered by tests
end
end
end
Expand Down
11 changes: 0 additions & 11 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,6 @@ def result=(result)
File.binwrite(File.join(fs_path, RESULT_FILENAME), ActiveSupport::Gzip.compress(result.force_encoding('UTF-8')))
end

def series
return nil if course.nil?

series = course.series
# we want to avoid accidentally linking a hidden series to a student
series = series.visible
# There could actually be multiple series with the same exercise and the same course
# But for now we just return the first one, as there is only one in most cases
series.joins(:series_memberships).find_by(series_memberships: { activity: exercise })
end

def clean_messages(messages, levels)
messages.select { |m| !m.is_a?(Hash) || !m.key?(:permission) || levels.include?(m[:permission]) }
end
Expand Down

0 comments on commit 117f73c

Please sign in to comment.