ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAssClozeTestCombinationVariantsInputGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
15 public function setValue($a_value)
16 {
17 foreach ($this->values as $index => $value) {
18 $this->values[$index]['points'] = $a_value['points'][$index];
19 }
20 }
21
22 public function checkInput()
23 {
24 global $DIC; /* @var ILIAS\DI\Container $DIC */
25 $lng = $DIC->language();
26
28
29 $values = $_POST[$this->getPostVar()];
30
31 $max = 0;
32 if (is_array($values['points'])) {
33 foreach ($values['points'] as $points) {
34 if ($points > $max) {
35 $max = $points;
36 }
37 if (((strlen($points)) == 0) || (!is_numeric($points))) {
38 $this->setAlert($lng->txt("form_msg_numeric_value_required"));
39 return false;
40 }
41 if ($this->minvalueShouldBeGreater()) {
42 if (trim($points) != "" &&
43 $this->getMinValue() !== false &&
44 $points <= $this->getMinValue()) {
45 $this->setAlert($lng->txt("form_msg_value_too_low"));
46
47 return false;
48 }
49 } else {
50 if (trim($points) != "" &&
51 $this->getMinValue() !== false &&
52 $points < $this->getMinValue()) {
53 $this->setAlert($lng->txt("form_msg_value_too_low"));
54
55 return false;
56 }
57 }
58 }
59 }
60 if ($max == 0) {
61 $this->setAlert($lng->txt("enter_enough_positive_points"));
62 return false;
63 }
64
65 return true;
66 }
67
68 public function insert($a_tpl)
69 {
70 $tpl = new ilTemplate('tpl.prop_gap_combi_answers_input.html', true, true, 'Modules/TestQuestionPool');
71
72 $gaps = array();
73
74 foreach ($this->values as $varId => $variant) {
75 foreach ($variant['gaps'] as $gapIndex => $answer) {
76 $gaps[$gapIndex] = $gapIndex;
77
78 $tpl->setCurrentBlock('gap_answer');
79 $tpl->setVariable('GAP_ANSWER', $answer);
80 $tpl->parseCurrentBlock();
81 }
82
83 $tpl->setCurrentBlock('variant');
84 $tpl->setVariable('POSTVAR', $this->getPostVar());
85 $tpl->setVariable('POINTS', $variant['points']);
86 $tpl->parseCurrentBlock();
87 }
88
89 foreach ($gaps as $gapIndex) {
90 $tpl->setCurrentBlock('gap_header');
91 $tpl->setVariable('GAP_HEADER', 'Gap ' . ($gapIndex + 1));
92 $tpl->parseCurrentBlock();
93 }
94
95 $tpl->setVariable('POINTS_HEADER', 'Points');
96
97 $a_tpl->setCurrentBlock("prop_generic");
98 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
99 $a_tpl->parseCurrentBlock();
100 }
101}
$tpl
Definition: ilias.php:10
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a single choice wizard property in a property form.
minvalueShouldBeGreater()
Get minvalueShouldBeGreater.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
special template class to simplify handling of ITX/PEAR
$index
Definition: metadata.php:60
global $DIC
Definition: saml.php:7