4 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
47 public function insert(&$a_tpl)
52 $a_tpl->setCurrentBlock(
"prop_generic");
53 $a_tpl->setVariable(
"PROP_GENERIC", $this->
getHtml());
54 $a_tpl->parseCurrentBlock();
60 $this->ordering_type = $a_ordering_type;
69 $this->image_path = $a_image_path;
77 $this->image_path_web = $a_image_path_web;
85 $this->thumb_prefix = $a_thumb_prefix;
115 shuffle($a_answers_array);
119 foreach($a_answers_array as $obj_answer)
121 $this->answers[$i][
'random_id'] = $obj_answer->getRandomId();
122 $this->answers[$i][
'answertext'] = (string)$obj_answer->getAnswertext();
123 $this->answers[$i][
'answer_id'] = $obj_answer->getAnswerId();
124 $this->answers[$i][
'ordering_depth'] = $obj_answer->getOrderingDepth();
132 $js_include_tpl =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_html.html", TRUE, TRUE,
"Modules/TestQuestionPool");
133 $js_include_tpl->setCurrentBlock(
'begin_sortablecontainer');
134 $js_include_tpl->setVariable(
'INSTANCE_ID', $this->
getInstanceId());
135 $js_include_tpl->parseCurrentBlock();
137 return $js_include_tpl->get();
141 $js_include_tpl =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_html.html", TRUE, TRUE,
"Modules/TestQuestionPool");
142 $js_include_tpl->touchBlock(
'end_sortablecontainer');
144 return $js_include_tpl->get();
149 $js_include_tpl =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_html.html", TRUE, TRUE,
"Modules/TestQuestionPool");
150 $js_include_tpl->touchBlock(
'begin_list_item');
152 $js_include_tpl->setCurrentBlock(
'item_value');
153 $js_include_tpl->setVariable(
'LIST_ITEM_VALUE', $this->
renderAnswerOutput($cur_answer[
'answertext'], $i));
154 $js_include_tpl->setVariable(
'LIST_ITEM_ID', $i);
160 if($cur_answer[
'ok'] ===
true)
163 $text_ok = $lng->txt(
"answer_is_right");
168 $text_ok = $lng->txt(
"answer_is_wrong");
171 $js_include_tpl->setVariable(
'ICON_OK', $icon_ok);
172 $js_include_tpl->setVariable(
'TEXT_OK', $text_ok);
175 $js_include_tpl->parseCurrentBlock();
177 return $js_include_tpl->get();
182 $js_include_tpl =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_html.html", TRUE, TRUE,
"Modules/TestQuestionPool");
183 $js_include_tpl->touchBlock(
'end_list_item');
185 return $js_include_tpl->get();
190 $js_include_tpl =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_html.html", TRUE, TRUE,
"Modules/TestQuestionPool");
191 $js_include_tpl->touchBlock(
'begin_sublist');
193 return $js_include_tpl->get();
198 $js_include_tpl =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_html.html", TRUE, TRUE,
"Modules/TestQuestionPool");
199 $js_include_tpl->touchBlock(
'end_sublist');
201 return $js_include_tpl->get();
212 $input_tpl =
new ilTemplate(
"tpl.prop_nestable_value.html",
true,
true,
"Modules/TestQuestionPool");
214 if(strlen($text_value))
218 $input_tpl->setCurrentBlock(
'nested_terms');
220 $input_tpl->setVariable(
"INPUT_POST_VAR", $this->
getPostVar() .
"[$i]");
221 $input_tpl->setVariable(
"NON_EDITABLE_ID", $this->
getPostVar() .
"[$i]");
224 $input_tpl->setVariable(
"ID", $this->
getFieldId() .
"[$i]");
228 $input_tpl->setCurrentBlock(
'nested_pictures');
232 $input_tpl->setVariable(
"PICTURE_HREF",$thumbweb);
233 $input_tpl->setVariable(
"THUMB_ALT", $lng->txt(
"thumbnail"));
234 $input_tpl->setVariable(
"THUMB_TITLE", $lng->txt(
"thumbnail"));
235 $input_tpl->setVariable(
"NON_EDITABLE_ID", $this->
getPostVar() .
"[$i]");
236 $input_tpl->setVariable(
"HVALUE", $text_value);
237 $input_tpl->setVariable(
"ID", $this->
getFieldId() .
"[$i]");
242 $input_tpl->parseCurrentBlock();
244 return $input_tpl->get();
260 if($shuffle_depth == 1)
263 foreach($this->answers as $cur_answer)
265 $html_output .= $this->
renderListItem($cur_answer,$cur_answer[
'random_id']);
274 $tmp_array[count($tmp_array)][
'ordering_depth'] =
'END_OF_LIST';
276 foreach($this->answers as $cur_answer)
278 $current_depth = $cur_answer[
'ordering_depth'];
279 $next_depth = $tmp_array[$i+1][
'ordering_depth'];
281 if($next_depth ==
'END_OF_LIST')
286 if($previous_depth == $current_depth)
290 if($current_depth == $next_depth)
294 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
297 else if($current_depth > $next_depth)
299 if($previous_depth == $next_depth)
303 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
308 else if($previous_depth > $next_depth)
312 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
314 for($openlists = $next_depth; $openlists < $current_depth; $openlists++)
322 else if($current_depth < $next_depth)
326 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
330 else if($previous_depth > $current_depth)
332 if($current_depth == $next_depth)
336 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
339 else if($current_depth > $next_depth)
343 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
347 else if($current_depth < $next_depth)
349 if($previous_depth == $next_depth)
353 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
356 else if($previous_depth > $next_depth)
360 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
361 for($openlists = $next_depth; $openlists < $current_depth; $openlists++)
369 else if($previous_depth < $current_depth)
371 if($current_depth == $next_depth)
375 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
378 else if($current_depth > $next_depth)
380 if($previous_depth == $next_depth)
384 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
390 else if($previous_depth > $next_depth)
394 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
395 for($openlists = $next_depth; $openlists < $current_depth; $openlists++)
402 else if($current_depth < $next_depth)
406 $html_output .= $this->
renderListItem($cur_answer, $cur_answer[
'random_id']);
410 $previous_depth = $current_depth;
417 include_once
"Services/jQuery/classes/class.iljQueryUtil.php";
421 $tpl->addJavaScript(
"./Services/jQuery/js/jquery.nestable.js" );
427 $js_include_tpl =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_javascript.html", TRUE, TRUE,
"Modules/TestQuestionPool");
428 $js_include_tpl->setCurrentBlock(
'js_include');
436 $js_include_tpl->setVariable(
'PERFORM_JAVASCRIPT',
false );
439 $js_include_tpl->setVariable(
'INSTANCE_ID', $this->
getInstanceId() );
441 $js_include_tpl->setVariable(
'HTML_OUTPUT', $html_output);
443 $js_include_tpl->parseCurrentBlock();
445 return $js_include_tpl->get();
461 $tmp_array = $a_solution_array;
462 $tmp_array[count($tmp_array)][
'depth'] =
'END_OF_LIST';
464 foreach($a_solution_array as $cur_answer)
466 $current_depth = $cur_answer[
'depth'];
467 $next_depth = $tmp_array[$i+1][
'depth'];
468 if($next_depth ==
'END_OF_LIST')
473 if($previous_depth == $current_depth)
477 if($current_depth == $next_depth)
484 else if($current_depth > $next_depth)
486 if($previous_depth == $next_depth)
495 else if($previous_depth > $next_depth)
501 for($openlists = $next_depth; $openlists < $current_depth; $openlists++)
509 else if($current_depth < $next_depth)
518 else if($previous_depth > $current_depth)
520 if($current_depth == $next_depth)
527 else if($current_depth > $next_depth)
535 else if($current_depth < $next_depth)
537 if($previous_depth == $next_depth)
544 else if($previous_depth > $next_depth)
549 for($openlists = $next_depth; $openlists < $current_depth; $openlists++)
557 else if($previous_depth < $current_depth)
559 if($current_depth == $next_depth)
566 else if($current_depth > $next_depth)
568 if($previous_depth == $next_depth)
578 else if($previous_depth > $next_depth)
583 for($openlists = $next_depth; $openlists < $current_depth; $openlists++)
590 else if($current_depth < $next_depth)
598 $previous_depth = $current_depth;
607 include_once
"Services/jQuery/classes/class.iljQueryUtil.php";
610 $tpl->addJavaScript(
"./Services/jQuery/js/jquery.nestable.js");
615 $js_include_tpl =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_javascript.html", TRUE, TRUE,
"Modules/TestQuestionPool");
617 $js_include_tpl->setCurrentBlock(
'js_include');
622 $js_include_tpl->setVariable(
'HTML_OUTPUT', $html_output);
624 $js_include_tpl->parseCurrentBlock();
626 return $js_include_tpl->get();
631 $this->perform_js = $a_bool;