Update from proforma to proformaxml

This commit is contained in:
Sebastian Serth
2023-08-23 00:10:11 +02:00
committed by Sebastian Serth
parent 41e75ca385
commit 245c3dba8c
12 changed files with 45 additions and 56 deletions

View File

@ -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)

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module Proforma
module ProformaXML
class ExerciseNotOwned < StandardError; end
end

View File

@ -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',

View File

@ -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

View File

@ -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