50 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
51 $this->renderer = $DIC->ui()->renderer();
56 $this->pairs = array();
57 $this->terms = array();
58 $this->definitions = array();
59 if (is_array($a_value)) {
60 if (isset($a_value[
'term']) && is_array($a_value[
'term'])) {
61 foreach ($a_value[
'term'] as $idx => $term) {
65 (
float) $a_value[
'points'][$idx]
69 $term_ids = explode(
",", $a_value[
'term_id']);
70 foreach ($term_ids as
$id) {
73 $definition_ids = explode(
",", $a_value[
'definition_id']);
74 foreach ($definition_ids as $id) {
87 $this->terms = $a_terms;
97 $this->definitions = $a_definitions;
107 $this->pairs = $a_pairs;
117 $this->allowMove = $a_allow_move;
144 if (is_array($foundvalues)) {
146 if (isset($foundvalues[
'term']) && is_array($foundvalues[
'term'])) {
147 foreach ($foundvalues[
'term'] as $val) {
153 foreach ($foundvalues[
'definition'] as $val) {
160 foreach ($foundvalues[
'points'] as $val) {
161 if ($this->
getRequired() && (strlen($val)) === 0) {
165 $val = str_replace(
",",
".", $val);
166 if (!is_numeric($val)) {
204 $global_tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/answerwizardinput.js");
205 $global_tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/matchingpairwizard.js");
207 $tpl =
new ilTemplate(
"tpl.prop_matchingpairinput.html",
true,
true,
"Modules/TestQuestionPool");
210 foreach ($this->pairs as $pair) {
212 $tpl->setCurrentBlock(
"option_term");
214 $tpl->setVariable(
"VALUE_OPTION", 0);
215 $tpl->parseCurrentBlock();
216 foreach ($this->terms as $term) {
217 $tpl->setCurrentBlock(
"option_term");
219 $tpl->setVariable(
"TEXT_OPTION",
$lng->
txt(
'term') .
" " . $counter);
220 if ($pair->getTerm()->getIdentifier() == $term->getIdentifier()) {
221 $tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
223 $tpl->parseCurrentBlock();
227 $tpl->setCurrentBlock(
"option_definition");
229 $tpl->setVariable(
"VALUE_OPTION", 0);
230 $tpl->parseCurrentBlock();
231 foreach ($this->definitions as $definition) {
232 $tpl->setCurrentBlock(
"option_definition");
234 $tpl->setVariable(
"TEXT_OPTION",
$lng->
txt(
'definition') .
" " . $counter);
235 if ($pair->getDefinition()->getIdentifier() == $definition->getIdentifier()) {
236 $tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
238 $tpl->parseCurrentBlock();
243 $tpl->setCurrentBlock(
'points_value');
244 $tpl->setVariable(
'POINTS_VALUE', $pair->getPoints());
245 $tpl->parseCurrentBlock();
248 $tpl->setCurrentBlock(
"move");
249 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
250 $tpl->setVariable(
"UP_BUTTON", $this->renderer->render(
251 $this->glyph_factory->up()->withAction(
'#')
253 $tpl->setVariable(
"DOWN_BUTTON", $this->renderer->render(
254 $this->glyph_factory->down()->withAction(
'#')
256 $tpl->parseCurrentBlock();
259 $tpl->setCurrentBlock(
"row");
260 $tpl->setVariable(
"ROW_NUMBER", $i);
262 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
263 $tpl->setVariable(
"ADD_BUTTON", $this->renderer->render(
264 $this->glyph_factory->add()->withAction(
'#')
266 $tpl->setVariable(
"REMOVE_BUTTON", $this->renderer->render(
267 $this->glyph_factory->remove()->withAction(
'#')
270 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
272 $tpl->parseCurrentBlock();
277 $tpl->setCurrentBlock(
'term_ids');
279 foreach ($this->terms as $term) {
280 array_push($ids, $term->getIdentifier());
282 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
283 $tpl->setVariable(
"TERM_IDS", join(
",", $ids));
284 $tpl->parseCurrentBlock();
286 $tpl->setCurrentBlock(
'definition_ids');
288 foreach ($this->definitions as $definition) {
289 array_push($ids, $definition->getIdentifier());
291 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
292 $tpl->setVariable(
"DEFINITION_IDS", join(
",", $ids));
293 $tpl->parseCurrentBlock();
295 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
296 $tpl->setVariable(
"TEXT_POINTS",
$lng->
txt(
'points'));
297 $tpl->setVariable(
"TEXT_DEFINITION",
$lng->
txt(
'definition'));
298 $tpl->setVariable(
"TEXT_TERM",
$lng->
txt(
'term'));
299 $tpl->setVariable(
"TEXT_ACTIONS",
$lng->
txt(
'actions'));
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...