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;
145 if (is_array($foundvalues))
148 if (is_array($foundvalues[
'term']))
150 foreach ($foundvalues[
'term'] as $val)
154 $this->
setAlert($lng->txt(
"msg_input_is_required"));
158 foreach ($foundvalues[
'definition'] as $val)
162 $this->
setAlert($lng->txt(
"msg_input_is_required"));
167 foreach ($foundvalues[
'points'] as $val)
169 if ($val > 0) $max += $val;
172 $this->
setAlert($lng->txt(
"msg_input_is_required"));
178 $this->
setAlert($lng->txt(
"enter_enough_positive_points"));
186 $this->
setAlert($lng->txt(
"msg_input_is_required"));
195 $this->
setAlert($lng->txt(
"msg_input_is_required"));
211 $tpl =
new ilTemplate(
"tpl.prop_matchingpairinput.html",
true,
true,
"Modules/TestQuestionPool");
214 foreach ($this->pairs as $pair)
217 $tpl->setCurrentBlock(
"option_term");
219 $tpl->setVariable(
"VALUE_OPTION", 0);
220 $tpl->parseCurrentBlock();
221 foreach ($this->terms as $term)
223 $tpl->setCurrentBlock(
"option_term");
225 $tpl->setVariable(
"TEXT_OPTION", $lng->txt(
'term') .
" " . $counter);
226 if ($pair->term->identifier == $term->identifier)
$tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
227 $tpl->parseCurrentBlock();
231 $tpl->setCurrentBlock(
"option_definition");
233 $tpl->setVariable(
"VALUE_OPTION", 0);
234 $tpl->parseCurrentBlock();
235 foreach ($this->definitions as $definition)
237 $tpl->setCurrentBlock(
"option_definition");
239 $tpl->setVariable(
"TEXT_OPTION", $lng->txt(
'definition') .
" " . $counter);
240 if ($pair->definition->identifier == $definition->identifier)
$tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
241 $tpl->parseCurrentBlock();
245 if (strlen($pair->points))
247 $tpl->setCurrentBlock(
'points_value');
248 $tpl->setVariable(
'POINTS_VALUE', $pair->points);
249 $tpl->parseCurrentBlock();
253 $tpl->setCurrentBlock(
"move");
254 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
255 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
259 $tpl->parseCurrentBlock();
262 $tpl->setCurrentBlock(
"row");
263 $class = ($i % 2 == 0) ?
"even" :
"odd";
264 if ($i == 0) $class .=
" first";
265 if ($i == count($this->values)-1) $class .=
" last";
266 $tpl->setVariable(
"ROW_CLASS", $class);
267 $tpl->setVariable(
"ROW_NUMBER", $i);
270 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
271 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
277 $tpl->parseCurrentBlock();
282 $tpl->setCurrentBlock(
'term_ids');
284 foreach ($this->terms as $term)
286 array_push($ids, $term->identifier);
289 $tpl->setVariable(
"TERM_IDS", join($ids,
","));
290 $tpl->parseCurrentBlock();
292 $tpl->setCurrentBlock(
'definition_ids');
294 foreach ($this->definitions as $definition)
296 array_push($ids, $definition->identifier);
299 $tpl->setVariable(
"DEFINITION_IDS", join($ids,
","));
300 $tpl->parseCurrentBlock();
303 $tpl->setVariable(
"TEXT_POINTS", $lng->txt(
'points'));
304 $tpl->setVariable(
"TEXT_DEFINITION", $lng->txt(
'definition'));
305 $tpl->setVariable(
"TEXT_TERM", $lng->txt(
'term'));
307 $a_tpl->setCurrentBlock(
"prop_generic");
308 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
309 $a_tpl->parseCurrentBlock();
312 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
314 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/matchingpairwizard.js");