changed behaviour of user exercise feedback (max 20 is collected), added some constant for the integers used.
This commit is contained in:
@ -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,22 +400,28 @@ 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) }
|
||||||
# set a message that informs the user that his score was perfect and help in RFC is greatly appreciated.
|
if(not rfc.nil?)
|
||||||
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc')
|
# set a message that informs the user that his score was perfect and help in RFC is greatly appreciated.
|
||||||
flash.keep(:notice)
|
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc')
|
||||||
|
flash.keep(:notice)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to(rfc) }
|
format.html { redirect_to(rfc) }
|
||||||
format.json { render(json: {redirect: url_for(rfc)}) }
|
format.json { render(json: {redirect: url_for(rfc)}) }
|
||||||
|
end
|
||||||
|
return
|
||||||
end
|
end
|
||||||
return
|
|
||||||
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
|
||||||
redirect_to_user_feedback
|
if @exercise.user_exercise_feedbacks.size <= 50
|
||||||
return
|
redirect_to_user_feedback
|
||||||
|
else
|
||||||
|
redirect_to_lti_return_path
|
||||||
|
end
|
||||||
|
return
|
||||||
end
|
end
|
||||||
redirect_to_lti_return_path
|
redirect_to_lti_return_path
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user