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