changed behaviour of user exercise feedback (max 20 is collected), added some constant for the integers used.

This commit is contained in:
Ralf Teusner
2017-10-25 10:38:27 +02:00
parent d162f78b67
commit 539b2931c3

View File

@ -24,6 +24,9 @@ class ExercisesController < ApplicationController
3 3
end end
MAX_EXERCISE_FEEDBACKS = 20
MAX_COMMENTS_PER_REQUEST = 5
def java_course_token def java_course_token
"702cbd2a-c84c-4b37-923a-692d7d1532d0" "702cbd2a-c84c-4b37-923a-692d7d1532d0"
@ -382,7 +385,7 @@ class ExercisesController < ApplicationController
# 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.) # 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.)
# redirect 10 percent pseudorandomly to the feedback page # redirect 10 percent pseudorandomly to the feedback page
if current_user.respond_to? :external_id if current_user.respond_to? :external_id
if ((current_user.id + @submission.exercise.created_at.to_i) % 10 == 1) if (((current_user.id + @submission.exercise.created_at.to_i) % 10 == 1) && @exercise.user_exercise_feedbacks.size <= MAX_EXERCISE_FEEDBACKS)
redirect_to_user_feedback redirect_to_user_feedback
return return
elsif rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise, user_id: current_user.id).first elsif rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise, user_id: current_user.id).first
@ -397,7 +400,8 @@ class ExercisesController < ApplicationController
return return
# else: show open rfc for same exercise if available # else: show open rfc for same exercise if available
elsif rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < 5) } elsif rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_PER_REQUEST) }
if(not rfc.nil?)
# set a message that informs the user that his score was perfect and help in RFC is greatly appreciated. # set a message that informs the user that his score was perfect and help in RFC is greatly appreciated.
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc') flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc')
flash.keep(:notice) flash.keep(:notice)
@ -409,9 +413,14 @@ class ExercisesController < ApplicationController
return return
end end
end end
end
else else
# redirect to feedback page if score is less than 100 percent # redirect to feedback page if score is less than 100 percent
if @exercise.user_exercise_feedbacks.size <= 50
redirect_to_user_feedback redirect_to_user_feedback
else
redirect_to_lti_return_path
end
return return
end end
redirect_to_lti_return_path redirect_to_lti_return_path