proformaxml 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop/layout.yml +39 -0
- data/.rubocop/lint.yml +14 -0
- data/.rubocop/metrics.yml +31 -0
- data/.rubocop/rails.yml +4 -0
- data/.rubocop/rspec.yml +27 -0
- data/.rubocop/style.yml +74 -0
- data/.rubocop.yml +30 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +168 -0
- data/Guardfile +44 -0
- data/LICENSE.txt +21 -0
- data/README.md +212 -0
- data/Rakefile +11 -0
- data/SECURITY.md +14 -0
- data/assets/schemas/proforma-2.0.xsd +1038 -0
- data/assets/schemas/proforma-2.1.xsd +1084 -0
- data/assets/schemas/proforma-java-checkstyle.xsd +11 -0
- data/assets/schemas/proforma-regexptest.xsd +50 -0
- data/assets/schemas/proforma-unittest.xsd +12 -0
- data/lib/proformaxml/errors.rb +9 -0
- data/lib/proformaxml/helpers/export_helpers.rb +79 -0
- data/lib/proformaxml/helpers/import_helpers.rb +114 -0
- data/lib/proformaxml/models/base.rb +11 -0
- data/lib/proformaxml/models/model_solution.rb +12 -0
- data/lib/proformaxml/models/task.rb +29 -0
- data/lib/proformaxml/models/task_file.rb +11 -0
- data/lib/proformaxml/models/test.rb +12 -0
- data/lib/proformaxml/services/exporter.rb +140 -0
- data/lib/proformaxml/services/importer.rb +135 -0
- data/lib/proformaxml/services/validator.rb +52 -0
- data/lib/proformaxml/version.rb +5 -0
- data/lib/proformaxml.rb +24 -0
- data/proformaxml.gemspec +37 -0
- metadata +179 -0
data/README.md
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
# ProformaXML
|
2
|
+
|
3
|
+
[![Build Status](https://github.com/openHPI/proformaxml/workflows/CI/badge.svg)](https://github.com/openHPI/proformaxml/actions?query=workflow%3ACI)
|
4
|
+
[![codecov](https://codecov.io/gh/openHPI/proformaxml/branch/main/graph/badge.svg?token=n1rDXnCezH)](https://codecov.io/gh/openHPI/proformaxml)
|
5
|
+
|
6
|
+
This gem offers a Ruby implementation of the [ProFormA XML standard](https://github.com/ProFormA/proformaxml), an XML exchange format for programming exercises. This gem includes a datastructure and XML-(de)serializer.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add these lines to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'proformaxml'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
```
|
19
|
+
$ bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
Note: Removing support for ancient Ruby or Rails versions will not result in a new major. Please be extra careful when using ancient Ruby or Rails versions and updating gems.
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Create Task
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
task = ProformaXML::Task.new(title: 'title')
|
30
|
+
```
|
31
|
+
Call Exporter to serialize to XML.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
ProformaXML::Exporter.new(task: task).perform
|
35
|
+
```
|
36
|
+
It returns a StringIO of a zip-file which includes the XML and any external files (TaskFiles will be saved in the XML up to a size of 50kb, anything larger will be its own file in the zip)
|
37
|
+
`ProformaXML::Exporter` has the following optional parameters:
|
38
|
+
- `custom_namespaces`: expects an array with hashes with the following attributes:
|
39
|
+
- `prefix`
|
40
|
+
- `uri`
|
41
|
+
- `version`: sets the ProFormA version of the generated XML
|
42
|
+
|
43
|
+
Call Importer to deserialize from XML
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
result = ProformaXML::Importer.new(zip: zip_file).perform
|
47
|
+
task = result[:task]
|
48
|
+
custom_namespaces = result[:custom_namespaces]
|
49
|
+
```
|
50
|
+
the `zip_file` has to be openable by `Zip::File.open(zip: zip.path)`, otherwise `ProformaXML::InvalidZip` will be raised
|
51
|
+
`ProformaXML::Importer` has the following optional parameter:
|
52
|
+
- `expected_version`: if the version of the XML doesn't match this value `ProformaXML::InvalidZip` will be raised
|
53
|
+
|
54
|
+
## Example
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
ProformaXML::Task.new(
|
58
|
+
title: 'title',
|
59
|
+
description: 'description',
|
60
|
+
internal_description: 'internal_description',
|
61
|
+
proglang: {name: 'proglang_name', version: '123'},
|
62
|
+
meta_data: {
|
63
|
+
CodeOcean: {
|
64
|
+
meta_data_key: 'meta_data_content',
|
65
|
+
secrets: {
|
66
|
+
server_key: 'the key',
|
67
|
+
other_key: 'another key'
|
68
|
+
}
|
69
|
+
}
|
70
|
+
},
|
71
|
+
files: [
|
72
|
+
ProformaXML::TaskFile.new(
|
73
|
+
id: 'file_id_1',
|
74
|
+
content: 'public static fileContent(){}',
|
75
|
+
filename: 'file_content.java',
|
76
|
+
used_by_grader: false,
|
77
|
+
visible: 'delayed',
|
78
|
+
usage_by_lms: 'edit',
|
79
|
+
binary: false,
|
80
|
+
internal_description: 'internal_description',
|
81
|
+
mimetype: 'text/plain'
|
82
|
+
),
|
83
|
+
ProformaXML::TaskFile.new(
|
84
|
+
id: 'file_id_2',
|
85
|
+
content: 'BINARY IMAGE CONTENT',
|
86
|
+
filename: 'image.jpg',
|
87
|
+
used_by_grader: false,
|
88
|
+
visible: 'yes',
|
89
|
+
usage_by_lms: 'display',
|
90
|
+
binary: true,
|
91
|
+
internal_description: 'internal_description',
|
92
|
+
mimetype: 'image/jpeg'
|
93
|
+
)
|
94
|
+
],
|
95
|
+
tests: [
|
96
|
+
ProformaXML::Test.new(
|
97
|
+
id: 'test_id_1',
|
98
|
+
title: 'test title',
|
99
|
+
files: [
|
100
|
+
ProformaXML::TaskFile.new(
|
101
|
+
id: 'test_file_1',
|
102
|
+
content: 'public static assert123(){}',
|
103
|
+
filename: 'junit/assert123.java',
|
104
|
+
used_by_grader: true,
|
105
|
+
visible: 'no',
|
106
|
+
binary: false,
|
107
|
+
internal_description: 'internal_description',
|
108
|
+
)
|
109
|
+
],
|
110
|
+
meta_data: {
|
111
|
+
CodeOcean: {
|
112
|
+
entry_point: 'junit/assert123.java'
|
113
|
+
}
|
114
|
+
}
|
115
|
+
)
|
116
|
+
],
|
117
|
+
uuid: '2c8ee23e-fa98-4ea9-b6a5-9a0066ebac1f',
|
118
|
+
parent_uuid: 'abf097f5-0df0-468d-8ce4-13460c34cd3b',
|
119
|
+
language: 'de',
|
120
|
+
model_solutions: [
|
121
|
+
ProformaXML::ModelSolution.new(
|
122
|
+
id: 'model_solution_id_1',
|
123
|
+
files: [
|
124
|
+
ProformaXML::TaskFile.new(
|
125
|
+
id: 'model_solution_test_id_1',
|
126
|
+
content: 'public static fileContent(){ syso("A"); }',
|
127
|
+
filename: 'this_is_how_its_done.java',
|
128
|
+
used_by_grader: false,
|
129
|
+
usage_by_lms: 'display',
|
130
|
+
visible: 'delayed',
|
131
|
+
binary: false,
|
132
|
+
internal_description: 'internal_description'
|
133
|
+
)
|
134
|
+
]
|
135
|
+
)
|
136
|
+
],
|
137
|
+
)
|
138
|
+
```
|
139
|
+
Generated XML from task above with `custom_namespaces: [{prefix: 'CodeOcean', uri: 'codeocean.openhpi.de'}]`
|
140
|
+
```xml
|
141
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
142
|
+
<task xmlns="urn:proforma:v2.0.1" xmlns:CodeOcean="codeocean.openhpi.de" uuid="2c8ee23e-fa98-4ea9-b6a5-9a0066ebac1f" lang="de" parent-uuid="abf097f5-0df0-468d-8ce4-13460c34cd3b">
|
143
|
+
<title>title</title>
|
144
|
+
<description>description</description>
|
145
|
+
<internal-description>internal_description</internal-description>
|
146
|
+
<proglang version="123">proglang_name</proglang>
|
147
|
+
<files>
|
148
|
+
<file id="file_id_1" used-by-grader="false" visible="delayed" usage-by-lms="edit" mimetype="text/plain">
|
149
|
+
<embedded-txt-file filename="file_content.java">public static fileContent(){}</embedded-txt-file>
|
150
|
+
<internal-description>internal_description</internal-description>
|
151
|
+
</file>
|
152
|
+
<file id="file_id_2" used-by-grader="false" visible="yes" usage-by-lms="display" mimetype="image/jpeg">
|
153
|
+
<embedded-bin-file filename="image.jpg">QklOQVJZIElNQUdFIENPTlRFTlQ=
|
154
|
+
</embedded-bin-file>
|
155
|
+
<internal-description>internal_description</internal-description>
|
156
|
+
</file>
|
157
|
+
<file id="model_solution_test_id_1" used-by-grader="false" visible="delayed" usage-by-lms="display">
|
158
|
+
<embedded-txt-file filename="this_is_how_its_done.java">public static fileContent(){ syso("A"); }</embedded-txt-file>
|
159
|
+
<internal-description>internal_description</internal-description>
|
160
|
+
</file>
|
161
|
+
<file id="test_file_1" used-by-grader="true" visible="no">
|
162
|
+
<embedded-txt-file filename="junit/assert123.java">public static assert123(){}</embedded-txt-file>
|
163
|
+
<internal-description>internal_description</internal-description>
|
164
|
+
</file>
|
165
|
+
</files>
|
166
|
+
<model-solutions>
|
167
|
+
<model-solution id="model_solution_id_1">
|
168
|
+
<filerefs>
|
169
|
+
<fileref refid="model_solution_test_id_1"/>
|
170
|
+
</filerefs>
|
171
|
+
</model-solution>
|
172
|
+
</model-solutions>
|
173
|
+
<tests>
|
174
|
+
<test id="test_id_1">
|
175
|
+
<title>test title</title>
|
176
|
+
<test-type/>
|
177
|
+
<test-configuration>
|
178
|
+
<filerefs>
|
179
|
+
<fileref refid="test_file_1"/>
|
180
|
+
</filerefs>
|
181
|
+
<test-meta-data>
|
182
|
+
<CodeOcean:entry_point>junit/assert123.java</CodeOcean:entry_point>
|
183
|
+
</test-meta-data>
|
184
|
+
</test-configuration>
|
185
|
+
</test>
|
186
|
+
</tests>
|
187
|
+
<meta-data>
|
188
|
+
<CodeOcean:meta_data_key>meta_data_content</CodeOcean:meta_data_key>
|
189
|
+
<CodeOcean:secrets>
|
190
|
+
<CodeOcean:server_key>the key</CodeOcean:server_key>
|
191
|
+
<CodeOcean:other_key>another key</CodeOcean:other_key>
|
192
|
+
</CodeOcean:secrets>
|
193
|
+
</meta-data>
|
194
|
+
</task>
|
195
|
+
```
|
196
|
+
## Development
|
197
|
+
|
198
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
199
|
+
|
200
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
201
|
+
|
202
|
+
## Contributing
|
203
|
+
|
204
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/openHPI/proformaxml. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/openHPI/proformaxml/blob/main/CODE_OF_CONDUCT.md).
|
205
|
+
|
206
|
+
## License
|
207
|
+
|
208
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
209
|
+
|
210
|
+
## Code of Conduct
|
211
|
+
|
212
|
+
Everyone interacting in this project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/openHPI/proformaxml/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/SECURITY.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
To receive fixes for security vulnerabilities it is required to always upgrade to the latest version of proformaxml.
|
6
|
+
See https://github.com/openHPI/proformaxml/releases for the latest version.
|
7
|
+
|
8
|
+
## Reporting a Vulnerability
|
9
|
+
|
10
|
+
If you have found a vulnerability or you are uncertain whether what you have discovered is a vulnerability,
|
11
|
+
please send an email to sebastian.serth@hpi.de ([GPG Key](https://github.com/mrserth.gpg)).
|
12
|
+
|
13
|
+
If you have a patch for the issue please use `git format-patch` and attach it to the email. Please do not open an issue or
|
14
|
+
pull request on GitHub as that may disclose sensitive details around the vulnerability.
|