53 $this->ui_factory = $DIC[
'ui.factory'];
54 $this->ui_renderer = $DIC[
'ui.renderer'];
85 $this->list_tpl =
new ilTemplate(
'tpl.prop_nested_ordering_list.html',
true,
true,
'components/ILIAS/TestQuestionPool');
102 $elementList->completeContentsFromElementList(
103 $question->getOrderingElementList()
186 $icon_name =
'standard/icon_not_ok.svg';
187 $label = $this->
lng->txt(
"answer_is_wrong");
188 if ($correctness ===
'correct') {
189 $icon_name =
'standard/icon_ok.svg';
190 $label = $this->
lng->txt(
"answer_is_right");
193 $icon = $this->ui_factory->symbol()->icon()->custom(
197 return $this->ui_renderer->render($icon);
202 return new ilTemplate(
'tpl.prop_ass_nested_order_elem.html',
true,
true,
'components/ILIAS/TestQuestionPool');
218 string $content_post_var,
219 string $position_post_var,
220 string $indentation_post_var
228 $tpl->setCurrentBlock(
'item_text');
230 $tpl->parseCurrentBlock();
236 $tpl->setCurrentBlock(
'item_image');
239 $tpl->parseCurrentBlock();
244 $correctness =
'not_correct';
246 $correctness =
'correct';
248 $tpl->setCurrentBlock(
'correctness_icon');
251 $tpl->parseCurrentBlock();
254 $tpl->setCurrentBlock(
'item');
255 $tpl->setVariable(
'ITEM_CONTENT_POSTVAR', $content_post_var);
257 $tpl->setVariable(
'ITEM_POSITION_POSTVAR', $position_post_var);
258 $tpl->setVariable(
'ITEM_POSITION', $element[
'ordering_position']);
259 $tpl->setVariable(
'ITEM_INDENTATION_POSTVAR', $indentation_post_var);
260 $tpl->setVariable(
'ITEM_INDENTATION', $element[
'ordering_indentation']);
261 $tpl->parseCurrentBlock();
268 if (!is_array(
$data)) {
285 $list_item_tpl =
new ilTemplate(
'tpl.prop_nested_ordering_list_item.html',
true,
true,
'components/ILIAS/TestQuestionPool');
290 $list_item_tpl->setVariable(
'LIST_ITEM_VALUE', $this->
getItemHtml(
295 $indentation_post_var
298 if ($this->nesting_enabled) {
299 $list_item_tpl->setCurrentBlock(
'nested_list');
300 $list_item_tpl->setVariable(
'SUB_LIST', $children);
301 $list_item_tpl->parseCurrentBlock();
303 return $list_item_tpl->get();
311 if ($this->nesting_enabled) {
315 $this->list_tpl->setVariable(
319 static fn(array
$a, array
$b):
int => $a[
'ordering_position'] - $b[
'ordering_position']
323 return $this->list_tpl->get();
328 foreach (array_keys($values) as $k) {
336 $values_with_parent = [];
338 foreach ($values as $k => $v) {
342 if ($v[
'ordering_indentation'] > 0) {
343 $v[
'parent'] = $levels_array[$v[
'ordering_indentation'] - 1];
345 $levels_array[$v[
'ordering_indentation']] = $k;
346 $values_with_parent[$k] = $v;
351 static fn(array
$a, array
$b):
int => $b[
'ordering_indentation'] - $a[
'ordering_indentation']
354 foreach (array_keys($values_with_parent) as $k) {
355 $v = $values_with_parent[$k];
356 if ($v[
'parent'] !==
null) {
357 $values_with_parent[$v[
'parent']][
'children'][$k] = $v;
363 static fn(array $v):
bool => $v[
'ordering_indentation'] === 0
369 usort($array, $sort_closure);
372 function (
string $c, array $v) use ($sort_closure):
string {
374 if ($this->nesting_enabled && $v[
'children'] !== []) {
375 $children = $this->
buildHTMLView($v[
'children'], $sort_closure);
384 public function render(
string $a_mode =
''): string
386 if (!$this->styling_disabled) {
387 $this->
getGlobalTpl()->addCss(
'assets/css/content.css');
390 if ($this->interaction_enabled) {
409 $this->
getGlobalTpl()->addJavascript(
'assets/js/orderingvertical.js');
411 'il.test.orderingvertical.init(document.querySelector("#nestable_ordering"));'
static buildInstance(int $question_id, array $elements=[])
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
getRandomIdentifierIndexedElements()
__construct(Container $dic, ilPlugin $plugin)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
const F_NESTED_IDENTIFIER_PREFIX