Skip to content

Commit d8bf599

Browse files
authored
Merge pull request #257 from openHPI/190-update-proforma-to-version-2-1
use newest proforma schema, bump version to 0.8.0
2 parents 4558f5b + 5b4c61c commit d8bf599

File tree

9 files changed

+159
-112
lines changed

9 files changed

+159
-112
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
proforma (0.7.1)
4+
proforma (0.8.0)
55
activemodel (>= 5.2.3, < 8.0.0)
66
activesupport (>= 5.2.3, < 8.0.0)
77
nokogiri (>= 1.10.2, < 2.0.0)
Lines changed: 74 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:proforma:v2.0.1" xmlns:tns="urn:proforma:v2.0.1"
3-
elementFormDefault="qualified">
2+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:proforma:v2.1" xmlns:tns="urn:proforma:v2.1" elementFormDefault="qualified">
43

54
<xs:element name="task" type="tns:task-type">
65
<xs:key name="task-fileids">
@@ -113,6 +112,28 @@
113112
</xs:choice>
114113
</xs:group>
115114

115+
<xs:attributeGroup name="resource-properties">
116+
<xs:attribute name="used-by-grader" type="xs:boolean" use="required"/>
117+
<xs:attribute name="visible" use="required">
118+
<xs:simpleType>
119+
<xs:restriction base="xs:string">
120+
<xs:enumeration value="yes"/>
121+
<xs:enumeration value="no"/>
122+
<xs:enumeration value="delayed"/>
123+
</xs:restriction>
124+
</xs:simpleType>
125+
</xs:attribute>
126+
<xs:attribute name="usage-by-lms" default="download">
127+
<xs:simpleType>
128+
<xs:restriction base="xs:string">
129+
<xs:enumeration value="edit"/>
130+
<xs:enumeration value="display"/>
131+
<xs:enumeration value="download"/>
132+
</xs:restriction>
133+
</xs:simpleType>
134+
</xs:attribute>
135+
</xs:attributeGroup>
136+
116137
<xs:complexType name="filerefs-type">
117138
<xs:sequence maxOccurs="unbounded">
118139
<xs:element name="fileref" type="tns:fileref-type"/>
@@ -200,14 +221,14 @@
200221
<xs:element name="combine-ref" type="tns:grades-combine-ref-child-type"/>
201222
</xs:choice>
202223
</xs:sequence>
203-
<xs:attribute name="id" type="xs:string" use="optional">
224+
<xs:attribute name="id" type="xs:string">
204225
<xs:annotation>
205226
<xs:documentation xml:lang="en">Node identifier. It is optional for the "root" node and required for "combine"
206227
nodes.
207228
</xs:documentation>
208229
</xs:annotation>
209230
</xs:attribute>
210-
<xs:attribute name="function" use="optional" default="min">
231+
<xs:attribute name="function" default="min">
211232
<xs:annotation>
212233
<xs:documentation xml:lang="en">Accumulator function that is used to condense several sub results to a single
213234
result.
@@ -286,7 +307,7 @@
286307
</xs:element>
287308
</xs:choice>
288309
</xs:sequence>
289-
<xs:attribute name="weight" type="xs:double" use="optional">
310+
<xs:attribute name="weight" type="xs:double">
290311
<xs:annotation>
291312
<xs:documentation xml:lang="en">Specifies a weight that is multiplied to the sub result of the pointed-at node
292313
when flowing into the accumulator function. The pointed-at node is a test or a combine node. When calculating
@@ -337,7 +358,7 @@
337358
<xs:documentation xml:lang="en">The id of the pointed-at test.</xs:documentation>
338359
</xs:annotation>
339360
</xs:attribute>
340-
<xs:attribute name="sub-ref" type="xs:string" use="optional">
361+
<xs:attribute name="sub-ref" type="xs:string">
341362
<xs:annotation>
342363
<xs:documentation xml:lang="en">If the pointed at test exhibits sub test results, this points to one of the
343364
sub results. Examples are individual test cases in a unit test specification, individual violation rules
@@ -554,7 +575,7 @@
554575
<xs:documentation xml:lang="en">The id of the pointed-at test.</xs:documentation>
555576
</xs:annotation>
556577
</xs:attribute>
557-
<xs:attribute name="sub-ref" type="xs:string" use="optional">
578+
<xs:attribute name="sub-ref" type="xs:string">
558579
<xs:annotation>
559580
<xs:documentation xml:lang="en">If the pointed at test exhibits sub test results, this points to one of the
560581
sub results. Examples are individual test cases in a unit test specification, individual violation rules
@@ -592,7 +613,7 @@
592613
<xs:element name="submission-restrictions" type="tns:submission-restrictions-type" minOccurs="0"/>
593614
<xs:element name="files" type="tns:task-files-type"/>
594615
<xs:element name="external-resources" type="tns:external-resources-type" minOccurs="0"/>
595-
<xs:element name="model-solutions" type="tns:model-solutions-type"/>
616+
<xs:element name="model-solutions" type="tns:model-solutions-type" minOccurs="0"/>
596617
<xs:element name="tests" type="tns:tests-type"/>
597618
<xs:element name="grading-hints" type="tns:grading-hints-type" minOccurs="0">
598619
<xs:key name="task-gh-combineids">
@@ -607,29 +628,39 @@
607628
<xs:element name="meta-data" type="tns:task-meta-data-type"/>
608629
</xs:sequence>
609630
<xs:attribute name="uuid" type="xs:string" use="required"/>
610-
<xs:attribute name="parent-uuid" type="xs:string" use="optional"/>
631+
<xs:attribute name="parent-uuid" type="xs:string"/>
611632
<xs:attribute name="lang" type="xs:language"/>
612633
</xs:complexType>
613634

614635
<xs:complexType name="submission-restrictions-type">
615-
<xs:sequence minOccurs="0" maxOccurs="unbounded">
616-
<xs:element name="file-restriction" type="tns:file-restr-type"/>
636+
<xs:sequence>
637+
<xs:element name="file-restriction" type="tns:file-restr-type" minOccurs="0" maxOccurs="unbounded"/>
638+
<xs:element name="description" type="tns:description-type" minOccurs="0"/>
639+
<xs:element name="internal-description" type="tns:description-type" minOccurs="0"/>
617640
</xs:sequence>
618-
<xs:attribute name="max-size" type="xs:positiveInteger" use="optional"/>
641+
<xs:attribute name="max-size" type="xs:positiveInteger"/>
619642
</xs:complexType>
620643

621644
<xs:complexType name="file-restr-type">
622645
<xs:simpleContent>
623646
<xs:extension base="xs:string">
624-
<xs:attribute name="required" type="xs:boolean" use="optional" default="true"/>
625-
<xs:attribute name="pattern-format" use="optional" default="none">
647+
<xs:attribute name="use" default="required">
648+
<xs:simpleType>
649+
<xs:restriction base="xs:string">
650+
<xs:enumeration value="required"/>
651+
<xs:enumeration value="optional"/>
652+
<xs:enumeration value="prohibited"/>
653+
</xs:restriction>
654+
</xs:simpleType>
655+
</xs:attribute>
656+
<xs:attribute name="pattern-format" default="none">
626657
<xs:simpleType>
627658
<xs:restriction base="xs:string">
628659
<xs:enumeration value="none"/>
629660
<xs:enumeration value="posix-ere"/>
630661
</xs:restriction>
631662
</xs:simpleType>
632-
</xs:attribute>
663+
</xs:attribute>
633664
</xs:extension>
634665
</xs:simpleContent>
635666
</xs:complexType>
@@ -663,8 +694,8 @@
663694
A list of existing programming languages is
664695
available in the white paper appendix.
665696
</xs:documentation>
666-
</xs:annotation>
667-
<xs:attribute name="version" type="xs:string" use="required"/>
697+
</xs:annotation>
698+
<xs:attribute name="version" type="xs:string" use="required"/>
668699
</xs:extension>
669700
</xs:simpleContent>
670701
</xs:complexType>
@@ -675,26 +706,8 @@
675706
<xs:element name="internal-description" type="tns:description-type" minOccurs="0"/>
676707
</xs:sequence>
677708
<xs:attribute name="id" type="xs:string" use="required"/>
678-
<xs:attribute name="mimetype" type="xs:string" use="optional"/>
679-
<xs:attribute name="used-by-grader" type="xs:boolean" use="required"/>
680-
<xs:attribute name="visible" use="required">
681-
<xs:simpleType>
682-
<xs:restriction base="xs:string">
683-
<xs:enumeration value="yes"/>
684-
<xs:enumeration value="no"/>
685-
<xs:enumeration value="delayed"/>
686-
</xs:restriction>
687-
</xs:simpleType>
688-
</xs:attribute>
689-
<xs:attribute name="usage-by-lms" use="optional" default="download">
690-
<xs:simpleType>
691-
<xs:restriction base="xs:string">
692-
<xs:enumeration value="edit"/>
693-
<xs:enumeration value="display"/>
694-
<xs:enumeration value="download"/>
695-
</xs:restriction>
696-
</xs:simpleType>
697-
</xs:attribute>
709+
<xs:attribute name="mimetype" type="xs:string"/>
710+
<xs:attributeGroup ref="tns:resource-properties"/>
698711
</xs:complexType>
699712

700713
<xs:complexType name="task-files-type">
@@ -715,7 +728,8 @@
715728
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
716729
</xs:sequence>
717730
<xs:attribute name="id" type="xs:string" use="required"/>
718-
<xs:attribute name="reference" type="xs:string" use="optional"/>
731+
<xs:attribute name="reference" type="xs:string"/>
732+
<xs:attributeGroup ref="tns:resource-properties"/>
719733
</xs:complexType>
720734

721735
<xs:simpleType name="title-type">
@@ -762,7 +776,7 @@
762776
<xs:element name="test-configuration" type="tns:test-configuration-type"/>
763777
</xs:sequence>
764778
<xs:attribute name="id" type="xs:string" use="required"/>
765-
<xs:attribute name="validity" use="optional" default="1.00">
779+
<xs:attribute name="validity" default="1.00">
766780
<xs:simpleType>
767781
<xs:restriction base="xs:decimal">
768782
<xs:totalDigits value="3"/>
@@ -817,12 +831,13 @@
817831
<xs:element name="lms" type="tns:lms-type" minOccurs="0"/>
818832
<xs:element name="result-spec" type="tns:result-spec-type"/>
819833
</xs:sequence>
834+
<xs:attribute name="id" type="xs:string"/>
820835
</xs:complexType>
821836

822837
<xs:complexType name="submission-file-type">
823838
<xs:group ref="tns:file-choice-group"/>
824-
<xs:attribute name="id" type="xs:string" use="optional"/>
825-
<xs:attribute name="mimetype" type="xs:string" use="optional"/>
839+
<xs:attribute name="id" type="xs:string"/>
840+
<xs:attribute name="mimetype" type="xs:string"/>
826841
</xs:complexType>
827842

828843
<xs:complexType name="submission-files-type">
@@ -832,24 +847,28 @@
832847
</xs:complexType>
833848

834849
<xs:complexType name="external-task-type">
835-
<xs:simpleContent>
836-
<xs:extension base="xs:string">
837-
<xs:attribute name="uuid" type="xs:string" use="optional"/>
838-
</xs:extension>
839-
</xs:simpleContent>
850+
<xs:sequence>
851+
<xs:element name="uri" type="xs:string" minOccurs="0"/>
852+
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
853+
</xs:sequence>
854+
<xs:attribute name="uuid" type="xs:string"/>
840855
</xs:complexType>
841856

842-
<xs:simpleType name="external-submission-type">
843-
<xs:restriction base="xs:string"/>
844-
</xs:simpleType>
857+
<xs:complexType name="external-submission-type">
858+
<xs:sequence>
859+
<xs:element name="uri" type="xs:string" minOccurs="0"/>
860+
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
861+
</xs:sequence>
862+
</xs:complexType>
845863

846864
<xs:complexType name="included-task-file-type">
847865
<xs:choice>
848866
<xs:element name="embedded-zip-file" type="tns:embedded-bin-file-type"/>
867+
<xs:element name="embedded-xml-file" type="tns:embedded-bin-file-type"/>
849868
<xs:element name="attached-zip-file" type="tns:attached-bin-file-type"/>
850869
<xs:element name="attached-xml-file" type="tns:attached-txt-file-type"/>
851870
</xs:choice>
852-
<xs:attribute name="uuid" type="xs:string" use="optional"/>
871+
<xs:attribute name="uuid" type="xs:string"/>
853872
</xs:complexType>
854873

855874
<xs:complexType name="lms-type">
@@ -860,7 +879,7 @@
860879
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"
861880
processContents="lax"/>
862881
</xs:sequence>
863-
<xs:attribute name="url" type="xs:string" use="optional"/>
882+
<xs:attribute name="url" type="xs:string"/>
864883
</xs:complexType>
865884

866885
<xs:complexType name="result-spec-type">
@@ -906,10 +925,12 @@
906925
<xs:element name="response-meta-data" type="tns:response-meta-data-type"/>
907926
</xs:sequence>
908927
<xs:attribute name="lang" type="xs:language"/>
928+
<xs:attribute name="submission-id" type="xs:string"/>
909929
</xs:complexType>
910930

911931
<xs:complexType name="response-meta-data-type">
912932
<xs:sequence>
933+
<xs:element name="response-datetime" minOccurs="0" type="xs:dateTime"/>
913934
<xs:element name="grader-engine" type="tns:grader-engine-type"/>
914935
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
915936
</xs:sequence>
@@ -1043,14 +1064,15 @@
10431064
</xs:complexType>
10441065
</xs:element>
10451066
<xs:element name="filerefs" type="tns:filerefs-type" minOccurs="0"/>
1067+
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
10461068
</xs:sequence>
10471069
<xs:attribute name="level" type="tns:feedback-level-type"/>
10481070
</xs:complexType>
10491071

10501072
<xs:complexType name="response-file-type">
10511073
<xs:group ref="tns:file-choice-group"/>
10521074
<xs:attribute name="id" type="xs:string" use="required"/>
1053-
<xs:attribute name="mimetype" type="xs:string" use="optional"/>
1075+
<xs:attribute name="mimetype" type="xs:string"/>
10541076
<xs:attribute name="title" type="xs:string" use="required"/>
10551077
</xs:complexType>
10561078

lib/proforma.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
module Proforma
1717
SCHEMA_FORMAT_PATH = File.join(File.dirname(File.expand_path(__FILE__)), '../assets/schemas/proforma_%s.xsd')
18-
SCHEMA_VERSIONS = ['2.0.1', '2.0'].freeze
18+
SCHEMA_VERSIONS = ['2.1', '2.0'].freeze
1919
MAX_EMBEDDED_FILE_SIZE_KB = 50
2020
end

lib/proforma/services/exporter.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(task:, custom_namespaces: [], version: nil)
1111
@task = task
1212
@custom_namespaces = custom_namespaces
1313
@version = version || SCHEMA_VERSIONS.first
14-
add_placeholders
14+
add_placeholders if @version == '2.0'
1515
end
1616

1717
def perform
@@ -52,7 +52,7 @@ def add_meta_data(xml)
5252

5353
def add_objects_to_xml(xml)
5454
xml.files { files(xml) }
55-
xml.send('model-solutions') { model_solutions(xml) }
55+
xml.send('model-solutions') { model_solutions(xml) } if @task.model_solutions.any? || @version == '2.0'
5656
xml.tests { tests(xml) }
5757
end
5858

@@ -100,7 +100,7 @@ def tests(xml)
100100
end
101101
end
102102

103-
# ms-placeholder should be able to go as soon as profoma 2.1 is released https://github.com/ProFormA/proformaxml/issues/5
103+
# ms-placeholder only necessary for version 2.0 where model-solutions were mandatory
104104
def add_placeholders
105105
return if @task.model_solutions&.any?
106106

lib/proforma/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Proforma
4-
VERSION = '0.7.1'
4+
VERSION = '0.8.0'
55
end

0 commit comments

Comments
 (0)