ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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->forms_helper->transformPoints($a_value) as $index => $value) {
32 if ($value === null) {
33 return;
34 }
35
36 $this->values[$index]['points'] = $value;
37 }
38 }
39
40 public function checkInput(): bool
41 {
42 // check points
43 $points = $this->forms_helper->checkPointsInputEnoughPositive($this->raw($this->getPostVar()), true);
44 if (!is_array($points)) {
45 $this->setAlert($this->lng->txt($points));
46 return false;
47 }
48 return true;
49 }
50
51 public function insert(ilTemplate $a_tpl): void
52 {
53 $tpl = new ilTemplate('tpl.prop_gap_combi_answers_input.html', true, true, 'components/ILIAS/TestQuestionPool');
54 $gaps = [];
55
56 foreach ($this->values as $variant) {
57 foreach ($variant['gaps'] as $gap_index => $answer) {
58 $gaps[$gap_index] = $gap_index;
59
60 $tpl->setCurrentBlock('gap_answer');
61 $tpl->setVariable('GAP_ANSWER', $answer);
62 $tpl->parseCurrentBlock();
63 }
64
65 $tpl->setCurrentBlock('variant');
66 $tpl->setVariable('POSTVAR', $this->getPostVar());
67 $tpl->setVariable('POINTS', $variant['points']);
68 $tpl->parseCurrentBlock();
69 }
70
71 foreach ($gaps as $gap_index) {
72 $tpl->setCurrentBlock('gap_header');
73 $tpl->setVariable('GAP_HEADER', 'Gap ' . ($gap_index + 1));
74 $tpl->parseCurrentBlock();
75 }
76
77 $tpl->setVariable('POINTS_HEADER', 'Points');
78
79 $a_tpl->setCurrentBlock('prop_generic');
80 $a_tpl->setVariable('PROP_GENERIC', $tpl->get());
81 $a_tpl->parseCurrentBlock();
82 }
83}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
This class represents a single choice wizard property in a property form.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)