- rename parameter to be more generic
- fix splatting of service args - add file role depending on parent object of file - add default feedback_message for imports
This commit is contained in:
@ -118,7 +118,7 @@ raise: false
|
||||
partial: 'export_actions',
|
||||
locals: {
|
||||
exercise: @exercise,
|
||||
task_found: codeharbor_check[:task_found],
|
||||
task_found: codeharbor_check[:uuid_found],
|
||||
update_right: codeharbor_check[:update_right],
|
||||
error: codeharbor_check[:error],
|
||||
exported: false,
|
||||
@ -159,10 +159,10 @@ raise: false
|
||||
uuid = params[:uuid]
|
||||
exercise = Exercise.find_by(uuid: uuid)
|
||||
|
||||
return render json: {exercise_found: false} if exercise.nil?
|
||||
return render json: {exercise_found: true, update_right: false} unless ExercisePolicy.new(user, exercise).update?
|
||||
return render json: {uuid_found: false} if exercise.nil?
|
||||
return render json: {uuid_found: true, update_right: false} unless ExercisePolicy.new(user, exercise).update?
|
||||
|
||||
render json: {exercise_found: true, update_right: true}
|
||||
render json: {uuid_found: true, update_right: true}
|
||||
end
|
||||
|
||||
def import_exercise
|
||||
|
@ -27,14 +27,23 @@ module ProformaService
|
||||
end
|
||||
|
||||
def files
|
||||
test_files + task_files.values
|
||||
model_solution_files + test_files + task_files.values
|
||||
end
|
||||
|
||||
def test_files
|
||||
@task.tests.map do |test_object|
|
||||
task_files.delete(test_object.files.first.id).tap do |file|
|
||||
file.weight = 1.0
|
||||
file.feedback_message = test_object.meta_data[:CodeOcean]&.dig(:'feedback-message')
|
||||
file.feedback_message = test_object.meta_data[:CodeOcean]&.dig(:'feedback-message').presence || 'Feedback'
|
||||
file.role = 'teacher_defined_test'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def model_solution_files
|
||||
@task.model_solutions.map do |model_solution_object|
|
||||
task_files.delete(model_solution_object.files.first.id).tap do |file|
|
||||
file.role = 'reference_implementation'
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -53,7 +62,7 @@ module ProformaService
|
||||
hidden: file.visible == 'no',
|
||||
name: File.basename(file.filename, '.*'),
|
||||
read_only: file.usage_by_lms != 'edit',
|
||||
role: file.internal_description,
|
||||
role: 'regular_file',
|
||||
path: File.dirname(file.filename).in?(['.', '']) ? nil : File.dirname(file.filename)
|
||||
)
|
||||
if file.binary
|
||||
|
@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ServiceBase
|
||||
def self.call(*args)
|
||||
new(*args).execute
|
||||
def self.call(**args)
|
||||
new(**args).execute
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user