56 $this->pairs = array();
57 $this->terms = array();
58 $this->definitions = array();
59 if (is_array($a_value))
61 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
62 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
63 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
64 if (is_array($a_value[
'term']))
66 foreach ($a_value[
'term'] as $idx => $term)
71 $term_ids = split(
",", $a_value[
'term_id']);
72 foreach ($term_ids as $id)
76 $definition_ids = split(
",", $a_value[
'definition_id']);
77 foreach ($definition_ids as $id)
91 $this->terms = $a_terms;
101 $this->definitions = $a_definitions;
111 $this->pairs = $a_pairs;
121 $this->allowMove = $a_allow_move;
143 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
146 if (is_array($foundvalues))
149 if (is_array($foundvalues[
'term']))
151 foreach ($foundvalues[
'term'] as $val)
155 $this->
setAlert($lng->txt(
"msg_input_is_required"));
159 foreach ($foundvalues[
'definition'] as $val)
163 $this->
setAlert($lng->txt(
"msg_input_is_required"));
168 foreach ($foundvalues[
'points'] as $val)
170 if ($val > 0) $max += $val;
173 $this->
setAlert($lng->txt(
"msg_input_is_required"));
179 $this->
setAlert($lng->txt(
"enter_enough_positive_points"));
187 $this->
setAlert($lng->txt(
"msg_input_is_required"));
196 $this->
setAlert($lng->txt(
"msg_input_is_required"));
212 $tpl =
new ilTemplate(
"tpl.prop_matchingpairinput.html",
true,
true,
"Modules/TestQuestionPool");
215 foreach ($this->pairs as $pair)
218 $tpl->setCurrentBlock(
"option_term");
220 $tpl->setVariable(
"VALUE_OPTION", 0);
221 $tpl->parseCurrentBlock();
222 foreach ($this->terms as $term)
224 $tpl->setCurrentBlock(
"option_term");
226 $tpl->setVariable(
"TEXT_OPTION", $lng->txt(
'term') .
" " . $counter);
227 if ($pair->term->identifier == $term->identifier)
$tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
228 $tpl->parseCurrentBlock();
232 $tpl->setCurrentBlock(
"option_definition");
234 $tpl->setVariable(
"VALUE_OPTION", 0);
235 $tpl->parseCurrentBlock();
236 foreach ($this->definitions as $definition)
238 $tpl->setCurrentBlock(
"option_definition");
240 $tpl->setVariable(
"TEXT_OPTION", $lng->txt(
'definition') .
" " . $counter);
241 if ($pair->definition->identifier == $definition->identifier)
$tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
242 $tpl->parseCurrentBlock();
246 if (strlen($pair->points))
248 $tpl->setCurrentBlock(
'points_value');
249 $tpl->setVariable(
'POINTS_VALUE', $pair->points);
250 $tpl->parseCurrentBlock();
254 $tpl->setCurrentBlock(
"move");
255 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
256 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
260 $tpl->parseCurrentBlock();
263 $tpl->setCurrentBlock(
"row");
264 $class = ($i % 2 == 0) ?
"even" :
"odd";
265 if ($i == 0) $class .=
" first";
266 if ($i == count($this->values)-1) $class .=
" last";
267 $tpl->setVariable(
"ROW_CLASS", $class);
268 $tpl->setVariable(
"ROW_NUMBER", $i);
271 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
272 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
278 $tpl->parseCurrentBlock();
283 $tpl->setCurrentBlock(
'term_ids');
285 foreach ($this->terms as $term)
287 array_push($ids, $term->identifier);
290 $tpl->setVariable(
"TERM_IDS", join($ids,
","));
291 $tpl->parseCurrentBlock();
293 $tpl->setCurrentBlock(
'definition_ids');
295 foreach ($this->definitions as $definition)
297 array_push($ids, $definition->identifier);
300 $tpl->setVariable(
"DEFINITION_IDS", join($ids,
","));
301 $tpl->parseCurrentBlock();
304 $tpl->setVariable(
"TEXT_POINTS", $lng->txt(
'points'));
305 $tpl->setVariable(
"TEXT_DEFINITION", $lng->txt(
'definition'));
306 $tpl->setVariable(
"TEXT_TERM", $lng->txt(
'term'));
308 $a_tpl->setCurrentBlock(
"prop_generic");
309 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
310 $a_tpl->parseCurrentBlock();
313 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
315 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/matchingpairwizard.js");