Fix rubocop, I18n, cleanup rebase

This commit is contained in:
Felix Auringer
2021-07-26 14:16:41 +02:00
committed by Sebastian Serth
parent 2dff81a510
commit 5cc180d0e9
8 changed files with 20 additions and 91 deletions

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
module ScoringResultFormatting
def format_scoring_results(outputs)
outputs.map do |output|
output[:message] = t(output[:message], default: render_markdown(output[:message]))
output[:filename] = t(output[:filename], default: output[:filename])
output
end
end
end

View File

@ -3,7 +3,6 @@
class RemoteEvaluationController < ApplicationController
include RemoteEvaluationParameters
include Lti
include ScoringResultFormatting
skip_after_action :verify_authorized
skip_before_action :verify_authenticity_token
@ -63,7 +62,7 @@ status: 202}
validation_token = remote_evaluation_params[:validation_token]
if (remote_evaluation_mapping = RemoteEvaluationMapping.find_by(validation_token: validation_token))
@submission = Submission.create(build_submission_params(cause, remote_evaluation_mapping))
format_scoring_results(@submission.calculate_score)
@submission.calculate_score
else
# TODO: better output
# TODO: check token expired?

View File

@ -119,7 +119,7 @@ class RequestForCommentsController < ApplicationController
if @request_for_comment.save
# create thread here and execute tests. A run is triggered from the frontend and does not need to be handled here.
Thread.new do
@request_for_comment.submission.calculate_score
switch_locale { @request_for_comment.submission.calculate_score }
ensure
ActiveRecord::Base.connection_pool.release_connection
end

View File

@ -5,7 +5,6 @@ class SubmissionsController < ApplicationController
include CommonBehavior
include Lti
include SubmissionParameters
include ScoringResultFormatting
include Tubesock::Hijack
before_action :set_submission,
@ -35,15 +34,6 @@ class SubmissionsController < ApplicationController
create_and_respond(object: @submission)
end
def command_substitutions(filename)
{
class_name: File.basename(filename, File.extname(filename)).upcase_first,
filename: filename,
module_name: File.basename(filename, File.extname(filename)).underscore,
}
end
private :command_substitutions
def copy_comments
# copy each annotation and set the target_file.id
params[:annotations_arr]&.each do |annotation|
@ -247,7 +237,7 @@ class SubmissionsController < ApplicationController
hijack do |tubesock|
return kill_socket(tubesock) if @embed_options[:disable_run]
tubesock.send_data(JSON.dump(format_scoring_results(@submission.calculate_score)))
tubesock.send_data(JSON.dump(@submission.calculate_score))
# To enable hints when scoring a submission, uncomment the next line:
# send_hints(tubesock, StructuredError.where(submission: @submission))
rescue Runner::Error => e