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

@@ -164,7 +164,6 @@ class ExercisesController < ApplicationController
private :handle_file_uploads
def implement
redirect_to_user_feedback
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
user_solved_exercise = @exercise.has_user_solved(current_user)
user_got_enough_interventions = UserExerciseIntervention.where(user: current_user).where("created_at >= ?", Time.zone.now.beginning_of_day).count >= max_intervention_count
@@ -381,7 +380,11 @@ class ExercisesController < ApplicationController
if @submission.normalized_score == 1.0
# if user is external and has an own rfc, redirect to it and message him to clean up and accept the answer. (we need to check that the user is external,
# otherwise an internal user could be shown a false rfc here, since current_user.id is polymorphic, but only makes sense for external users when used with rfcs.)
if current_user.respond_to? :external_id
# redirect 10 percent pseudorandomly to the feedback page
if ((current_user.id + @submission.exercise.created_at.to_i) % 10 == 1)
redirect_to_user_feedback
return
elsif current_user.respond_to? :external_id
if rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise, user_id: current_user.id).first
# set a message that informs the user that his own RFC should be closed.
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_own_rfc')
@@ -406,6 +409,10 @@ class ExercisesController < ApplicationController
return
end
end
else
# redirect to feedback page if score is less than 100 percent
redirect_to_user_feedback
return
end
redirect_to_lti_return_path
end

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])