ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRandomTestROInputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29{
30 protected $values = [];
31
38 public function __construct($a_title = "", $a_postvar = "")
39 {
40 parent::__construct($a_title, $a_postvar);
41 $this->setRequired(true);
42 }
43
49 public function setValue($a_value)
50 {
51 }
52
53 public function setValueByArray($a_values)
54 {
55 }
56
62 public function setValues($a_values)
63 {
64 $this->values = $a_values;
65 }
66
72 public function getValues(): array
73 {
74 return $this->values;
75 }
76
81 public function checkInput(): bool
82 {
83 return $this->checkSubItemsInput();
84 }
85
89 public function insert($a_tpl)
90 {
91 $tpl = new ilTemplate("tpl.prop_randomtestroinput.html", true, true, "components/ILIAS/Test");
92 $i = 0;
93 foreach ($this->values as $value) {
94 if ($value['num_of_q'] > 0) {
95 $tpl->setCurrentBlock("num_of_q");
96 $tpl->setVariable("NUM_OF_Q", $value['num_of_q']);
97 $tpl->setVariable("TEXT_FROM", $this->lng->txt('questions_from'));
98 $tpl->parseCurrentBlock();
99 }
100 $tpl->setCurrentBlock("row");
101 $class = ($i % 2 == 0) ? "even" : "odd";
102 if ($i == 0) {
103 $class .= " first";
104 }
105 if ($i == count($this->values) - 1) {
106 $class .= " last";
107 }
108 $tpl->setVariable("ROW_CLASS", $class);
109 $tpl->setVariable("QPL_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($value['title']));
110 $tpl->setVariable("COUNT_VALUE", "(" . $value['count'] . " " . $this->lng->txt('assQuestions') . ")");
111 $tpl->parseCurrentBlock();
112 $i++;
113 }
114 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
115
116 $a_tpl->setCurrentBlock("prop_generic");
117 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
118 $a_tpl->parseCurrentBlock();
119 }
120}
setRequired(bool $a_required)
static prepareFormOutput($a_str, bool $a_strip=false)
This class represents a random test input property in a property form.
insert($a_tpl)
Insert property html.
__construct($a_title="", $a_postvar="")
Constructor.
checkInput()
Check input, strip slashes etc.
This class represents a property that may include a sub form.
special template class to simplify handling of ITX/PEAR
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc