Apply automatic rubocop fixes

This commit is contained in:
Sebastian Serth
2021-05-14 10:51:44 +02:00
parent fe4000916c
commit 6cbecb5b39
440 changed files with 2705 additions and 1853 deletions

View File

@ -26,7 +26,7 @@ module ProformaService
tests: tests,
uuid: uuid,
language: DEFAULT_LANGUAGE,
model_solutions: model_solutions
model_solutions: model_solutions,
}.compact
)
end
@ -37,7 +37,7 @@ module ProformaService
end
def model_solutions
@exercise.files.filter { |file| file.role == 'reference_implementation' }.map do |file|
@exercise.files.filter {|file| file.role == 'reference_implementation' }.map do |file|
Proforma::ModelSolution.new(
id: "ms-#{file.id}",
files: model_solution_file(file)
@ -50,18 +50,20 @@ module ProformaService
task_file(file).tap do |ms_file|
ms_file.used_by_grader = false
ms_file.usage_by_lms = 'display'
end
end,
]
end
def tests
@exercise.files.filter { |file| file.role == 'teacher_defined_test' || file.role == 'teacher_defined_linter' }.map do |file|
@exercise.files.filter do |file|
file.role == 'teacher_defined_test' || file.role == 'teacher_defined_linter'
end.map do |file|
Proforma::Test.new(
id: file.id,
title: file.name,
files: test_file(file),
meta_data: {
'feedback-message' => file.feedback_message
'feedback-message' => file.feedback_message,
}.compact
)
end
@ -72,13 +74,16 @@ module ProformaService
task_file(file).tap do |t_file|
t_file.used_by_grader = true
t_file.internal_description = 'teacher_defined_test'
end
end,
]
end
def task_files
@exercise.files
.filter { |file| !file.role.in? %w[reference_implementation teacher_defined_test teacher_defined_linter] }.map do |file|
.filter do |file|
!file.role.in? %w[reference_implementation teacher_defined_test
teacher_defined_linter]
end.map do |file|
task_file(file)
end
end
@ -96,7 +101,12 @@ module ProformaService
end
def filename(file)
file.path.present? && file.path != '.' ? ::File.join(file.path, file.name_with_extension) : file.name_with_extension
if file.path.present? && file.path != '.'
::File.join(file.path,
file.name_with_extension)
else
file.name_with_extension
end
end
def add_content_to_task_file(file, task_file)

View File

@ -39,11 +39,9 @@ module ProformaService
end
def task_files
@task_files ||= Hash[
@task.all_files.reject { |file| file.id == 'ms-placeholder-file' }.map do |task_file|
[task_file.id, codeocean_file_from_task_file(task_file)]
end
]
@task_files ||= @task.all_files.reject {|file| file.id == 'ms-placeholder-file' }.map do |task_file|
[task_file.id, codeocean_file_from_task_file(task_file)]
end.to_h
end
def codeocean_file_from_task_file(file)

View File

@ -39,7 +39,7 @@ module ProformaService
def import_multi
Zip::File.open(@zip.path) do |zip_file|
zip_files = zip_file.filter { |entry| entry.name.match?(/\.zip$/) }
zip_files = zip_file.filter {|entry| entry.name.match?(/\.zip$/) }
begin
zip_files.map! do |entry|
store_zip_entry_in_tempfile entry
@ -65,7 +65,7 @@ module ProformaService
zip_file.map(&:name)
end
filenames.select { |f| f[/\.xml$/] }.any?
filenames.select {|f| f[/\.xml$/] }.any?
rescue Zip::Error
raise Proforma::InvalidZip
end