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