From 06131e6e636f4b7adcaf60fa2858afe7bbf93bba Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Thu, 9 Jul 2015 16:08:26 +0200 Subject: [PATCH] Remove logic to find newest submission for an exercise and user. This is no longer necessary, since we update the file ids in editor.js --- .../request_for_comments_controller.rb | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb index 8c2379b4..fbeb21b7 100644 --- a/app/controllers/request_for_comments_controller.rb +++ b/app/controllers/request_for_comments_controller.rb @@ -35,30 +35,7 @@ class RequestForCommentsController < ApplicationController # POST /request_for_comments # POST /request_for_comments.json def create - - file = CodeOcean::File.find(request_for_comment_params[:fileid]) - - # get newest version of the file. this method is only called if there is at least one submission (prevented in frontend otherwise) - # find newest submission for that exercise and user, use the file with the same filename for that. - # this is necessary because the passed params are not up to date since the data attributes are not updated upon submission creation. - - # if we stat from the template, the context type is exercise. we find the newest submission based on the context_id and the current_user.id - if(file.context_type =='Exercise') - newest_submission = Submission.where(exercise_id: file.context_id, user_id: current_user.id).order('created_at DESC').first - else - # else we start from a submission. we find it it by the given context_id and retrieve the newest submission with the info of the known submission. - submission = Submission.find(file.context_id) - newest_submission = Submission.where(exercise_id: submission.exercise_id, user_id: submission.user_id).order('created_at DESC').first - end - newest_file = CodeOcean::File.where(context_id: newest_submission.id, name: file.name).first - - #finally, correct the fileid and create the request for comment - request_for_comment_params[:fileid]=newest_file.id - @request_for_comment = RequestForComment.new(request_for_comment_params) - - - respond_to do |format| if @request_for_comment.save format.json { render :show, status: :created, location: @request_for_comment }