Skip to content

Commit

Permalink
Redirect if activity not in series
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Mar 27, 2024
1 parent 4b724fe commit c77aa30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/controllers/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def show
raise Pundit::NotAuthorizedError, 'Not allowed' unless @activity.accessible?(current_user, @course)

@series = Series.find_by(id: params[:series_id])
# Double check if activity still exists within this series, redirect to course activity if it does not
redirect_to helpers.activity_scoped_path(activity: @activity, course: @course) if @series&.activities&.exclude?(@activity)

@not_registered = @course && !current_user&.member_of?(@course)
flash.now[:alert] = I18n.t('activities.show.not_a_member') if @not_registered
@current_membership = CourseMembership.where(course: @course, user: current_user).first if @lti_launch && @not_registered
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/activities_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def create_exercises_return_valid

get course_series_activity_url(right_course, wrong_series, right_exercise)

assert_redirected_to root_url
assert_redirected_to course_activity_url(right_course, right_exercise)
end

test 'should not show activity if series not in course' do
Expand Down

0 comments on commit c77aa30

Please sign in to comment.