Skip to content
Snippets Groups Projects
Commit 096d7bd2 authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

export additional assignment options, fixes #106

parent 0ca9aae2
No related branches found
No related tags found
No related merge requests found
......@@ -171,12 +171,32 @@ class VipsAssignment extends SimpleORMap
if ($test->notes) {
$data['options']['notes'] = trim($test->notes);
}
if ($test->limit['access-code']) {
$data['options']['access_code'] = (string) $test->limit['access-code'];
}
if ($test->limit['ip-ranges']) {
$data['options']['ip_range'] = (string) $test->limit['ip-ranges'];
}
if ($test->limit['resets']) {
$data['options']['resets'] = (int) $test->limit['resets'];
}
if ($test->limit['tries']) {
$data['options']['max_tries'] = (int) $test->limit['tries'];
}
if ($test->option['scoring-mode'] == 'negative_points') {
$data['options']['evaluation_mode'] = 1;
} else if ($test->option['scoring-mode'] == 'all_or_nothing') {
$data['options']['evaluation_mode'] = 2;
}
if ($test->option['shuffle-answers'] == 'true') {
$data['options']['shuffle_answers'] = 1;
}
if ($test->option['shuffle-exercises'] == 'true') {
$data['options']['shuffle_exercises'] = 1;
}
if ($test['start']) {
$data['start'] = date('Y-m-d H:i:s', strtotime($test['start']));
}
......
......@@ -12,9 +12,16 @@ element test {
element description { text }?,
element notes { text }?,
element limit {
attribute access-code { xsd:string }?,
attribute ip-ranges { xsd:string }?,
attribute resets { xsd:integer }?,
attribute tries { xsd:integer }?
}?,
element option {
attribute scoring-mode { token }?,
attribute shuffle-answers { xsd:boolean }?,
attribute shuffle-exercises { xsd:boolean }?
}?,
element exercises {
element exercise {
attribute id { xsd:ID },
......
......@@ -7,6 +7,7 @@
<xs:element minOccurs="0" name="description" type="xs:string"/>
<xs:element minOccurs="0" ref="ns1:notes"/>
<xs:element minOccurs="0" ref="ns1:limit"/>
<xs:element minOccurs="0" ref="ns1:option"/>
<xs:element ref="ns1:exercises"/>
<xs:element minOccurs="0" ref="ns1:files"/>
</xs:sequence>
......@@ -30,10 +31,19 @@
<xs:element name="notes" type="xs:string"/>
<xs:element name="limit">
<xs:complexType>
<xs:attribute name="access-code" type="xs:string"/>
<xs:attribute name="ip-ranges" type="xs:string"/>
<xs:attribute name="resets" type="xs:integer"/>
<xs:attribute name="tries" type="xs:integer"/>
</xs:complexType>
</xs:element>
<xs:element name="option">
<xs:complexType>
<xs:attribute name="scoring-mode" type="xs:token"/>
<xs:attribute name="shuffle-answers" type="xs:boolean"/>
<xs:attribute name="shuffle-exercises" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="exercises">
<xs:complexType>
<xs:sequence>
......
......@@ -23,13 +23,33 @@
<?= vips_xml_encode($assignment->options['notes']) ?>
</notes>
<? endif ?>
<? if ($assignment->type === 'selftest'): ?>
<limit <? if ($assignment->options['resets'] === 0): ?>resets="0"<? endif ?>
<? if ($assignment->options['max_tries']): ?>
tries="<?= (int) $assignment->options['max_tries'] ?>"
<? endif ?>
/>
<limit
<? if (isset($assignment->options['access_code'])): ?>
access-code="<?= vips_xml_encode($assignment->options['access_code']) ?>"
<? endif ?>
<? if (isset($assignment->options['ip_range'])): ?>
ip-ranges="<?= vips_xml_encode($assignment->options['ip_range']) ?>"
<? endif ?>
<? if ($assignment->options['resets'] === 0): ?>
resets="0"
<? endif ?>
<? if ($assignment->options['max_tries']): ?>
tries="<?= (int) $assignment->options['max_tries'] ?>"
<? endif ?>
/>
<option
<? if ($assignment->options['evaluation_mode'] == 1): ?>
scoring-mode="negative_points"
<? elseif ($assignment->options['evaluation_mode'] == 2): ?>
scoring-mode="all_or_nothing"
<? endif ?>
<? if ($assignment->isShuffled()): ?>
shuffle-answers="true"
<? endif ?>
<? if ($assignment->isExerciseShuffled()): ?>
shuffle-exercises="true"
<? endif ?>
/>
<exercises>
<? foreach ($assignment->test->exercise_refs as $exercise_ref): ?>
<?= $this->render_partial($exercise_ref->exercise->getXMLTemplate($assignment), ['points' => $exercise_ref->points]) ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment