proformaxml 0.10.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/lib/proformaxml/helpers/export_helpers.rb +7 -5
- data/lib/proformaxml/helpers/import_helpers.rb +4 -1
- data/lib/proformaxml/models/task.rb +2 -2
- data/lib/proformaxml/services/exporter.rb +4 -1
- data/lib/proformaxml/services/importer.rb +10 -0
- data/lib/proformaxml/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c50e2e72dc70055556ef14a9be087d9f557aeac25eb4c8a53c28f1132baaf20e
|
4
|
+
data.tar.gz: 392e5f8391908e2221a423b8ae69d97e25edc6ea184ed987e59487d9acf9a715
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aff94d81a98f927cd04cd85b9c0fed428fb93e0496e968d0079152e2a50269e3b6cced82a17cec7002ee0fb0fbc3c964a7a85513f597541f4ade0e91eeb3bc7d
|
7
|
+
data.tar.gz: e54b57f55f6731036eb9659357d734e991f2f3dafd63083e56119d73be12cea07ba779ead3c7e5c921ccbaf4e258d3042054281bc2a21720c00a3f2288b70a92
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
proformaxml (0.
|
4
|
+
proformaxml (1.0.0)
|
5
5
|
activemodel (>= 5.2.3, < 8.0.0)
|
6
6
|
activesupport (>= 5.2.3, < 8.0.0)
|
7
7
|
dachsfisch (>= 0.1.0, < 1.0.0)
|
@@ -11,9 +11,9 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
activemodel (7.0.
|
15
|
-
activesupport (= 7.0.
|
16
|
-
activesupport (7.0.
|
14
|
+
activemodel (7.0.8)
|
15
|
+
activesupport (= 7.0.8)
|
16
|
+
activesupport (7.0.8)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 1.6, < 2)
|
19
19
|
minitest (>= 5.1)
|
@@ -27,7 +27,7 @@ GEM
|
|
27
27
|
nokogiri (>= 1.14.1, < 2.0.0)
|
28
28
|
diff-lcs (1.5.0)
|
29
29
|
docile (1.4.0)
|
30
|
-
factory_bot (6.
|
30
|
+
factory_bot (6.3.0)
|
31
31
|
activesupport (>= 5.0.0)
|
32
32
|
ffi (1.15.5)
|
33
33
|
formatador (1.1.0)
|
@@ -55,7 +55,7 @@ GEM
|
|
55
55
|
lumberjack (1.2.9)
|
56
56
|
method_source (1.0.0)
|
57
57
|
mini_portile2 (2.8.4)
|
58
|
-
minitest (5.
|
58
|
+
minitest (5.20.0)
|
59
59
|
nenv (0.3.0)
|
60
60
|
nokogiri (1.15.4)
|
61
61
|
mini_portile2 (~> 2.8.2)
|
@@ -99,7 +99,7 @@ GEM
|
|
99
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
100
100
|
rspec-support (~> 3.12.0)
|
101
101
|
rspec-support (3.12.1)
|
102
|
-
rubocop (1.56.
|
102
|
+
rubocop (1.56.2)
|
103
103
|
base64 (~> 0.1.1)
|
104
104
|
json (~> 2.3)
|
105
105
|
language_server-protocol (>= 3.17.0)
|
@@ -26,7 +26,7 @@ module ProformaXML
|
|
26
26
|
def add_test_configuration(xml, test)
|
27
27
|
xml.send(:'test-configuration') do
|
28
28
|
add_filerefs(xml, test) if test.files
|
29
|
-
|
29
|
+
add_dachsfisch_node(xml, test.configuration)
|
30
30
|
if test.meta_data
|
31
31
|
xml.send(:'test-meta-data') do
|
32
32
|
meta_data(xml, test.meta_data)
|
@@ -55,10 +55,12 @@ module ProformaXML
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
def add_dachsfisch_node(xml, dachsfisch_node)
|
59
|
+
return if dachsfisch_node.nil?
|
60
|
+
|
61
|
+
xml_snippet = Dachsfisch::JSON2XMLConverter.perform(json: dachsfisch_node.to_json)
|
62
|
+
dachsfisch_node.flat_map {|_, val| val['@xmlns'].to_a }.uniq.each do |namespace|
|
63
|
+
xml.doc.root.add_namespace(namespace[0], namespace[1]) unless namespace[0] == '$'
|
62
64
|
end
|
63
65
|
|
64
66
|
xml << xml_snippet
|
@@ -97,7 +97,10 @@ module ProformaXML
|
|
97
97
|
|
98
98
|
def convert_xml_node_to_json(any_node)
|
99
99
|
xml_snippet = Nokogiri::XML::DocumentFragment.new(Nokogiri::XML::Document.new, any_node)
|
100
|
-
|
100
|
+
unless any_node.namespace.prefix.nil?
|
101
|
+
xml_snippet.children.first.add_namespace_definition(any_node.namespace.prefix,
|
102
|
+
any_node.namespace.href)
|
103
|
+
end
|
101
104
|
JSON.parse(Dachsfisch::XML2JSONConverter.perform(xml: xml_snippet.to_xml))
|
102
105
|
end
|
103
106
|
|
@@ -8,8 +8,8 @@ require 'proformaxml/errors'
|
|
8
8
|
|
9
9
|
module ProformaXML
|
10
10
|
class Task < Base
|
11
|
-
attr_accessor :title, :description, :internal_description, :proglang, :uuid, :parent_uuid,
|
12
|
-
:
|
11
|
+
attr_accessor :title, :description, :internal_description, :proglang, :uuid, :parent_uuid, :language,
|
12
|
+
:model_solutions, :files, :tests, :meta_data, :submission_restrictions, :external_resources, :grading_hints
|
13
13
|
|
14
14
|
def initialize(attributes = {})
|
15
15
|
super
|
@@ -24,7 +24,7 @@ module ProformaXML
|
|
24
24
|
|
25
25
|
raise PostGenerateValidationError.new(errors) if errors.any?
|
26
26
|
|
27
|
-
# File.
|
27
|
+
# File.binwrite('../testfile.zip', write_to_zip(xmldoc).string)
|
28
28
|
write_to_zip(xmldoc)
|
29
29
|
end
|
30
30
|
|
@@ -51,9 +51,12 @@ module ProformaXML
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def add_objects_to_xml(xml)
|
54
|
+
add_dachsfisch_node(xml, @task.submission_restrictions)
|
54
55
|
xml.files { files(xml) }
|
56
|
+
add_dachsfisch_node(xml, @task.external_resources)
|
55
57
|
xml.send(:'model-solutions') { model_solutions(xml) } if @task.model_solutions.any? || @version == '2.0'
|
56
58
|
xml.tests { tests(xml) }
|
59
|
+
add_dachsfisch_node(xml, @task.grading_hints)
|
57
60
|
end
|
58
61
|
|
59
62
|
def files(xml)
|
@@ -44,6 +44,7 @@ module ProformaXML
|
|
44
44
|
set_model_solutions
|
45
45
|
set_tests
|
46
46
|
set_meta_data
|
47
|
+
set_extra_data
|
47
48
|
end
|
48
49
|
|
49
50
|
def set_namespaces
|
@@ -86,6 +87,15 @@ module ProformaXML
|
|
86
87
|
@task.meta_data = meta_data(meta_data_node, use_namespace: true) if meta_data_node.text.present?
|
87
88
|
end
|
88
89
|
|
90
|
+
def set_extra_data
|
91
|
+
submission_restrictions_node = @task_node.xpath('xmlns:submission-restrictions').first
|
92
|
+
@task.submission_restrictions = convert_xml_node_to_json(submission_restrictions_node) unless submission_restrictions_node.nil?
|
93
|
+
external_resources_node = @task_node.xpath('xmlns:external-resources').first
|
94
|
+
@task.external_resources = convert_xml_node_to_json(external_resources_node) unless external_resources_node.nil?
|
95
|
+
grading_hints_node = @task_node.xpath('xmlns:grading-hints').first
|
96
|
+
@task.grading_hints = convert_xml_node_to_json(grading_hints_node) unless grading_hints_node.nil?
|
97
|
+
end
|
98
|
+
|
89
99
|
def add_model_solution(model_solution_node)
|
90
100
|
model_solution = ModelSolution.new
|
91
101
|
model_solution.id = model_solution_node.attributes['id'].value
|
data/lib/proformaxml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proformaxml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karol
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
|
-
rubygems_version: 3.4.
|
175
|
+
rubygems_version: 3.4.6
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: Implements parts of ProFormA-XML specification
|