specs for services
This commit is contained in:
@ -22,11 +22,9 @@ module ProformaService
|
||||
title: @exercise.title,
|
||||
description: @exercise.description,
|
||||
internal_description: @exercise.instructions,
|
||||
# proglang: proglang,
|
||||
files: task_files,
|
||||
tests: tests,
|
||||
uuid: uuid,
|
||||
# parent_uuid: parent_uuid,
|
||||
language: DEFAULT_LANGUAGE,
|
||||
model_solutions: model_solutions,
|
||||
import_checksum: @exercise.import_checksum
|
||||
@ -66,8 +64,6 @@ module ProformaService
|
||||
files: test_file(file),
|
||||
meta_data: {
|
||||
'feedback-message' => file.feedback_message
|
||||
# 'testing-framework' => test.testing_framework&.name,
|
||||
# 'testing-framework-version' => test.testing_framework&.version
|
||||
}.compact
|
||||
)
|
||||
end
|
||||
|
@ -22,7 +22,6 @@ module ProformaService
|
||||
description: @task.description,
|
||||
instructions: @task.internal_description,
|
||||
files: files,
|
||||
uuid: @task.uuid,
|
||||
import_checksum: @task.checksum
|
||||
)
|
||||
end
|
||||
@ -56,10 +55,10 @@ module ProformaService
|
||||
name: File.basename(file.filename, '.*'),
|
||||
read_only: file.usage_by_lms != 'edit',
|
||||
role: file.internal_description,
|
||||
path: File.dirname(file.filename)
|
||||
path: File.dirname(file.filename).in?(['.', '']) ? nil : File.dirname(file.filename)
|
||||
}.tap do |params|
|
||||
if file.binary
|
||||
params[:native_file] = FileIO.new(file.content.force_encoding('UTF-8'), File.basename(file.filename))
|
||||
params[:native_file] = FileIO.new(file.content.dup.force_encoding('UTF-8'), File.basename(file.filename))
|
||||
else
|
||||
params[:content] = file.content
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ module ProformaService
|
||||
importer = Proforma::Importer.new(@zip)
|
||||
@task = importer.perform
|
||||
|
||||
exercise = Exercise.find_by(uuid: @task.uuid)
|
||||
exercise = base_exercise
|
||||
exercise_files = exercise&.files&.to_a
|
||||
|
||||
exercise = ConvertTaskToExercise.call(task: @task, user: @user, exercise: exercise)
|
||||
@ -26,6 +26,17 @@ module ProformaService
|
||||
|
||||
private
|
||||
|
||||
def base_exercise
|
||||
exercise = Exercise.find_by(uuid: @task.uuid)
|
||||
if exercise
|
||||
return exercise if ExercisePolicy.new(@user, exercise).update?
|
||||
|
||||
return Exercise.new(uuid: SecureRandom.uuid, unpublished: true)
|
||||
end
|
||||
|
||||
Exercise.new(uuid: @task.uuid || SecureRandom.uuid, unpublished: true)
|
||||
end
|
||||
|
||||
def import_multi
|
||||
Zip::File.open(@zip.path) do |zip_file|
|
||||
zip_files = zip_file.filter { |entry| entry.name.match?(/\.zip$/) }
|
||||
|
Reference in New Issue
Block a user