ILIAS  release_8 Revision v8.24
class.ilAssClozeTestCombinationVariantsInputGUI.php
Go to the documentation of this file.
1<?php
2
28{
29 public function setValue($a_value): void
30 {
31 foreach ($this->values as $index => $value) {
32 $this->values[$index]['points'] = $a_value['points'][$index];
33 }
34 }
35
36 public function checkInput(): bool
37 {
38 global $DIC; /* @var ILIAS\DI\Container $DIC */
39 $lng = $DIC->language();
40
41 $values = $_POST[$this->getPostVar()];
42
43 $max = 0;
44 if (is_array($values['points'])) {
45 foreach ($values['points'] as $points) {
46 if ($points > $max) {
47 $max = $points;
48 }
49 if (((strlen($points)) == 0) || (!is_numeric($points))) {
50 $this->setAlert($lng->txt("form_msg_numeric_value_required"));
51 return false;
52 }
53 if ($this->minvalueShouldBeGreater()) {
54 if (trim($points) != "" &&
55 $this->getMinValue() !== false &&
56 $points <= $this->getMinValue()) {
57 $this->setAlert($lng->txt("form_msg_value_too_low"));
58
59 return false;
60 }
61 } else {
62 if (trim($points) != "" &&
63 $this->getMinValue() !== false &&
64 $points < $this->getMinValue()) {
65 $this->setAlert($lng->txt("form_msg_value_too_low"));
66
67 return false;
68 }
69 }
70 }
71 }
72 if ($max == 0) {
73 $this->setAlert($lng->txt("enter_enough_positive_points"));
74 return false;
75 }
76
77 return true;
78 }
79
80 public function insert(ilTemplate $a_tpl): void
81 {
82 $tpl = new ilTemplate('tpl.prop_gap_combi_answers_input.html', true, true, 'Modules/TestQuestionPool');
83
84 $gaps = array();
85
86 foreach ($this->values as $varId => $variant) {
87 foreach ($variant['gaps'] as $gapIndex => $answer) {
88 $gaps[$gapIndex] = $gapIndex;
89
90 $tpl->setCurrentBlock('gap_answer');
91 $tpl->setVariable('GAP_ANSWER', $answer);
92 $tpl->parseCurrentBlock();
93 }
94
95 $tpl->setCurrentBlock('variant');
96 $tpl->setVariable('POSTVAR', $this->getPostVar());
97 $tpl->setVariable('POINTS', $variant['points']);
98 $tpl->parseCurrentBlock();
99 }
100
101 foreach ($gaps as $gapIndex) {
102 $tpl->setCurrentBlock('gap_header');
103 $tpl->setVariable('GAP_HEADER', 'Gap ' . ($gapIndex + 1));
104 $tpl->parseCurrentBlock();
105 }
106
107 $tpl->setVariable('POINTS_HEADER', 'Points');
108
109 $a_tpl->setCurrentBlock("prop_generic");
110 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
111 $a_tpl->parseCurrentBlock();
112 }
113}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
minvalueShouldBeGreater()
Get minvalueShouldBeGreater.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
global $DIC
Definition: feed.php:28
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$index
Definition: metadata.php:145