diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 37d60476..05e69dcf 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -9,7 +9,7 @@ class Exercise < ApplicationRecord after_initialize :generate_token after_initialize :set_default_values - belongs_to :execution_environment + belongs_to :execution_environment, optional: true has_many :submissions has_and_belongs_to_many :proxy_exercises diff --git a/app/services/proforma_service/convert_task_to_exercise.rb b/app/services/proforma_service/convert_task_to_exercise.rb index f2d26b45..ee5f5a78 100644 --- a/app/services/proforma_service/convert_task_to_exercise.rb +++ b/app/services/proforma_service/convert_task_to_exercise.rb @@ -21,19 +21,33 @@ module ProformaService title: @task.title, description: @task.description, instructions: @task.internal_description, - # exercise_files: task_files.values, - # execution_environment: execution_environment, + files: task_files # tests: tests, + # execution_environment: execution_environment, # state_list: @exercise.persisted? ? 'updated' : 'new' ) end def task_files - @task_files ||= Hash[ - @task.all_files.reject { |file| file.id == 'ms-placeholder-file' }.map do |task_file| - [task_file.id, exercise_file_from_task_file(task_file)] - end - ] + @task.all_files.map do |file| + CodeOcean::File.new( + context: @exercise, + file_type: FileType.find_by(file_extension: File.extname(file.filename)), + hidden: file.visible == 'no', + name: File.basename(file.filename, '.*'), + read_only: file.usage_by_lms != 'edit', + # native_file: somehting something, + role: file.internal_description.underscore.gsub(' ', '_'), + # feedback_message: #if file is testfilethingy take that message, + # weight: see above, + path: File.dirname(file.filename) + ) + end + # @task_files ||= Hash[ + # @task.all_files.reject { |file| file.id == 'ms-placeholder-file' }.map do |task_file| + # [task_file.id, exercise_file_from_task_file(task_file)] + # end + # ] end def exercise_file_from_task_file(task_file) diff --git a/app/views/exercises/show.html.slim b/app/views/exercises/show.html.slim index e2f7ada9..b9fd33bc 100644 --- a/app/views/exercises/show.html.slim +++ b/app/views/exercises/show.html.slim @@ -12,7 +12,7 @@ h1 = row(label: 'exercise.title', value: @exercise.title) = row(label: 'exercise.user', value: link_to_if(policy(@exercise.author).show?, @exercise.author, @exercise.author)) = row(label: 'exercise.description', value: render_markdown(@exercise.description), class: 'm-0') -= row(label: 'exercise.execution_environment', value: link_to_if(policy(@exercise.execution_environment).show?, @exercise.execution_environment, @exercise.execution_environment)) += row(label: 'exercise.execution_environment', value: link_to_if(@exercise.execution_environment && policy(@exercise.execution_environment).show?, @exercise.execution_environment, @exercise.execution_environment)) /= row(label: 'exercise.instructions', value: render_markdown(@exercise.instructions)) = row(label: 'exercise.maximum_score', value: @exercise.maximum_score) = row(label: 'exercise.public', value: @exercise.public?)