36 $this->pairs = array();
37 $this->terms = array();
38 $this->definitions = array();
39 if (is_array($a_value))
41 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
42 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
43 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
44 if (is_array($a_value[
'term']))
46 foreach ($a_value[
'term'] as $idx => $term)
51 $term_ids = split(
",", $a_value[
'term_id']);
52 foreach ($term_ids as $id)
56 $definition_ids = split(
",", $a_value[
'definition_id']);
57 foreach ($definition_ids as $id)
71 $this->terms = $a_terms;
81 $this->definitions = $a_definitions;
91 $this->pairs = $a_pairs;
101 $this->allowMove = $a_allow_move;
125 if (is_array($foundvalues))
128 if (is_array($foundvalues[
'term']))
130 foreach ($foundvalues[
'term'] as $val)
134 $this->
setAlert($lng->txt(
"msg_input_is_required"));
138 foreach ($foundvalues[
'definition'] as $val)
142 $this->
setAlert($lng->txt(
"msg_input_is_required"));
147 foreach ($foundvalues[
'points'] as $val)
149 if ($val > 0) $max += $val;
152 $this->
setAlert($lng->txt(
"msg_input_is_required"));
158 $this->
setAlert($lng->txt(
"enter_enough_positive_points"));
166 $this->
setAlert($lng->txt(
"msg_input_is_required"));
175 $this->
setAlert($lng->txt(
"msg_input_is_required"));
191 $tpl =
new ilTemplate(
"tpl.prop_matchingpairinput.html",
true,
true,
"Modules/TestQuestionPool");
194 foreach ($this->pairs as $pair)
197 $tpl->setCurrentBlock(
"option_term");
199 $tpl->setVariable(
"VALUE_OPTION", 0);
200 $tpl->parseCurrentBlock();
201 foreach ($this->terms as $term)
203 $tpl->setCurrentBlock(
"option_term");
205 $tpl->setVariable(
"TEXT_OPTION", $lng->txt(
'term') .
" " . $counter);
206 if ($pair->term->identifier == $term->identifier)
$tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
207 $tpl->parseCurrentBlock();
211 $tpl->setCurrentBlock(
"option_definition");
213 $tpl->setVariable(
"VALUE_OPTION", 0);
214 $tpl->parseCurrentBlock();
215 foreach ($this->definitions as $definition)
217 $tpl->setCurrentBlock(
"option_definition");
219 $tpl->setVariable(
"TEXT_OPTION", $lng->txt(
'definition') .
" " . $counter);
220 if ($pair->definition->identifier == $definition->identifier)
$tpl->setVariable(
'SELECTED_OPTION',
' selected="selected"');
221 $tpl->parseCurrentBlock();
225 if (strlen($pair->points))
227 $tpl->setCurrentBlock(
'points_value');
228 $tpl->setVariable(
'POINTS_VALUE', $pair->points);
229 $tpl->parseCurrentBlock();
233 $tpl->setCurrentBlock(
"move");
234 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
235 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
239 $tpl->parseCurrentBlock();
242 $tpl->setCurrentBlock(
"row");
243 $class = ($i % 2 == 0) ?
"even" :
"odd";
244 if ($i == 0) $class .=
" first";
245 if ($i == count($this->values)-1) $class .=
" last";
246 $tpl->setVariable(
"ROW_CLASS", $class);
247 $tpl->setVariable(
"ROW_NUMBER", $i);
250 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
251 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
257 $tpl->parseCurrentBlock();
262 $tpl->setCurrentBlock(
'term_ids');
264 foreach ($this->terms as $term)
266 array_push($ids, $term->identifier);
269 $tpl->setVariable(
"TERM_IDS", join($ids,
","));
270 $tpl->parseCurrentBlock();
272 $tpl->setCurrentBlock(
'definition_ids');
274 foreach ($this->definitions as $definition)
276 array_push($ids, $definition->identifier);
279 $tpl->setVariable(
"DEFINITION_IDS", join($ids,
","));
280 $tpl->parseCurrentBlock();
283 $tpl->setVariable(
"TEXT_POINTS", $lng->txt(
'points'));
284 $tpl->setVariable(
"TEXT_DEFINITION", $lng->txt(
'definition'));
285 $tpl->setVariable(
"TEXT_TERM", $lng->txt(
'term'));
287 $a_tpl->setCurrentBlock(
"prop_generic");
288 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
289 $a_tpl->parseCurrentBlock();
292 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
294 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/matchingpairwizard.js");