diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index fc2848e7..2e33d11a 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -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
diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb
index 5b2a46d1..0d1e1925 100644
--- a/app/controllers/user_exercise_feedbacks_controller.rb
+++ b/app/controllers/user_exercise_feedbacks_controller.rb
@@ -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])
diff --git a/app/views/exercises/_comment_exercise_dialogcontent.html.slim b/app/views/exercises/_comment_exercise_dialogcontent.html.slim
deleted file mode 100644
index 89d1fd41..00000000
--- a/app/views/exercises/_comment_exercise_dialogcontent.html.slim
+++ /dev/null
@@ -1,5 +0,0 @@
-h5 =t('exercises.implement.comment.addComment')
-textarea#commentOnExercise.form-control(style='resize:none;')
-
-p=''
-button#addCommentExerciseButton.btn.btn-block.btn-primary(type='button') =t('exercises.implement.comment.addCommentButton')
diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb
index 57c48828..ffc7f661 100644
--- a/app/views/request_for_comments/show.html.erb
+++ b/app/views/request_for_comments/show.html.erb
@@ -20,7 +20,6 @@
<%= t('activerecord.attributes.request_for_comments.question')%>: <%= t('request_for_comments.no_question') %>
<% end %>
-
<% if (policy(@request_for_comment).mark_as_solved? and not @request_for_comment.solved?) %>
@@ -62,7 +61,6 @@ also, all settings from the rails model needed for the editor configuration in t
<% end %>
<%= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent') %>
-<%= render('shared/modal', id: 'comment-exercise-modal', title: t('exercises.implement.comment.addCommentExercise'), template: 'exercises/_comment_exercise_dialogcontent') %>