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 private :handle_file_uploads
def implement def implement
redirect_to_user_feedback
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists? redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
user_solved_exercise = @exercise.has_user_solved(current_user) 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 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 @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, # 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.) # 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 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. # 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') flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_own_rfc')
@ -406,6 +409,10 @@ class ExercisesController < ApplicationController
return return
end end
end end
else
# redirect to feedback page if score is less than 100 percent
redirect_to_user_feedback
return
end end
redirect_to_lti_return_path redirect_to_lti_return_path
end end

View File

@ -25,17 +25,27 @@ class UserExerciseFeedbacksController < ApplicationController
private :authorize! private :authorize!
def create def create
exercise = Exercise.find(uef_params[:exercise_id]) @exercise = Exercise.find(uef_params[:exercise_id])
if exercise 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) @uef = UserExerciseFeedback.new(uef_params)
if validate_inputs(uef_params) if validate_inputs(uef_params)
authorize! 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 else
flash[:danger] = t('shared.message_failure') flash[:danger] = t('shared.message_failure')
redirect_to(:back, id: uef_params[:exercise_id]) redirect_to(:back, id: uef_params[:exercise_id])
end end
end end
end end
def destroy def destroy
@ -62,9 +72,17 @@ class UserExerciseFeedbacksController < ApplicationController
end end
def update 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! authorize!
if @exercise && validate_inputs(uef_params) 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 else
flash[:danger] = t('shared.message_failure') flash[:danger] = t('shared.message_failure')
redirect_to(:back, id: uef_params[:exercise_id]) redirect_to(:back, id: uef_params[:exercise_id])

View File

@ -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')

View File

@ -20,7 +20,6 @@
<u><%= t('activerecord.attributes.request_for_comments.question')%>:</u> <%= t('request_for_comments.no_question') %> <u><%= t('activerecord.attributes.request_for_comments.question')%>:</u> <%= t('request_for_comments.no_question') %>
<% end %> <% end %>
</h5> </h5>
<button class="btn btn-warning" id="comment-exercise-button"><%= t('request_for_comments.comment_exercise') %></button>
<% if (policy(@request_for_comment).mark_as_solved? and not @request_for_comment.solved?) %> <% if (policy(@request_for_comment).mark_as_solved? and not @request_for_comment.solved?) %>
<button class="btn btn-primary" id="mark-as-solved-button"><%= t('request_for_comments.mark_as_solved') %></button> <button class="btn btn-primary" id="mark-as-solved-button"><%= t('request_for_comments.mark_as_solved') %></button>
@ -62,7 +61,6 @@ also, all settings from the rails model needed for the editor configuration in t
<% end %> <% end %>
<%= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent') %> <%= 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') %>
<script type="text/javascript"> <script type="text/javascript">
@ -84,29 +82,6 @@ also, all settings from the rails model needed for the editor configuration in t
}); });
}); });
// comment exercise
commentOnExerciseButton.on('click', function(){
$('#comment-exercise-modal').modal('show');
})
addCommentExerciseButton.on('click', function(event){
var comment = $('#commentOnExercise').val();
var url = $('#exercise_caption').data('comment-exercise-url');
var jqrequest = $.ajax({
dataType: 'json',
method: 'POST',
url: url,
data: {
exercise_id: $('#exercise_caption').data('exercise-id'),
feedback_text: comment
},
dataType: 'json'
});
$('#comment-exercise-modal').modal('hide');
});
// set file paths for ace // set file paths for ace
var ACE_FILES_PATH = '/assets/ace/'; var ACE_FILES_PATH = '/assets/ace/';
_.each(['modePath', 'themePath', 'workerPath'], function(attribute) { _.each(['modePath', 'themePath', 'workerPath'], function(attribute) {

View File

@ -5,12 +5,12 @@
h1 id="exercise-headline" h1 id="exercise-headline"
= t('activerecord.models.user_exercise_feedback.one') + " " = t('activerecord.models.user_exercise_feedback.one') + " "
= link_to(@exercise.title, [:implement, @exercise]) = link_to(@exercise.title, [:implement, @exercise])
#description-panel.lead.description-panel
u = t('activerecord.attributes.exercise.description')
= render_markdown(@exercise.description)
= render('shared/form_errors', object: @uef) = render('shared/form_errors', object: @uef)
h4 h4
== t('user_exercise_feedback.description') == t('user_exercise_feedback.description')
#description-panel.lead.description-panel
u = t('activerecord.attributes.exercise.description')
= render_markdown(@exercise.description)
.form-group .form-group
= f.text_area(:feedback_text, class: 'form-control', required: true, :rows => "10") = f.text_area(:feedback_text, class: 'form-control', required: true, :rows => "10")
h4 = t('user_exercise_feedback.difficulty') h4 = t('user_exercise_feedback.difficulty')

View File

@ -535,7 +535,7 @@ de:
difficulty_some_what_difficult: "es war etwas zu schwer" difficulty_some_what_difficult: "es war etwas zu schwer"
difficult_too_difficult: "es war zu schwer" difficult_too_difficult: "es war zu schwer"
difficulty: "Schwierigkeit der Aufgabe" difficulty: "Schwierigkeit der Aufgabe"
description: "Wir freuen uns, wenn Sie uns hier Feedback zur Aufgabe zu geben.<br><br>Bitte beschreiben Sie, was Ihnen an der Aufgabe gefallen hat und was nicht. Gabs Schwierigkeiten bei der Aufgabe? War die Aufgabe zu leicht oder zu schwer?<br>Wir freuen uns über jedes Feedback." description: "Ihre Punkte wurden übertragen. Wir würden uns freuen, wenn Sie uns hier Feedback zur Aufgabe geben würden. Wenn sie das nicht möchten, können Sie das Fenster auch einfach schließen.<br><br>Bitte beschreiben Sie, was Ihnen an der Aufgabe gefallen hat und was nicht. Gab es Schwierigkeiten bei der Aufgabe? War die Aufgabe zu leicht oder zu schwer?<br>Wir freuen uns über jedes Feedback."
estimated_time_less_5: "weniger als 5 Minuten" estimated_time_less_5: "weniger als 5 Minuten"
estimated_time_5_to_10: "zwischen 5 und 10 Minuten" estimated_time_5_to_10: "zwischen 5 und 10 Minuten"
estimated_time_10_to_20: "zwischen 10 und 20 Minuten" estimated_time_10_to_20: "zwischen 10 und 20 Minuten"

View File

@ -557,7 +557,7 @@ en:
difficulty_some_what_difficult: "it was somewhat difficult" difficulty_some_what_difficult: "it was somewhat difficult"
difficult_too_difficult: "it was too difficult" difficult_too_difficult: "it was too difficult"
difficulty: "Difficulty of the exercise" difficulty: "Difficulty of the exercise"
description: "We kindly ask you for feedback for this exercise.<br><br>Please describe what you liked on this exercise and what you did not. Was the exercise easy to understand or did you have problems understanding? How was the difficulty of the exercise to you?<br>We are happy about any feedback." description: "Your points have been submitted. We kindly ask you for feedback for this exercise. If you do not want to give feedback you can simply close this window.<br><br>Please describe what you liked on this exercise and what you did not. Was the exercise easy to understand or did you have problems understanding? How was the difficulty of the exercise to you?<br>We are happy about any feedback."
working_time: "Estimated time working on this exercise" working_time: "Estimated time working on this exercise"
estimated_time_less_5: "less than 5 minutes" estimated_time_less_5: "less than 5 minutes"
estimated_time_5_to_10: "between 5 and 10 minutes" estimated_time_5_to_10: "between 5 and 10 minutes"