55 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
56 $this->
renderer = $DIC->ui()->renderer();
63 $this->definitions = [];
65 $to_int = $this->
refinery->kindlyTo()->int();
66 $points = $this->forms_helper->transformPoints($a_value);
67 $terms = $this->forms_helper->transformArray($a_value,
'term', $to_int);
68 $definitions = $this->forms_helper->transformArray($a_value,
'definition', $to_int);
70 foreach (
$terms as $index => $term) {
78 $term_ids = explode(
',', $a_value[
'term_id']);
79 foreach ($term_ids as
$id) {
83 $definition_ids = explode(
',', $a_value[
'definition_id']);
84 foreach ($definition_ids as $id) {
96 $this->terms = $a_terms;
106 $this->definitions = $a_definitions;
116 $this->pairs = $a_pairs;
126 $this->allowMove = $a_allow_move;
145 $to_int = $this->
refinery->kindlyTo()->int();
148 if (!is_array(
$data)) {
149 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
154 $result_points = $this->forms_helper->checkPointsInputEnoughPositive(
$data,
true);
155 if (!is_array($result_points)) {
161 $terms = $this->forms_helper->transformArray(
$data,
'term', $to_int);
162 $definitions = $this->forms_helper->transformArray(
$data,
'definition', $to_int);
165 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
182 $global_tpl->addJavascript(
"assets/js/answerwizardinput.js");
183 $global_tpl->addJavascript(
"assets/js/matchingpairwizard.js");
185 $tpl =
new ilTemplate(
"tpl.prop_matchingpairinput.html",
true,
true,
"components/ILIAS/TestQuestionPool");
188 foreach ($this->pairs as $pair) {
190 $tpl->setCurrentBlock(
"option_term");
192 $tpl->setVariable(
"VALUE_OPTION", 0);
193 $tpl->parseCurrentBlock();
194 foreach ($this->terms as $term) {
195 $tpl->setCurrentBlock(
"option_term");
197 $tpl->setVariable(
"TEXT_OPTION",
$lng->
txt(
'term') .
" " . $counter);
198 if ($pair->getTerm()->getIdentifier() == $term->getIdentifier()) {
199 $tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
201 $tpl->parseCurrentBlock();
205 $tpl->setCurrentBlock(
"option_definition");
207 $tpl->setVariable(
"VALUE_OPTION", 0);
208 $tpl->parseCurrentBlock();
209 foreach ($this->definitions as $definition) {
210 $tpl->setCurrentBlock(
"option_definition");
212 $tpl->setVariable(
"TEXT_OPTION",
$lng->
txt(
'definition') .
" " . $counter);
213 if ($pair->getDefinition()->getIdentifier() == $definition->getIdentifier()) {
214 $tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
216 $tpl->parseCurrentBlock();
221 $tpl->setCurrentBlock(
'points_value');
222 $tpl->setVariable(
'POINTS_VALUE', $pair->getPoints());
223 $tpl->parseCurrentBlock();
226 $tpl->setCurrentBlock(
"move");
227 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
228 $tpl->setVariable(
"UP_BUTTON", $this->
renderer->render(
229 $this->glyph_factory->up()->withAction(
'#')
231 $tpl->setVariable(
"DOWN_BUTTON", $this->
renderer->render(
232 $this->glyph_factory->down()->withAction(
'#')
234 $tpl->parseCurrentBlock();
237 $tpl->setCurrentBlock(
"row");
238 $tpl->setVariable(
"ROW_NUMBER", $i);
240 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
241 $tpl->setVariable(
"ADD_BUTTON", $this->
renderer->render(
242 $this->glyph_factory->add()->withAction(
'#')
244 $tpl->setVariable(
"REMOVE_BUTTON", $this->
renderer->render(
245 $this->glyph_factory->remove()->withAction(
'#')
248 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
250 $tpl->parseCurrentBlock();
255 $tpl->setCurrentBlock(
'term_ids');
257 foreach ($this->terms as $term) {
258 array_push($ids, $term->getIdentifier());
260 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
261 $tpl->setVariable(
"TERM_IDS", join(
",", $ids));
262 $tpl->parseCurrentBlock();
264 $tpl->setCurrentBlock(
'definition_ids');
266 foreach ($this->definitions as $definition) {
267 array_push($ids, $definition->getIdentifier());
269 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
270 $tpl->setVariable(
"DEFINITION_IDS", join(
",", $ids));
271 $tpl->parseCurrentBlock();
273 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
274 $tpl->setVariable(
"TEXT_POINTS",
$lng->
txt(
'points'));
275 $tpl->setVariable(
"TEXT_DEFINITION",
$lng->
txt(
'definition'));
276 $tpl->setVariable(
"TEXT_TERM",
$lng->
txt(
'term'));
277 $tpl->setVariable(
"TEXT_ACTIONS",
$lng->
txt(
'actions'));
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Class for matching question terms.
Class for matching question pairs.
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...
This is how a factory for glyphs looks like.
setVariable($variable, $value='')
Sets a variable value.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
Class for matching question definitions.