Fix Rubocop offenses after Rubocop was reconfigured
This commit is contained in:

committed by
Sebastian Serth

parent
fc6aa12b0a
commit
63d997a7e3
@ -49,14 +49,15 @@ module SubmissionScoring
|
|||||||
|
|
||||||
private :execute_test_file
|
private :execute_test_file
|
||||||
|
|
||||||
def feedback_message(file, output)
|
def feedback_message(_file, output)
|
||||||
# set_locale
|
# TODO: why did we comment out set_locale and render_markdown?
|
||||||
|
set_locale
|
||||||
if output[:score] == Assessor::MAXIMUM_SCORE && output[:file_role] == 'teacher_defined_test'
|
if output[:score] == Assessor::MAXIMUM_SCORE && output[:file_role] == 'teacher_defined_test'
|
||||||
I18n.t('exercises.implement.default_test_feedback')
|
I18n.t('exercises.implement.default_test_feedback')
|
||||||
elsif output[:score] == Assessor::MAXIMUM_SCORE && output[:file_role] == 'teacher_defined_linter'
|
elsif output[:score] == Assessor::MAXIMUM_SCORE && output[:file_role] == 'teacher_defined_linter'
|
||||||
I18n.t('exercises.implement.default_linter_feedback')
|
I18n.t('exercises.implement.default_linter_feedback')
|
||||||
else
|
else
|
||||||
# render_markdown(file.feedback_message)
|
render_markdown(file.feedback_message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class SubmissionsController < ApplicationController
|
|||||||
include Tubesock::Hijack
|
include Tubesock::Hijack
|
||||||
|
|
||||||
before_action :set_submission,
|
before_action :set_submission,
|
||||||
only: %i[download download_file render_file run score extract_errors show statistics test]
|
only: %i[download download_file render_file run score extract_errors show statistics]
|
||||||
before_action :set_files, only: %i[download download_file render_file show run]
|
before_action :set_files, only: %i[download download_file render_file show run]
|
||||||
before_action :set_file, only: %i[download_file render_file run]
|
before_action :set_file, only: %i[download_file render_file run]
|
||||||
before_action :set_mime_type, only: %i[download_file render_file]
|
before_action :set_mime_type, only: %i[download_file render_file]
|
||||||
@ -134,7 +134,7 @@ class SubmissionsController < ApplicationController
|
|||||||
|
|
||||||
def handle_websockets(tubesock, runner, socket)
|
def handle_websockets(tubesock, runner, socket)
|
||||||
tubesock.send_data JSON.dump({'cmd' => 'status', 'status' => :container_running})
|
tubesock.send_data JSON.dump({'cmd' => 'status', 'status' => :container_running})
|
||||||
@output = String.new
|
@output = +''
|
||||||
|
|
||||||
socket.on :output do |data|
|
socket.on :output do |data|
|
||||||
Rails.logger.info("#{Time.zone.now.getutc}: Container sending: #{data}")
|
Rails.logger.info("#{Time.zone.now.getutc}: Container sending: #{data}")
|
||||||
@ -239,9 +239,8 @@ class SubmissionsController < ApplicationController
|
|||||||
def score
|
def score
|
||||||
Thread.new do
|
Thread.new do
|
||||||
hijack do |tubesock|
|
hijack do |tubesock|
|
||||||
if @embed_options[:disable_run]
|
return kill_socket(tubesock) if @embed_options[:disable_run]
|
||||||
return kill_socket(tubesock)
|
|
||||||
end
|
|
||||||
tubesock.send_data(@submission.calculate_score)
|
tubesock.send_data(@submission.calculate_score)
|
||||||
# To enable hints when scoring a submission, uncomment the next line:
|
# To enable hints when scoring a submission, uncomment the next line:
|
||||||
# send_hints(tubesock, StructuredError.where(submission: @submission))
|
# send_hints(tubesock, StructuredError.where(submission: @submission))
|
||||||
@ -268,7 +267,7 @@ class SubmissionsController < ApplicationController
|
|||||||
# private :set_docker_client
|
# private :set_docker_client
|
||||||
|
|
||||||
def set_file
|
def set_file
|
||||||
@file = @files.detect { |file| file.name_with_extension == sanitize_filename }
|
@file = @files.detect {|file| file.name_with_extension == sanitize_filename }
|
||||||
head :not_found unless @file
|
head :not_found unless @file
|
||||||
end
|
end
|
||||||
private :set_file
|
private :set_file
|
||||||
|
@ -22,18 +22,18 @@ class Runner < ApplicationRecord
|
|||||||
|
|
||||||
return runner if runner.save
|
return runner if runner.save
|
||||||
|
|
||||||
raise(RunnerNotAvailableError, 'No runner available')
|
raise RunnerNotAvailableError.new('No runner available')
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_files(files)
|
def copy_files(files)
|
||||||
url = "#{runner_url}/files"
|
url = "#{runner_url}/files"
|
||||||
body = {files: files.map { |filename, content| {filepath: filename, content: content} }}
|
body = {files: files.map {|filename, content| {filepath: filename, content: content} }}
|
||||||
response = Faraday.patch(url, body.to_json, HEADERS)
|
response = Faraday.patch(url, body.to_json, HEADERS)
|
||||||
return unless response.status == 404
|
return unless response.status == 404
|
||||||
|
|
||||||
# runner has disappeared for some reason
|
# runner has disappeared for some reason
|
||||||
destroy
|
destroy
|
||||||
raise(RunnerNotAvailableError, 'Runner unavailable')
|
raise RunnerNotAvailableError.new('Runner unavailable')
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute_command(command)
|
def execute_command(command)
|
||||||
@ -42,7 +42,7 @@ class Runner < ApplicationRecord
|
|||||||
if response.status == 404
|
if response.status == 404
|
||||||
# runner has disappeared for some reason
|
# runner has disappeared for some reason
|
||||||
destroy
|
destroy
|
||||||
raise(RunnerNotAvailableError, 'Runner unavailable')
|
raise RunnerNotAvailableError.new('Runner unavailable')
|
||||||
end
|
end
|
||||||
parse response
|
parse response
|
||||||
end
|
end
|
||||||
|
@ -72,7 +72,7 @@ class Submission < ApplicationRecord
|
|||||||
# expects the full file path incl. file extension
|
# expects the full file path incl. file extension
|
||||||
# Caution: There must be no unnecessary path prefix included.
|
# Caution: There must be no unnecessary path prefix included.
|
||||||
# Use `file.ext` rather than `./file.ext`
|
# Use `file.ext` rather than `./file.ext`
|
||||||
collect_files.detect { |file| file.filepath == file_path }
|
collect_files.detect {|file| file.filepath == file_path }
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalized_score
|
def normalized_score
|
||||||
@ -165,7 +165,7 @@ class Submission < ApplicationRecord
|
|||||||
container_execution_time: execution_time,
|
container_execution_time: execution_time,
|
||||||
status: exit_code.zero? ? :ok : :failed,
|
status: exit_code.zero? ? :ok : :failed,
|
||||||
stdout: stdout,
|
stdout: stdout,
|
||||||
stderr: stderr
|
stderr: stderr,
|
||||||
}
|
}
|
||||||
test_result(output, file)
|
test_result(output, file)
|
||||||
end
|
end
|
||||||
@ -202,7 +202,7 @@ class Submission < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def command_for(template, file)
|
def command_for(template, file)
|
||||||
filepath = collect_files.find { |f| f.name_with_extension == file }.filepath
|
filepath = collect_files.find {|f| f.name_with_extension == file }.filepath
|
||||||
template % command_substitutions(filepath)
|
template % command_substitutions(filepath)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class Submission < ApplicationRecord
|
|||||||
{
|
{
|
||||||
class_name: File.basename(filename, File.extname(filename)).camelize,
|
class_name: File.basename(filename, File.extname(filename)).camelize,
|
||||||
filename: filename,
|
filename: filename,
|
||||||
module_name: File.basename(filename, File.extname(filename)).underscore
|
module_name: File.basename(filename, File.extname(filename)).underscore,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CreateRunners < ActiveRecord::Migration[6.1]
|
class CreateRunners < ActiveRecord::Migration[6.1]
|
||||||
def change
|
def change
|
||||||
create_table :runners do |t|
|
create_table :runners do |t|
|
||||||
|
@ -11,10 +11,10 @@ class RunnerConnection
|
|||||||
@socket = Faye::WebSocket::Client.new(url, [], ping: 5)
|
@socket = Faye::WebSocket::Client.new(url, [], ping: 5)
|
||||||
|
|
||||||
%i[open message error close].each do |event_type|
|
%i[open message error close].each do |event_type|
|
||||||
@socket.on(event_type) { |event| __send__(:"on_#{event_type}", event) }
|
@socket.on(event_type) {|event| __send__(:"on_#{event_type}", event) }
|
||||||
end
|
end
|
||||||
|
|
||||||
EVENTS.each { |event_type| instance_variable_set(:"@#{event_type}_callback", ->(e) {}) }
|
EVENTS.each {|event_type| instance_variable_set(:"@#{event_type}_callback", ->(e) {}) }
|
||||||
@start_callback = -> {}
|
@start_callback = -> {}
|
||||||
@exit_code = 0
|
@exit_code = 0
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user