fix namespacing, specs
This commit is contained in:
@ -22,12 +22,19 @@ module ProformaService
|
|||||||
{
|
{
|
||||||
title: @exercise.title,
|
title: @exercise.title,
|
||||||
description: @exercise.description,
|
description: @exercise.description,
|
||||||
internal_description: @exercise.instructions,
|
internal_description: nil,
|
||||||
|
# ?: @exercise.instructions, store in meta-data
|
||||||
|
# proglang: proglang, where can we get this information?
|
||||||
files: task_files,
|
files: task_files,
|
||||||
tests: tests,
|
tests: tests,
|
||||||
uuid: uuid,
|
uuid: uuid,
|
||||||
language: DEFAULT_LANGUAGE,
|
language: DEFAULT_LANGUAGE,
|
||||||
model_solutions: model_solutions,
|
model_solutions: model_solutions,
|
||||||
|
meta_data: {
|
||||||
|
openHPI: {
|
||||||
|
instructions: @exercise.instructions,
|
||||||
|
},
|
||||||
|
},
|
||||||
}.compact
|
}.compact
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -69,8 +76,10 @@ module ProformaService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_meta_data(file)
|
def test_meta_data(file)
|
||||||
[{namespace: 'openHPI', key: 'entry-point', value: file.filepath},
|
{openHPI: {
|
||||||
{namespace: 'openHPI', key: 'feedback-message', value: file.feedback_message}]
|
'entry-point': file.filepath,
|
||||||
|
'feedback-message': file.feedback_message,
|
||||||
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_file(file)
|
def test_file(file)
|
||||||
|
@ -21,7 +21,7 @@ module ProformaService
|
|||||||
user: @user,
|
user: @user,
|
||||||
title: @task.title,
|
title: @task.title,
|
||||||
description: @task.description,
|
description: @task.description,
|
||||||
instructions: @task.internal_description,
|
instructions: @task.meta_data&.dig(:openHPI)&.dig(:instructions),
|
||||||
files: files
|
files: files
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -34,7 +34,7 @@ module ProformaService
|
|||||||
@task.tests.map do |test_object|
|
@task.tests.map do |test_object|
|
||||||
task_files.delete(test_object.files.first.id).tap do |file|
|
task_files.delete(test_object.files.first.id).tap do |file|
|
||||||
file.weight = 1.0
|
file.weight = 1.0
|
||||||
file.feedback_message = test_object.meta_data.detect {|meta_data| meta_data[:namespace] == 'openHPI' && meta_data[:key] == 'feedback-message' }[:value]
|
file.feedback_message = test_object.meta_data[:openHPI]&.dig(:'feedback-message')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,13 +30,18 @@ RSpec.describe ProformaService::ConvertExerciseToTask do
|
|||||||
expect(task).to have_attributes(
|
expect(task).to have_attributes(
|
||||||
title: exercise.title,
|
title: exercise.title,
|
||||||
description: exercise.description,
|
description: exercise.description,
|
||||||
internal_description: exercise.instructions,
|
# internal_description: exercise.instructions,
|
||||||
# proglang: {
|
# proglang: {
|
||||||
# name: exercise.execution_environment.language,
|
# name: exercise.execution_environment.language,
|
||||||
# version: exercise.execution_environment.version
|
# version: exercise.execution_environment.version
|
||||||
# },
|
# },
|
||||||
uuid: exercise.uuid,
|
uuid: exercise.uuid,
|
||||||
language: described_class::DEFAULT_LANGUAGE,
|
language: described_class::DEFAULT_LANGUAGE,
|
||||||
|
meta_data: {
|
||||||
|
openHPI: {
|
||||||
|
instructions: exercise.instructions,
|
||||||
|
},
|
||||||
|
},
|
||||||
# parent_uuid: exercise.clone_relations.first&.origin&.uuid,
|
# parent_uuid: exercise.clone_relations.first&.origin&.uuid,
|
||||||
files: [],
|
files: [],
|
||||||
tests: [],
|
tests: [],
|
||||||
@ -161,8 +166,12 @@ RSpec.describe ProformaService::ConvertExerciseToTask do
|
|||||||
id: test_file.id,
|
id: test_file.id,
|
||||||
title: test_file.name,
|
title: test_file.name,
|
||||||
files: have(1).item,
|
files: have(1).item,
|
||||||
meta_data: [{key: 'entry-point', namespace: 'openHPI', value: test_file.filepath},
|
meta_data: {
|
||||||
{key: 'feedback-message', namespace: 'openHPI', value: 'feedback_message'}]
|
openHPI: {
|
||||||
|
'entry-point': test_file.filepath,
|
||||||
|
'feedback-message': 'feedback_message',
|
||||||
|
},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,11 +34,15 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
Proforma::Task.new(
|
Proforma::Task.new(
|
||||||
title: 'title',
|
title: 'title',
|
||||||
description: 'description',
|
description: 'description',
|
||||||
internal_description: 'internal_description',
|
# proglang: {name: 'proglang-name', version: 'proglang-version'},
|
||||||
proglang: {name: 'proglang-name', version: 'proglang-version'},
|
|
||||||
uuid: 'uuid',
|
uuid: 'uuid',
|
||||||
parent_uuid: 'parent_uuid',
|
parent_uuid: 'parent_uuid',
|
||||||
language: 'language',
|
language: 'language',
|
||||||
|
meta_data: {
|
||||||
|
openHPI: {
|
||||||
|
instructions: 'instructions',
|
||||||
|
},
|
||||||
|
},
|
||||||
model_solutions: model_solutions,
|
model_solutions: model_solutions,
|
||||||
files: files,
|
files: files,
|
||||||
tests: tests
|
tests: tests
|
||||||
@ -54,7 +58,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
expect(convert_to_exercise_service).to have_attributes(
|
expect(convert_to_exercise_service).to have_attributes(
|
||||||
title: 'title',
|
title: 'title',
|
||||||
description: 'description',
|
description: 'description',
|
||||||
instructions: 'internal_description',
|
instructions: 'instructions',
|
||||||
execution_environment: be_blank,
|
execution_environment: be_blank,
|
||||||
uuid: be_blank,
|
uuid: be_blank,
|
||||||
unpublished: true,
|
unpublished: true,
|
||||||
@ -226,14 +230,15 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
id: 'test-id',
|
id: 'test-id',
|
||||||
title: 'title',
|
title: 'title',
|
||||||
description: 'description',
|
description: 'description',
|
||||||
internal_description: 'internal_description',
|
|
||||||
test_type: 'test_type',
|
test_type: 'test_type',
|
||||||
files: test_files,
|
files: test_files,
|
||||||
meta_data: [
|
meta_data: {
|
||||||
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
|
openHPI: {
|
||||||
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
|
'feedback-message': 'feedback-message',
|
||||||
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
|
'testing-framework': 'testing-framework',
|
||||||
]
|
'testing-framework-version': 'testing-framework-version',
|
||||||
|
},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -272,11 +277,13 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
let(:test2) do
|
let(:test2) do
|
||||||
Proforma::Test.new(
|
Proforma::Test.new(
|
||||||
files: test_files2,
|
files: test_files2,
|
||||||
meta_data: [
|
meta_data: {
|
||||||
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
|
openHPI: {
|
||||||
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
|
'feedback-message': 'feedback-message',
|
||||||
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
|
'testing-framework': 'testing-framework',
|
||||||
]
|
'testing-framework-version': 'testing-framework-version',
|
||||||
|
},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let(:test_files2) { [test_file2] }
|
let(:test_files2) { [test_file2] }
|
||||||
@ -317,7 +324,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
id: exercise.id,
|
id: exercise.id,
|
||||||
title: task.title,
|
title: task.title,
|
||||||
description: task.description,
|
description: task.description,
|
||||||
instructions: task.internal_description,
|
instructions: task.meta_data[:openHPI][:instructions],
|
||||||
execution_environment: exercise.execution_environment,
|
execution_environment: exercise.execution_environment,
|
||||||
uuid: exercise.uuid,
|
uuid: exercise.uuid,
|
||||||
user: exercise.user,
|
user: exercise.user,
|
||||||
@ -352,11 +359,13 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
internal_description: 'regular_file',
|
internal_description: 'regular_file',
|
||||||
test_type: 'test_type',
|
test_type: 'test_type',
|
||||||
files: test_files,
|
files: test_files,
|
||||||
meta_data: [
|
meta_data: {
|
||||||
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
|
openHPI: {
|
||||||
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
|
'feedback-message': 'feedback-message',
|
||||||
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
|
'testing-framework': 'testing-framework',
|
||||||
]
|
'testing-framework-version': 'testing-framework-version',
|
||||||
|
},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let(:test_files) { [test_file] }
|
let(:test_files) { [test_file] }
|
||||||
|
@ -37,5 +37,6 @@ describe ProformaService::ExportTask do
|
|||||||
export_task
|
export_task
|
||||||
expect(exporter).to have_received(:perform)
|
expect(exporter).to have_received(:perform)
|
||||||
end
|
end
|
||||||
|
# TODO more tests?!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user