@@ -59,10 +59,10 @@ def clone
5959 exercise = @exercise . duplicate ( public : false , token : nil , user : current_user , uuid : nil )
6060 exercise . send ( :generate_token )
6161 if exercise . save
62- redirect_to ( exercise_path ( exercise ) , notice : t ( 'shared.object_cloned' , model : Exercise . model_name . human ) )
62+ redirect_to exercise_path ( exercise ) , notice : t ( 'shared.object_cloned' , model : Exercise . model_name . human ) , status : :see_other
6363 else
6464 flash [ :danger ] = t ( 'shared.message_failure' )
65- redirect_to ( @exercise )
65+ redirect_to @exercise , status : :see_other
6666 end
6767 end
6868
@@ -238,7 +238,7 @@ def download_proforma
238238 zip_file = ProformaService ::ExportTask . call ( exercise : @exercise )
239239 send_data ( zip_file . string , type : 'application/zip' , filename : "exercise_#{ @exercise . id } .zip" , disposition : 'attachment' )
240240 rescue ProformaXML ::PostGenerateValidationError => e
241- redirect_to :root , danger : JSON . parse ( e . message ) . join ( '<br>' )
241+ redirect_to :root , danger : JSON . parse ( e . message ) . join ( '<br>' ) , status : :see_other
242242 end
243243
244244 def user_from_api_key
@@ -331,7 +331,7 @@ def handle_exercise_tips(tips_params)
331331 ExerciseTip . destroy ( previous_exercise_tips - remaining_exercise_tips )
332332 rescue JSON ::ParserError => e
333333 flash [ :danger ] = "JSON error: #{ e . message } "
334- redirect_to ( edit_exercise_path ( @exercise ) )
334+ redirect_to edit_exercise_path ( @exercise ) , status : :see_other
335335 end
336336 end
337337
@@ -349,7 +349,7 @@ def update_exercise_tips(exercise_tips, parent_exercise_tip_id, rank)
349349 rank += 1
350350 unless current_exercise_tip . save
351351 flash [ :danger ] = current_exercise_tip . errors . full_messages . join ( '. ' )
352- redirect_to ( edit_exercise_path ( @exercise ) ) and break
352+ redirect_to ( edit_exercise_path ( @exercise ) , status : :see_other ) and break
353353 end
354354
355355 children = update_exercise_tips exercise_tip [ :children ] , current_exercise_tip . id , rank
@@ -371,17 +371,16 @@ def implement # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedC
371371 session . delete ( :pair_programming )
372372 @current_contributor = current_user
373373 else
374- return redirect_back_or_to (
375- implement_exercise_path ( current_contributor . exercise ) ,
376- alert : t ( 'exercises.implement.existing_programming_group' , exercise : current_contributor . exercise . title )
377- )
374+ return redirect_back_or_to implement_exercise_path ( current_contributor . exercise ) ,
375+ alert : t ( 'exercises.implement.existing_programming_group' , exercise : current_contributor . exercise . title ) ,
376+ status : :see_other
378377 end
379378 elsif session [ :pg_id ] . blank? && ( pg = current_user . programming_groups . find_by ( exercise : @exercise ) ) && pg . submissions . where ( study_group_id : current_user . current_study_group_id ) . any?
380379 # we are just acting on behalf of a single user who has already worked on this exercise as part of a programming group **in the context of the current study group**
381380 session [ :pg_id ] = pg . id
382381 @current_contributor = pg
383382 elsif session [ :pg_id ] . blank? && session [ :pair_programming ] == 'mandatory'
384- return redirect_back_or_to ( new_exercise_programming_group_path ( @exercise ) )
383+ return redirect_back_or_to new_exercise_programming_group_path ( @exercise ) , status : :see_other
385384 elsif session [ :pg_id ] . blank? && session [ :pair_programming ] == 'optional' && current_user . submissions . where ( study_group_id : current_user . current_study_group_id , exercise : @exercise ) . none?
386385 Event . find_or_create_by ( category : 'pp_work_alone' , user : current_user , exercise : @exercise , data : nil , file_id : nil )
387386 current_user . pair_programming_waiting_users &.find_by ( exercise : @exercise ) &.update ( status : :worked_alone )
@@ -492,9 +491,9 @@ def not_authorized_for_exercise(_exception)
492491 return render_not_authorized unless %w[ implement working_times intervention reload ] . include? ( action_name )
493492
494493 if current_user . admin? || current_user . teacher?
495- redirect_to ( @exercise , alert : t ( 'exercises.implement.unpublished' ) ) if @exercise . unpublished?
496- redirect_to ( @exercise , alert : t ( 'exercises.implement.no_files' ) ) unless @exercise . files . visible . exists?
497- redirect_to ( @exercise , alert : t ( 'exercises.implement.no_execution_environment' ) ) if @exercise . execution_environment . blank?
494+ redirect_to ( @exercise , alert : t ( 'exercises.implement.unpublished' ) , status : :see_other ) if @exercise . unpublished?
495+ redirect_to ( @exercise , alert : t ( 'exercises.implement.no_files' ) , status : :see_other ) unless @exercise . files . visible . exists?
496+ redirect_to ( @exercise , alert : t ( 'exercises.implement.no_execution_environment' ) , status : :see_other ) if @exercise . execution_environment . blank?
498497 else
499498 render_not_authorized
500499 end
0 commit comments