removed comment on exercise in the RFC view. redirect 10% of user instead of redirecting to the RFC view to the feedback view. redirect all users how submitted to the feedback view if score is less than 100%

This commit is contained in:
Thomas Hille
2017-04-12 11:47:39 +02:00
parent 3cf123c61e
commit 60e587b690
7 changed files with 36 additions and 41 deletions

View File

@ -25,17 +25,27 @@ class UserExerciseFeedbacksController < ApplicationController
private :authorize!
def create
exercise = Exercise.find(uef_params[:exercise_id])
if exercise
@exercise = Exercise.find(uef_params[:exercise_id])
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first
submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first rescue nil
if @exercise
@uef = UserExerciseFeedback.new(uef_params)
if validate_inputs(uef_params)
authorize!
create_and_respond(object: @uef, path: proc{implement_exercise_path(exercise)})
path =
if rfc && submission && submission.normalized_score == 1.0
request_for_comment_path(rfc)
else
implement_exercise_path(@exercise)
end
create_and_respond(object: @uef, path: proc{path})
else
flash[:danger] = t('shared.message_failure')
redirect_to(:back, id: uef_params[:exercise_id])
end
end
end
def destroy
@ -62,9 +72,17 @@ class UserExerciseFeedbacksController < ApplicationController
end
def update
submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first rescue nil
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first
authorize!
if @exercise && validate_inputs(uef_params)
update_and_respond(object: @uef, params: uef_params, path: implement_exercise_path(@exercise))
path =
if rfc && submission && submission.normalized_score == 1.0
request_for_comment_path(rfc)
else
implement_exercise_path(@exercise)
end
update_and_respond(object: @uef, params: uef_params, path: path)
else
flash[:danger] = t('shared.message_failure')
redirect_to(:back, id: uef_params[:exercise_id])