ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjLearningSequenceContentTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected bool $lp_globally_enabled;
24
25 public function __construct(
26 protected ilObjLearningSequenceContentGUI $parent_gui,
27 protected ilObjLearningSequenceGUI $container_gui,
28 protected string $cmd,
29 ilCtrl $ctrl, //table2gui
30 ilLanguage $lng, //tablegui
31 protected ilAccess $access,
32 protected ILIAS\UI\Factory $ui_factory,
33 protected ILIAS\UI\Renderer $ui_renderer,
34 protected LSItemOnlineStatus $ls_item_online_status,
35 protected string $alert_icon
36 ) {
37 parent::__construct($parent_gui, $cmd);
38
39 $this->lp_globally_enabled = ilObjUserTracking::_enabledLearningProgress();
40
41 $this->lng->loadLanguageModule('trac');
42
43 $this->setTitle($this->lng->txt("table_sequence_content"));
44 $this->setRowTemplate("tpl.content_table.html", "components/ILIAS/LearningSequence");
45 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
46 $this->setExternalSorting(true);
47 $this->setEnableAllCommand(true);
48 $this->setShowRowsSelector(false);
49 $this->setTopCommands(true);
50 $this->setEnableHeader(true);
51
52 $this->addColumn("", "", "1", true);
53 $this->addColumn("");
54 $this->addColumn($this->lng->txt("table_position"));
55 $this->addColumn($this->lng->txt("table_title"));
56 $this->addColumn($this->lng->txt("table_online"));
57 $this->addColumn($this->lng->txt("table_may_proceed"));
58 if ($this->lp_globally_enabled) {
59 $this->addColumn($this->lng->txt("table_lp_settings"));
60 }
61 $this->addColumn($this->lng->txt("table_actions"));
62
63 $this->setLimit(9999);
64 }
65
66 protected function fillRow(array $a_set): void
67 {
69 $ls_item = $a_set[0];
70
71 $ni = new ilNumberInputGUI(
72 "",
73 $this->parent_gui->getFieldName($this->parent_gui::FIELD_ORDER, $ls_item->getRefId())
74 );
75 $ni->setSize(3);
76 $ni->setValue((string) (($ls_item->getOrderNumber() + 1) * 10));
77
78 $cb = new ilCheckboxInputGUI(
79 "",
80 $this->parent_gui->getFieldName($this->parent_gui::FIELD_ONLINE, $ls_item->getRefId())
81 );
82 $cb->setChecked($ls_item->isOnline());
83 if (!$this->ls_item_online_status->hasChangeableOnlineStatus($ls_item->getRefId())) {
84 $cb->setDisabled(true);
85 }
86 $this->tpl->setVariable("ONLINE", $cb->render());
87
88 $si = new ilSelectInputGUI(
89 "",
90 $this->parent_gui->getFieldName($this->parent_gui::FIELD_POSTCONDITION_TYPE, $ls_item->getRefId())
91 );
92 $options = $this->parent_gui->getPossiblePostConditionsForType($ls_item->getType());
93
94 $si->setOptions($options);
95 $si->setValue($ls_item->getPostCondition()->getConditionOperator());
96
97 $action_items = $this->getActionMenuItems($ls_item->getRefId(), $ls_item->getType());
98 $obj_link = $this->getEditLink($ls_item->getRefId(), $ls_item->getType(), $action_items);
99
100 $title = $ls_item->getTitle();
101 $title = sprintf(
102 '<a href="%s">%s</a>',
103 $obj_link,
104 $title
105 );
106
107 $this->tpl->setVariable("ID", $ls_item->getRefId());
108
109 $this->tpl->setVariable(
110 "IMAGE",
111 $this->ui_renderer->render(
112 $this->ui_factory->symbol()->icon()->custom(
113 $ls_item->getIconPath(),
114 $ls_item->getType()
115 )->withSize('medium')
116 )
117 );
118
119 $this->tpl->setVariable("ORDER", $ni->render());
120 $this->tpl->setVariable("TITLE", $title);
121 $this->tpl->setVariable("POST_CONDITIONS", $si->render());
122
123 if ($this->lp_globally_enabled) {
124 $lp_setting = $ls_item->getPostCondition()->getConditionOperator() === ilLSPostCondition::OPERATOR_LP ?
125 $this->getLPSettingsRepresentation($ls_item) : $this->lng->txt("lp_not_relevant_post_cond");
126 $this->tpl->setVariable("LP_SETTINGS", $lp_setting);
127 }
128
129 $this->tpl->setVariable("ACTIONS", $this->getItemActionsMenu($ls_item->getRefId(), $ls_item->getType()));
130 $this->tpl->setVariable("TYPE", $ls_item->getType());
131 }
132
133 protected function getLPSettingsRepresentation(LSItem $ls_item): string
134 {
135 $mode = $ls_item->getLPMode();
136 $setting = ilLPObjSettings::_mode2Text($mode);
137 if (
138 $ls_item->getPostCondition()->getConditionOperator() === ilLSPostCondition::OPERATOR_LP
139 && $mode === 0
140 ) {
141 $setting = $this->alert_icon . $setting;
142 }
143 return $setting;
144 }
145
146 protected function getItemActionsMenu(int $ref_id, string $type): string
147 {
148 $item_obj_id = $this->getObjIdFor($ref_id);
149 $item_list_gui = $this->getListGuiFor($type);
150 $item_list_gui->initItem($ref_id, $item_obj_id, $type);
151
152 $item_list_gui->enableCut(true);
153 $item_list_gui->enableDelete(true);
154 $item_list_gui->enableLink(true);
155 $item_list_gui->enableTimings(false);
156
157 $item_list_gui->setContainerObject($this->container_gui);
158
159 return $item_list_gui->getCommandsHTML();
160 }
161
172 protected function getActionMenuItems(int $ref_id, string $type): array
173 {
174 $item_obj_id = $this->getObjIdFor($ref_id);
175 $item_list_gui = $this->getListGuiFor($type);
176 $item_list_gui->initItem($ref_id, $item_obj_id, $type);
177 return $item_list_gui->getCommands();
178 }
179
180 protected function getEditLink(int $ref_id, string $type, array $action_items): ?string
181 {
182 switch ($type) {
183 case $this->ls_item_online_status::S_LEARNMODULE_IL:
184 case $this->ls_item_online_status::S_LEARNMODULE_HTML:
185 case $this->ls_item_online_status::S_SURVEY:
186 $prop_for_type = 'properties';
187 break;
188
189 case $this->ls_item_online_status::S_SAHS:
190 case $this->ls_item_online_status::S_CONTENTPAGE:
191 case $this->ls_item_online_status::S_EXERCISE:
192 case $this->ls_item_online_status::S_FILE:
193 $prop_for_type = 'edit';
194 break;
195
196 case $this->ls_item_online_status::S_TEST:
197 $prop_for_type = 'ilObjTestSettingsMainGUI::showForm';
198 break;
199
200 case $this->ls_item_online_status::S_IND_ASSESSMENT:
201 default:
202 return $this->getStdLink($ref_id, $type);
203 }
204
205 $props = array_filter(
206 $action_items,
207 fn($action_item) => $action_item['cmd'] === $prop_for_type
208 );
209
210 if ($props !== []) {
211 return array_shift($props)['link'];
212 }
213 return null;
214 }
215
216 protected function getObjIdFor(int $ref_id): int
217 {
219 }
220
221 protected function getListGuiFor(string $type): ilObjectListGUI
222 {
224 }
225
226 protected function getStdLink(int $ref_id, string $type): string
227 {
228 return ilLink::_getLink($ref_id, $type);
229 }
230}
Data holding class LSItem .
Definition: LSItem.php:25
getLPMode()
Definition: LSItem.php:98
getPostCondition()
Definition: LSItem.php:88
Class ilAccessHandler Checks access for ILIAS objects.
This class represents a checkbox property in a property form.
Class ilCtrl provides processing control methods.
static _mode2Text(int $a_mode)
language handling
This class represents a number property in a property form.
getEditLink(int $ref_id, string $type, array $action_items)
__construct(protected ilObjLearningSequenceContentGUI $parent_gui, protected ilObjLearningSequenceGUI $container_gui, protected string $cmd, ilCtrl $ctrl, ilLanguage $lng, protected ilAccess $access, protected ILIAS\UI\Factory $ui_factory, protected ILIAS\UI\Renderer $ui_renderer, protected LSItemOnlineStatus $ls_item_online_status, protected string $alert_icon)
Class ilObjLearningSequenceGUI @ilCtrl_isCalledBy ilObjLearningSequenceGUI: ilRepositoryGUI @ilCtrl_i...
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
static _lookupObjId(int $ref_id)
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setEnableAllCommand(bool $a_value)
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setEnableHeader(bool $a_enableheader)
fillRow(array $a_set)
Standard Version of Fill Row.
setTopCommands(bool $a_val)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
ilLanguage $lng
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.