diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb
index a46667ae..b2f69fcf 100644
--- a/app/assets/javascripts/editor.js.erb
+++ b/app/assets/javascripts/editor.js.erb
@@ -138,8 +138,8 @@ $(function() {
// This is the case, since it is set via a call to ancestor_id on the model, which returns either file_id if set, or id if it is not set.
// therefore the else part is not needed any longer...
- // if we have an file_id set (the file is a copy of a teacher supplied given file)
- if (file_id_old != null){
+ // if we have an file_id set (the file is a copy of a teacher supplied given file) and the new file-ids are present in the response
+ if (file_id_old != null && data.files){
// if we find file_id_old (this is the reference to the base file) in the submission, this is the match
for(var j = 0; j< data.files.length; j++){
if(data.files[j].file_id == file_id_old){
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 45fd04d9..75451eb3 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -224,7 +224,7 @@ class ExercisesController < ApplicationController
if lti_outcome_service?
transmit_lti_score
else
- redirect_to_lti_return_path
+ redirect_after_submit
end
end
@@ -232,7 +232,7 @@ class ExercisesController < ApplicationController
::NewRelic::Agent.add_custom_parameters({ submission: @submission.id, normalized_score: @submission.normalized_score })
response = send_score(@submission.normalized_score)
if response[:status] == 'success'
- redirect_to_lti_return_path
+ redirect_after_submit
else
respond_to do |format|
format.html { redirect_to(implement_exercise_path(@submission.exercise)) }
@@ -245,4 +245,28 @@ class ExercisesController < ApplicationController
def update
update_and_respond(object: @exercise, params: exercise_params)
end
+
+ def redirect_after_submit
+ Rails.logger.debug('Score ' + @submission.normalized_score.to_s)
+ if @submission.normalized_score == 1.0
+ # if user has an own rfc, redirect to it and message him to clean up and accept the answer.
+
+ # else: show open rfc for same exercise
+ if rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise).order("RANDOM()").first
+
+ # 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.keep(:notice)
+
+ respond_to do |format|
+ format.html { redirect_to(rfc) }
+ format.json { render(json: {redirect: url_for(rfc)}) }
+ end
+
+ return
+ end
+ end
+ redirect_to_lti_return_path
+ end
+
end
diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb
index 63d932fc..4be7d325 100644
--- a/app/models/request_for_comment.rb
+++ b/app/models/request_for_comment.rb
@@ -4,16 +4,12 @@ class RequestForComment < ActiveRecord::Base
belongs_to :exercise
belongs_to :file, class_name: 'CodeOcean::File'
- before_create :set_requested_timestamp
+ scope :unsolved, -> { where(solved: [false, nil]) }
def self.last_per_user(n = 5)
from("(#{row_number_user_sql}) as request_for_comments").where("row_number <= ?", n)
end
- def set_requested_timestamp
- self.requested_at = Time.now
- end
-
# not used right now, finds the last submission for the respective user and exercise.
# might be helpful to check whether the exercise has been solved in the meantime.
def last_submission
diff --git a/app/views/exercises/_comment_dialogcontent.html.slim b/app/views/exercises/_comment_dialogcontent.html.slim
index b14c988f..0d89bea3 100644
--- a/app/views/exercises/_comment_dialogcontent.html.slim
+++ b/app/views/exercises/_comment_dialogcontent.html.slim
@@ -1,9 +1,9 @@
-h5 =t('exercises.implement.comment.others')
-pre#other-comments
-
h5 =t('exercises.implement.comment.addyours')
textarea.form-control(style='resize:none;')
+#otherComments
+ h5 =t('exercises.implement.comment.others')
+ pre#otherCommentsTextfield
p = ''
button#addCommentButton.btn.btn-block.btn-primary(type='button') =t('exercises.implement.comment.addComment')
button#removeAllButton.btn.btn-block.btn-warning(type='button') =t('exercises.implement.comment.removeAllOnLine')
\ No newline at end of file
diff --git a/app/views/request_for_comments/_form.html.erb b/app/views/request_for_comments/_form.html.erb
index 4d4494ce..81f6ed65 100644
--- a/app/views/request_for_comments/_form.html.erb
+++ b/app/views/request_for_comments/_form.html.erb
@@ -23,10 +23,6 @@
<%= f.label :file_id %>
<%= f.number_field :file_id %>
-