Update from proforma to proformaxml
This commit is contained in:

committed by
Sebastian Serth

parent
41e75ca385
commit
245c3dba8c
3
Gemfile
3
Gemfile
@ -6,7 +6,6 @@ gem 'bcrypt'
|
|||||||
gem 'bootstrap-will_paginate'
|
gem 'bootstrap-will_paginate'
|
||||||
gem 'carrierwave'
|
gem 'carrierwave'
|
||||||
gem 'charlock_holmes', require: 'charlock_holmes/string'
|
gem 'charlock_holmes', require: 'charlock_holmes/string'
|
||||||
gem 'dachsfisch', github: 'openHPI/dachsfisch'
|
|
||||||
gem 'docker-api', require: 'docker'
|
gem 'docker-api', require: 'docker'
|
||||||
gem 'eventmachine'
|
gem 'eventmachine'
|
||||||
gem 'factory_bot_rails'
|
gem 'factory_bot_rails'
|
||||||
@ -31,7 +30,7 @@ gem 'net-smtp', require: false
|
|||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
gem 'pagedown-bootstrap-rails'
|
gem 'pagedown-bootstrap-rails'
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
gem 'proforma', github: 'openHPI/proforma', tag: 'v0.9.1'
|
gem 'proformaxml'
|
||||||
gem 'prometheus_exporter'
|
gem 'prometheus_exporter'
|
||||||
gem 'puma'
|
gem 'puma'
|
||||||
gem 'pundit'
|
gem 'pundit'
|
||||||
|
29
Gemfile.lock
29
Gemfile.lock
@ -1,21 +1,3 @@
|
|||||||
GIT
|
|
||||||
remote: https://github.com/openHPI/dachsfisch.git
|
|
||||||
revision: c74d5a3d74685a0838d369fe3dcbbb9166d50a5b
|
|
||||||
specs:
|
|
||||||
dachsfisch (0.1.0)
|
|
||||||
nokogiri (>= 1.14.1, < 2.0.0)
|
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: https://github.com/openHPI/proforma.git
|
|
||||||
revision: 10642d8d4ec27e0bdaa27482dac6b6c7e47bc660
|
|
||||||
tag: v0.9.1
|
|
||||||
specs:
|
|
||||||
proforma (0.9.1)
|
|
||||||
activemodel (>= 5.2.3, < 8.0.0)
|
|
||||||
activesupport (>= 5.2.3, < 8.0.0)
|
|
||||||
nokogiri (>= 1.10.2, < 2.0.0)
|
|
||||||
rubyzip (>= 1.2.2, < 3.0.0)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
@ -134,6 +116,8 @@ GEM
|
|||||||
crack (0.4.5)
|
crack (0.4.5)
|
||||||
rexml
|
rexml
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
|
dachsfisch (0.1.0)
|
||||||
|
nokogiri (>= 1.14.1, < 2.0.0)
|
||||||
database_cleaner (2.0.2)
|
database_cleaner (2.0.2)
|
||||||
database_cleaner-active_record (>= 2, < 3)
|
database_cleaner-active_record (>= 2, < 3)
|
||||||
database_cleaner-active_record (2.1.0)
|
database_cleaner-active_record (2.1.0)
|
||||||
@ -285,6 +269,12 @@ GEM
|
|||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
racc
|
racc
|
||||||
pg (1.5.3)
|
pg (1.5.3)
|
||||||
|
proformaxml (0.10.0)
|
||||||
|
activemodel (>= 5.2.3, < 8.0.0)
|
||||||
|
activesupport (>= 5.2.3, < 8.0.0)
|
||||||
|
dachsfisch (>= 0.1.0, < 1.0.0)
|
||||||
|
nokogiri (>= 1.10.2, < 2.0.0)
|
||||||
|
rubyzip (>= 1.2.2, < 3.0.0)
|
||||||
prometheus_exporter (2.0.8)
|
prometheus_exporter (2.0.8)
|
||||||
webrick
|
webrick
|
||||||
pry (0.14.2)
|
pry (0.14.2)
|
||||||
@ -547,7 +537,6 @@ DEPENDENCIES
|
|||||||
capybara
|
capybara
|
||||||
carrierwave
|
carrierwave
|
||||||
charlock_holmes
|
charlock_holmes
|
||||||
dachsfisch!
|
|
||||||
database_cleaner
|
database_cleaner
|
||||||
docker-api
|
docker-api
|
||||||
eventmachine
|
eventmachine
|
||||||
@ -578,7 +567,7 @@ DEPENDENCIES
|
|||||||
nyan-cat-formatter
|
nyan-cat-formatter
|
||||||
pagedown-bootstrap-rails
|
pagedown-bootstrap-rails
|
||||||
pg
|
pg
|
||||||
proforma!
|
proformaxml
|
||||||
prometheus_exporter
|
prometheus_exporter
|
||||||
pry-byebug
|
pry-byebug
|
||||||
pry-rails
|
pry-rails
|
||||||
|
@ -166,9 +166,9 @@ class ExercisesController < ApplicationController
|
|||||||
exercise.save!
|
exercise.save!
|
||||||
render json: {}, status: :created
|
render json: {}, status: :created
|
||||||
end
|
end
|
||||||
rescue Proforma::ExerciseNotOwned
|
rescue ProformaXML::ExerciseNotOwned
|
||||||
render json: {}, status: :unauthorized
|
render json: {}, status: :unauthorized
|
||||||
rescue Proforma::ProformaError
|
rescue ProformaXML::ProformaError
|
||||||
render json: t('exercises.import_codeharbor.import_errors.invalid'), status: :bad_request
|
render json: t('exercises.import_codeharbor.import_errors.invalid'), status: :bad_request
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Proforma
|
module ProformaXML
|
||||||
class ExerciseNotOwned < StandardError; end
|
class ExerciseNotOwned < StandardError; end
|
||||||
end
|
end
|
@ -18,7 +18,7 @@ module ProformaService
|
|||||||
private
|
private
|
||||||
|
|
||||||
def create_task
|
def create_task
|
||||||
Proforma::Task.new(
|
ProformaXML::Task.new(
|
||||||
{
|
{
|
||||||
title: @exercise.title,
|
title: @exercise.title,
|
||||||
description: @exercise.description,
|
description: @exercise.description,
|
||||||
@ -57,7 +57,7 @@ module ProformaService
|
|||||||
|
|
||||||
def model_solutions
|
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(
|
ProformaXML::ModelSolution.new(
|
||||||
id: "ms-#{file.id}",
|
id: "ms-#{file.id}",
|
||||||
files: model_solution_file(file)
|
files: model_solution_file(file)
|
||||||
)
|
)
|
||||||
@ -75,7 +75,7 @@ module ProformaService
|
|||||||
|
|
||||||
def tests
|
def tests
|
||||||
@exercise.files.filter(&:teacher_defined_assessment?).map do |file|
|
@exercise.files.filter(&:teacher_defined_assessment?).map do |file|
|
||||||
Proforma::Test.new(
|
ProformaXML::Test.new(
|
||||||
id: file.id,
|
id: file.id,
|
||||||
title: file.name,
|
title: file.name,
|
||||||
files: test_file(file),
|
files: test_file(file),
|
||||||
@ -122,7 +122,7 @@ module ProformaService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def task_file(file)
|
def task_file(file)
|
||||||
task_file = Proforma::TaskFile.new(
|
task_file = ProformaXML::TaskFile.new(
|
||||||
id: file.id,
|
id: file.id,
|
||||||
filename: filename(file),
|
filename: filename(file),
|
||||||
usage_by_lms: file.read_only ? 'display' : 'edit',
|
usage_by_lms: file.read_only ? 'display' : 'edit',
|
||||||
|
@ -10,7 +10,7 @@ module ProformaService
|
|||||||
def execute
|
def execute
|
||||||
@task = ConvertExerciseToTask.call(exercise: @exercise)
|
@task = ConvertExerciseToTask.call(exercise: @exercise)
|
||||||
namespaces = [{prefix: 'CodeOcean', uri: 'codeocean.openhpi.de'}]
|
namespaces = [{prefix: 'CodeOcean', uri: 'codeocean.openhpi.de'}]
|
||||||
exporter = Proforma::Exporter.new(task: @task, custom_namespaces: namespaces)
|
exporter = ProformaXML::Exporter.new(task: @task, custom_namespaces: namespaces)
|
||||||
exporter.perform
|
exporter.perform
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,7 +10,7 @@ module ProformaService
|
|||||||
|
|
||||||
def execute
|
def execute
|
||||||
if single_task?
|
if single_task?
|
||||||
importer = Proforma::Importer.new(zip: @zip)
|
importer = ProformaXML::Importer.new(zip: @zip)
|
||||||
import_result = importer.perform
|
import_result = importer.perform
|
||||||
@task = import_result[:task]
|
@task = import_result[:task]
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ module ProformaService
|
|||||||
def base_exercise
|
def base_exercise
|
||||||
exercise = Exercise.find_by(uuid: @task.uuid)
|
exercise = Exercise.find_by(uuid: @task.uuid)
|
||||||
if exercise
|
if exercise
|
||||||
raise Proforma::ExerciseNotOwned unless ExercisePolicy.new(@user, exercise).update?
|
raise ProformaXML::ExerciseNotOwned unless ExercisePolicy.new(@user, exercise).update?
|
||||||
|
|
||||||
exercise
|
exercise
|
||||||
else
|
else
|
||||||
@ -69,7 +69,7 @@ module ProformaService
|
|||||||
|
|
||||||
filenames.any? {|f| f[/\.xml$/] }
|
filenames.any? {|f| f[/\.xml$/] }
|
||||||
rescue Zip::Error
|
rescue Zip::Error
|
||||||
raise Proforma::InvalidZip
|
raise ProformaXML::InvalidZip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,4 +14,5 @@
|
|||||||
|
|
||||||
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||||
inflect.acronym 'IO'
|
inflect.acronym 'IO'
|
||||||
|
inflect.acronym 'ProformaXML'
|
||||||
end
|
end
|
||||||
|
@ -563,7 +563,7 @@ describe ExercisesController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when import fails with ProformaError' do
|
context 'when import fails with ProformaError' do
|
||||||
before { allow(ProformaService::Import).to receive(:call).and_raise(Proforma::PreImportValidationError) }
|
before { allow(ProformaService::Import).to receive(:call).and_raise(ProformaXML::PreImportValidationError) }
|
||||||
|
|
||||||
it 'responds with correct status code' do
|
it 'responds with correct status code' do
|
||||||
post_request
|
post_request
|
||||||
@ -572,7 +572,7 @@ describe ExercisesController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when import fails with ExerciseNotOwned' do
|
context 'when import fails with ExerciseNotOwned' do
|
||||||
before { allow(ProformaService::Import).to receive(:call).and_raise(Proforma::ExerciseNotOwned) }
|
before { allow(ProformaService::Import).to receive(:call).and_raise(ProformaXML::ExerciseNotOwned) }
|
||||||
|
|
||||||
it 'responds with correct status code' do
|
it 'responds with correct status code' do
|
||||||
post_request
|
post_request
|
||||||
|
@ -6,7 +6,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
describe '.new' do
|
describe '.new' do
|
||||||
subject(:convert_to_exercise_service) { described_class.new(task:, user:, exercise:) }
|
subject(:convert_to_exercise_service) { described_class.new(task:, user:, exercise:) }
|
||||||
|
|
||||||
let(:task) { Proforma::Task.new }
|
let(:task) { ProformaXML::Task.new }
|
||||||
let(:user) { build(:teacher) }
|
let(:user) { build(:teacher) }
|
||||||
let(:exercise) { build(:dummy) }
|
let(:exercise) { build(:dummy) }
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
before { create(:dot_txt) }
|
before { create(:dot_txt) }
|
||||||
|
|
||||||
let(:task) do
|
let(:task) do
|
||||||
Proforma::Task.new(
|
ProformaXML::Task.new(
|
||||||
title: 'title',
|
title: 'title',
|
||||||
description: 'description',
|
description: 'description',
|
||||||
proglang: {name: 'python', version: '3.4'},
|
proglang: {name: 'python', version: '3.4'},
|
||||||
@ -123,7 +123,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
context 'when task has a file' do
|
context 'when task has a file' do
|
||||||
let(:files) { [file] }
|
let(:files) { [file] }
|
||||||
let(:file) do
|
let(:file) do
|
||||||
Proforma::TaskFile.new(
|
ProformaXML::TaskFile.new(
|
||||||
id: 'id',
|
id: 'id',
|
||||||
content:,
|
content:,
|
||||||
filename:,
|
filename:,
|
||||||
@ -232,7 +232,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when file is a model-solution-placeholder (needed by proforma until issue #5 is resolved)' do
|
context 'when file is a model-solution-placeholder (needed by proforma until issue #5 is resolved)' do
|
||||||
let(:file) { Proforma::TaskFile.new(id: 'ms-placeholder-file') }
|
let(:file) { ProformaXML::TaskFile.new(id: 'ms-placeholder-file') }
|
||||||
|
|
||||||
it 'leaves exercise_files empty' do
|
it 'leaves exercise_files empty' do
|
||||||
expect(convert_to_exercise_service.files).to be_empty
|
expect(convert_to_exercise_service.files).to be_empty
|
||||||
@ -269,14 +269,14 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
context 'when task has a model-solution' do
|
context 'when task has a model-solution' do
|
||||||
let(:model_solutions) { [model_solution] }
|
let(:model_solutions) { [model_solution] }
|
||||||
let(:model_solution) do
|
let(:model_solution) do
|
||||||
Proforma::ModelSolution.new(
|
ProformaXML::ModelSolution.new(
|
||||||
id: 'ms-id',
|
id: 'ms-id',
|
||||||
files: ms_files
|
files: ms_files
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let(:ms_files) { [ms_file] }
|
let(:ms_files) { [ms_file] }
|
||||||
let(:ms_file) do
|
let(:ms_file) do
|
||||||
Proforma::TaskFile.new(
|
ProformaXML::TaskFile.new(
|
||||||
id: 'ms-file',
|
id: 'ms-file',
|
||||||
content: 'content',
|
content: 'content',
|
||||||
filename: 'filename.txt',
|
filename: 'filename.txt',
|
||||||
@ -296,14 +296,14 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
context 'when task has two model-solutions' do
|
context 'when task has two model-solutions' do
|
||||||
let(:model_solutions) { [model_solution, model_solution2] }
|
let(:model_solutions) { [model_solution, model_solution2] }
|
||||||
let(:model_solution2) do
|
let(:model_solution2) do
|
||||||
Proforma::ModelSolution.new(
|
ProformaXML::ModelSolution.new(
|
||||||
id: 'ms-id-2',
|
id: 'ms-id-2',
|
||||||
files: ms_files2
|
files: ms_files2
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let(:ms_files2) { [ms_file2] }
|
let(:ms_files2) { [ms_file2] }
|
||||||
let(:ms_file2) do
|
let(:ms_file2) do
|
||||||
Proforma::TaskFile.new(
|
ProformaXML::TaskFile.new(
|
||||||
id: 'ms-file-2',
|
id: 'ms-file-2',
|
||||||
content: 'content',
|
content: 'content',
|
||||||
filename: 'filename.txt',
|
filename: 'filename.txt',
|
||||||
@ -324,7 +324,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
context 'when task has a test' do
|
context 'when task has a test' do
|
||||||
let(:tests) { [test] }
|
let(:tests) { [test] }
|
||||||
let(:test) do
|
let(:test) do
|
||||||
Proforma::Test.new(
|
ProformaXML::Test.new(
|
||||||
id: 'test-id',
|
id: 'test-id',
|
||||||
title: 'title',
|
title: 'title',
|
||||||
description: 'description',
|
description: 'description',
|
||||||
@ -342,7 +342,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
|
|
||||||
let(:test_files) { [test_file] }
|
let(:test_files) { [test_file] }
|
||||||
let(:test_file) do
|
let(:test_file) do
|
||||||
Proforma::TaskFile.new(
|
ProformaXML::TaskFile.new(
|
||||||
id: 'test_file_id',
|
id: 'test_file_id',
|
||||||
content: 'testfile-content',
|
content: 'testfile-content',
|
||||||
filename: 'testfile.txt',
|
filename: 'testfile.txt',
|
||||||
@ -388,7 +388,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
context 'when task has multiple tests' do
|
context 'when task has multiple tests' do
|
||||||
let(:tests) { [test, test2] }
|
let(:tests) { [test, test2] }
|
||||||
let(:test2) do
|
let(:test2) do
|
||||||
Proforma::Test.new(
|
ProformaXML::Test.new(
|
||||||
files: test_files2,
|
files: test_files2,
|
||||||
meta_data: {
|
meta_data: {
|
||||||
CodeOcean: {
|
CodeOcean: {
|
||||||
@ -401,7 +401,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
end
|
end
|
||||||
let(:test_files2) { [test_file2] }
|
let(:test_files2) { [test_file2] }
|
||||||
let(:test_file2) do
|
let(:test_file2) do
|
||||||
Proforma::TaskFile.new(
|
ProformaXML::TaskFile.new(
|
||||||
id: 'test_file_id2',
|
id: 'test_file_id2',
|
||||||
content: 'testfile-content',
|
content: 'testfile-content',
|
||||||
filename: 'testfile.txt',
|
filename: 'testfile.txt',
|
||||||
@ -450,7 +450,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
context 'with file, model solution and test' do
|
context 'with file, model solution and test' do
|
||||||
let(:files) { [file] }
|
let(:files) { [file] }
|
||||||
let(:file) do
|
let(:file) do
|
||||||
Proforma::TaskFile.new(
|
ProformaXML::TaskFile.new(
|
||||||
id: 'id',
|
id: 'id',
|
||||||
content: 'content',
|
content: 'content',
|
||||||
filename: 'filename.txt',
|
filename: 'filename.txt',
|
||||||
@ -462,7 +462,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
end
|
end
|
||||||
let(:tests) { [test] }
|
let(:tests) { [test] }
|
||||||
let(:test) do
|
let(:test) do
|
||||||
Proforma::Test.new(
|
ProformaXML::Test.new(
|
||||||
id: 'test-id',
|
id: 'test-id',
|
||||||
title: 'title',
|
title: 'title',
|
||||||
description: 'description',
|
description: 'description',
|
||||||
@ -479,7 +479,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
end
|
end
|
||||||
let(:test_files) { [test_file] }
|
let(:test_files) { [test_file] }
|
||||||
let(:test_file) do
|
let(:test_file) do
|
||||||
Proforma::TaskFile.new(
|
ProformaXML::TaskFile.new(
|
||||||
id: 'test_file_id',
|
id: 'test_file_id',
|
||||||
content: 'testfile-content',
|
content: 'testfile-content',
|
||||||
filename: 'testfile.txt',
|
filename: 'testfile.txt',
|
||||||
@ -492,14 +492,14 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
end
|
end
|
||||||
let(:model_solutions) { [model_solution] }
|
let(:model_solutions) { [model_solution] }
|
||||||
let(:model_solution) do
|
let(:model_solution) do
|
||||||
Proforma::ModelSolution.new(
|
ProformaXML::ModelSolution.new(
|
||||||
id: 'ms-id',
|
id: 'ms-id',
|
||||||
files: ms_files
|
files: ms_files
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let(:ms_files) { [ms_file] }
|
let(:ms_files) { [ms_file] }
|
||||||
let(:ms_file) do
|
let(:ms_file) do
|
||||||
Proforma::TaskFile.new(
|
ProformaXML::TaskFile.new(
|
||||||
id: 'ms-file',
|
id: 'ms-file',
|
||||||
content: 'ms-content',
|
content: 'ms-content',
|
||||||
filename: 'filename.txt',
|
filename: 'filename.txt',
|
||||||
|
@ -24,13 +24,13 @@ describe ProformaService::ExportTask do
|
|||||||
describe '#execute' do
|
describe '#execute' do
|
||||||
subject(:export_task) { described_class.call(exercise:) }
|
subject(:export_task) { described_class.call(exercise:) }
|
||||||
|
|
||||||
let(:task) { Proforma::Task.new }
|
let(:task) { ProformaXML::Task.new }
|
||||||
let(:exercise) { build(:dummy) }
|
let(:exercise) { build(:dummy) }
|
||||||
let(:exporter) { instance_double(Proforma::Exporter, perform: 'zip') }
|
let(:exporter) { instance_double(ProformaXML::Exporter, perform: 'zip') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(ProformaService::ConvertExerciseToTask).to receive(:call).with(exercise:).and_return(task)
|
allow(ProformaService::ConvertExerciseToTask).to receive(:call).with(exercise:).and_return(task)
|
||||||
allow(Proforma::Exporter).to receive(:new).with(task:, custom_namespaces: [{prefix: 'CodeOcean', uri: 'codeocean.openhpi.de'}]).and_return(exporter)
|
allow(ProformaXML::Exporter).to receive(:new).with(task:, custom_namespaces: [{prefix: 'CodeOcean', uri: 'codeocean.openhpi.de'}]).and_return(exporter)
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
@ -160,7 +160,7 @@ describe ProformaService::Import do
|
|||||||
let(:import_user) { create(:teacher) }
|
let(:import_user) { create(:teacher) }
|
||||||
|
|
||||||
it 'raises a proforma error' do
|
it 'raises a proforma error' do
|
||||||
expect { imported_exercise.save! }.to raise_error Proforma::ExerciseNotOwned
|
expect { imported_exercise.save! }.to raise_error ProformaXML::ExerciseNotOwned
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user