57 $this->glyph_factory =
$DIC->ui()->factory()->symbol()->glyph();
58 $this->button_factory =
$DIC->ui()->factory()->button();
59 $this->
renderer = $DIC->ui()->renderer();
66 $this->definitions = [];
68 $to_int = $this->
refinery->kindlyTo()->int();
69 $points = $this->forms_helper->transformPoints($a_value);
70 $terms = $this->forms_helper->transformArray($a_value,
'term', $to_int);
71 $definitions = $this->forms_helper->transformArray($a_value,
'definition', $to_int);
73 foreach (
$terms as $index => $term) {
81 $term_ids = explode(
',', $a_value[
'term_id']);
82 foreach ($term_ids as
$id) {
86 $definition_ids = explode(
',', $a_value[
'definition_id']);
87 foreach ($definition_ids as
$id) {
99 $this->terms = $a_terms;
109 $this->definitions = $a_definitions;
119 $this->pairs = $a_pairs;
129 $this->allowMove = $a_allow_move;
148 $to_int = $this->
refinery->kindlyTo()->int();
151 if (!is_array(
$data)) {
152 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
157 $result_points = $this->forms_helper->checkPointsInputEnoughPositive(
$data,
true);
158 if (!is_array($result_points)) {
164 $terms = $this->forms_helper->transformArray(
$data,
'term', $to_int);
165 $definitions = $this->forms_helper->transformArray(
$data,
'definition', $to_int);
168 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
185 $global_tpl->addJavascript(
"assets/js/answerwizardinput.js");
186 $global_tpl->addJavascript(
"assets/js/matchingpairwizard.js");
188 $tpl =
new ilTemplate(
"tpl.prop_matchingpairinput.html",
true,
true,
"components/ILIAS/TestQuestionPool");
191 foreach ($this->pairs as $pair) {
193 $tpl->setCurrentBlock(
"option_term");
195 $tpl->setVariable(
"VALUE_OPTION", 0);
196 $tpl->parseCurrentBlock();
197 foreach ($this->terms as $term) {
198 $tpl->setCurrentBlock(
"option_term");
201 if ($pair->getTerm()->getIdentifier() == $term->getIdentifier()) {
202 $tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
204 $tpl->parseCurrentBlock();
208 $tpl->setCurrentBlock(
"option_definition");
210 $tpl->setVariable(
"VALUE_OPTION", 0);
211 $tpl->parseCurrentBlock();
212 foreach ($this->definitions as $definition) {
213 $tpl->setCurrentBlock(
"option_definition");
215 $tpl->setVariable(
"TEXT_OPTION",
$lng->
txt(
'definition') .
" " .
$counter);
216 if ($pair->getDefinition()->getIdentifier() == $definition->getIdentifier()) {
217 $tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
219 $tpl->parseCurrentBlock();
224 $tpl->setCurrentBlock(
'points_value');
225 $tpl->setVariable(
'POINTS_VALUE', $pair->getPoints());
226 $tpl->parseCurrentBlock();
229 $tpl->setCurrentBlock(
"move");
230 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
231 $tpl->setVariable(
"UP_BUTTON", $this->
renderer->render(
232 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->up())
234 $tpl->setVariable(
"DOWN_BUTTON", $this->
renderer->render(
235 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->down())
237 $tpl->parseCurrentBlock();
240 $tpl->setCurrentBlock(
"row");
241 $tpl->setVariable(
"ROW_NUMBER", $i);
243 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
244 $tpl->setVariable(
"ADD_BUTTON", $this->
renderer->render(
245 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->add())
247 $tpl->setVariable(
"REMOVE_BUTTON", $this->
renderer->render(
248 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->remove())
251 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
253 $tpl->parseCurrentBlock();
258 $tpl->setCurrentBlock(
'term_ids');
260 foreach ($this->terms as $term) {
261 array_push($ids, $term->getIdentifier());
263 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
264 $tpl->setVariable(
"TERM_IDS", join(
",", $ids));
265 $tpl->parseCurrentBlock();
267 $tpl->setCurrentBlock(
'definition_ids');
269 foreach ($this->definitions as $definition) {
270 array_push($ids, $definition->getIdentifier());
272 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
273 $tpl->setVariable(
"DEFINITION_IDS", join(
",", $ids));
274 $tpl->parseCurrentBlock();
276 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
277 $tpl->setVariable(
"TEXT_POINTS",
$lng->
txt(
'points'));
278 $tpl->setVariable(
"TEXT_DEFINITION",
$lng->
txt(
'definition'));
279 $tpl->setVariable(
"TEXT_TERM",
$lng->
txt(
'term'));
280 $tpl->setVariable(
"TEXT_ACTIONS",
$lng->
txt(
'actions'));
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setVariable($variable, $value='')
Sets a variable value.
Builds a Color from either hex- or rgb values.
Class for matching question definitions.
Class for matching question pairs.
Class for matching question terms.
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)
This class represents a text property in a property form.
This is how a factory for glyphs looks like.
An entity that renders components to a string output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc