ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilQuestionUsagesTableGUI.php
Go to the documentation of this file.
1<?php
2
24{
28 protected $question;
29
35 public function __construct($controller, $cmd, $template_context, assQuestion $question)
36 {
37 $this->question = $question;
38 $this->setId('qst_usage_' . $question->getId());
39 parent::__construct($controller, $cmd);
40
41 $this->setRowTemplate('tpl.il_as_qpl_question_usage_table_row.html', 'components/ILIAS/TestQuestionPool');
42 $this->setLimit(PHP_INT_MAX);
43
44 $this->setDefaultOrderField('title');
45 $this->setDefaultOrderDirection('ASC');
46
47 $this->setTitle($this->lng->txt('question_instances_title'));
48
49 $this->disable('sort');
50 $this->disable('hits');
51 $this->disable('numinfo');
52
53 $this->initColumns();
54 $this->initData();
55 }
56
60 protected function initColumns(): void
61 {
62 $this->addColumn($this->lng->txt('title'), 'title');
63 $this->addColumn($this->lng->txt('author'), 'author');
64 $this->addColumn($this->lng->txt('path'), '');
65 }
66
70 protected function initData(): void
71 {
75 global $DIC;
76 $tree = $DIC['tree'];
77
78 $path = new ilPathGUI();
79
80 $rows = [];
81 foreach ($this->question->getInstances() as $instance) {
82 foreach ($instance['refs'] as $ref_id) {
83 $trashed = $tree->isDeleted($ref_id);
84 $rows[] = [
85 'title' => $instance['title'],
86 'author' => $instance['author'],
87 'ref_id' => $ref_id,
88 'is_trashed' => $trashed,
89 'path' => $trashed ? $this->lng->txt('deleted') : $path->getPath(ROOT_FOLDER_ID, (int) $ref_id)
90 ];
91 }
92 }
93 $this->setData($rows);
94 }
95
99 public function fillRow(array $a_set): void
100 {
104 global $DIC;
105 $ilAccess = $DIC['ilAccess'];
106
107 $this->tpl->setVariable('USAGE_INSTANCE_TITLE', $a_set['title']);
108 $this->tpl->setVariable('USAGE_AUTHOR', $a_set['author']);
109 $this->tpl->setVariable('USAGE_PATH', $a_set['path']);
110
111 if ($ilAccess->checkAccess('read', '', $a_set['ref_id']) && !$a_set['is_trashed']) {
112 $link = new ilLink();
113
114 $this->tpl->setVariable('USAGE_INSTANCE_LINKTED_TITLE', $a_set['title']);
115 $this->tpl->setVariable('USAGE_INSTANCE_HREF', $link->_getStaticLink($a_set['ref_id'], 'tst'));
116
117 $this->tpl->setCurrentBlock('linked_title_b');
118 $this->tpl->touchBlock('linked_title_b');
119 $this->tpl->parseCurrentBlock();
120 }
121 }
122}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($controller, $cmd, $template_context, assQuestion $question)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
fillRow(array $a_set)
Standard Version of Fill Row.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
disable(string $a_module_name)
const ROOT_FOLDER_ID
Definition: constants.php:32
$ref_id
Definition: ltiauth.php:66
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26