ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilStudyProgrammeIndividualPlanTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private const SEL_COLUMN_COMPLETION_DATE = "completion_date";
24 private const SEL_COLUMN_DEADLINE = "prg_deadline";
25 private const SEL_COLUMN_ASSIGNMENT_DATE = "assignment_date";
26
27 protected ilDBInterface $db;
28
30 protected string $possible_image;
31 protected string $not_possible_image;
32
33 public function __construct(
36 ) {
37 $this->setId("manage_indiv");
38
39 parent::__construct($parent_obj, 'manage');
40
41 global $DIC;
42 $this->ctrl = $DIC['ilCtrl'];
43 $this->lng = $DIC['lng'];
44 $this->db = $DIC['ilDB'];
45
46 $this->assignment = $ass;
47
48 $this->setEnableTitle(true);
49 $this->setTopCommands(false);
50 $this->setEnableHeader(true);
51 // TODO: switch this to internal sorting/segmentation
52 $this->setExternalSorting(false);
53 $this->setExternalSegmentation(false);
54 $this->setRowTemplate("tpl.individual_plan_table_row.html", "Modules/StudyProgramme");
55 $this->setDefaultOrderDirection("asc");
56
57 $this->getParentObject()->appendIndividualPlanActions($this);
58
59 $columns = [
60 "status",
61 "title",
62 "prg_points_current",
63 "prg_points_required",
64 "prg_manual_status",
65 "prg_possible",
66 "prg_changed_by",
67 "prg_completion_by"
68 ];
69
70 foreach ($this->getSelectedColumns() as $column) {
71 $columns[] = $column;
72 }
73
74 foreach ($columns as $lng_var) {
75 $this->addColumn($this->lng->txt($lng_var));
76 }
77
78 $plan = $this->fetchData();
79
80 $this->setMaxCount(count($plan));
81 $this->setData($plan);
82
83 $this->determineLimit();
85
86 $ui_factory = $DIC['ui.factory'];
87 $ui_renderer = $DIC['ui.renderer'];
88 $this->possible_image = $ui_renderer->render(
89 $ui_factory->symbol()->icon()->custom(ilUtil::getImagePath("icon_ok.svg"), 'ok')->withSize('small')
90 );
91 $this->not_possible_image = $ui_renderer->render(
92 $ui_factory->symbol()->icon()->custom(ilUtil::getImagePath("icon_not_ok.svg"), 'not ok')->withSize('small')
93 );
94 }
95
96 protected function fillRow(array $a_set): void
97 {
98 $this->tpl->setVariable("STATUS", $a_set['status_repr']);
99
100 $title = $a_set["title"];
101 if ((int) $a_set["program_status"] === ilStudyProgrammeSettings::STATUS_DRAFT) {
102 $title .= " (" . $this->lng->txt("prg_status_draft") . ")";
103 } elseif ((int) $a_set["program_status"] === ilStudyProgrammeSettings::STATUS_OUTDATED) {
104 $title .= " (" . $this->lng->txt("prg_status_outdated") . ")";
105 }
106
107 $this->tpl->setVariable("TITLE", $title);
108 $this->tpl->setVariable("POINTS_CURRENT", $a_set["points_current"]);
109 $this->tpl->setVariable(
110 "POINTS_REQUIRED",
111 $this->getRequiredPointsInput($a_set["progress_id"], $a_set["status"], (string)$a_set["points_required"])
112 );
113 $this->tpl->setVariable("MANUAL_STATUS", $this->getManualStatusSelect(
114 $a_set["progress_id"],
115 (int) $a_set["status"]
116 ));
117 $this->tpl->setVariable("POSSIBLE", $a_set["possible"] ? $this->possible_image : $this->not_possible_image);
118 $this->tpl->setVariable("CHANGED_BY", $a_set["changed_by"]);
119 $this->tpl->setVariable("COMPLETION_BY", $a_set["completion_by"]);
120
121 foreach ($this->getSelectedColumns() as $column) {
122 switch ($column) {
124 $this->tpl->setCurrentBlock("assignment_date");
125 $this->tpl->setVariable("ASSIGNMENT_DATE", $a_set["assignment_date"]);
126 $this->tpl->parseCurrentBlock("assignment_date");
127 break;
129 $this->tpl->setCurrentBlock("deadline");
130 $this->tpl->setVariable("DEADLINE", $this->getDeadlineInput($a_set["progress_id"], $a_set["deadline"]));
131 $this->tpl->parseCurrentBlock("deadline");
132 break;
134 $this->tpl->setCurrentBlock("completion_date");
135 $this->tpl->setVariable("COMPLETION_DATE", $a_set["completion_date"]);
136 $this->tpl->parseCurrentBlock("completion_date");
137 break;
138 }
139 }
140 }
141
142 public function getSelectableColumns(): array
143 {
144 $cols = array();
145
147 "txt" => $this->lng->txt("assignment_date"));
149 "txt" => $this->lng->txt("prg_deadline"));
151 "txt" => $this->lng->txt("completion_date"));
152 return $cols;
153 }
154
155 protected function fetchData(): array
156 {
157 $prg_id = $this->assignment->getRootId();
159
160 $ass_id = $this->assignment->getId();
161 $usr_id = $this->assignment->getUserId();
162 $plan = array();
163
164 $prg->applyToSubTreeNodes(
165 function ($node) use ($prg_id, $ass_id, $usr_id, &$plan, $prg) {
166 $progress = $this->assignment->getProgressForNode($node->getId());
167 $completion_by_id = $progress->getCompletionBy();
168
169 if ($completion_by_id) {
170 $completion_by = ilObjUser::_lookupLogin($completion_by_id);
171 if (!$completion_by) {
172 $type = ilObject::_lookupType($completion_by_id);
173 if ($type === "crsr") {
174 $completion_by = ilContainerReference::_lookupTitle($completion_by_id);
175 } else {
176 $completion_by = ilObject::_lookupTitle($completion_by_id);
177 }
178 }
179 } else {
180 $completion_by = '';
181 if ($progress->isSuccessful()) {
182 if ($progress->getCompletionBy()) {
183 $completion_by = ilStudyProgrammeUserTable::lookupTitle($progress->getCompletionBy());
184 }
185 }
186 }
187
188 $programme = ilObjStudyProgramme::getInstanceByObjId($progress->getNodeId());
189 $plan[] = [
190 "status" => $progress->getStatus(),
191 "status_repr" => $programme->statusToRepr($progress->getStatus()),
192 "title" => $node->getTitle(),
193 "points_current" => $progress->getCurrentAmountOfPoints(),
194 "points_required" => $progress->getAmountOfPoints(),
195 "possible" => $progress->isSuccessful() || $programme->canBeCompleted($progress) || !$progress->isRelevant(),
196 "changed_by" => ilObjUser::_lookupLogin($progress->getLastChangeBy()),
197 "completion_by" => $completion_by,
198 "progress_id" => $progress->getId(),
199 //draft/active/outdated
200 "program_status" => $programme->getStatus(),
201 "assignment_date" => $progress->getAssignmentDate()->format('d.m.Y'),
202 "deadline" => $progress->isSuccessful() ? null : $progress->getDeadline(),
203 "completion_date" => $progress->getCompletionDate() ? $progress->getCompletionDate()->format('d.m.Y') : ''
204 ];
205 },
206 true
207 );
208 return $plan;
209 }
210
211 protected function getManualStatusSelect(string $progress_id, int $status): string
212 {
213 $parent = $this->getParentObject();
214 $options = [
215 $parent::MANUAL_STATUS_NONE => '-',
216 ilPRGProgress::STATUS_IN_PROGRESS => $this->lng->txt("prg_status_in_progress"),
217 ilPRGProgress::STATUS_ACCREDITED => $this->lng->txt("prg_status_accredited"),
218 ilPRGProgress::STATUS_NOT_RELEVANT => $this->lng->txt("prg_status_not_relevant")
219 //COMPLETED/FAILED are not to be set manually.
220 ];
221
223
224 $options = array_filter(
225 $options,
226 static function ($o) use ($allowed, $parent): bool {
227 return in_array($o, $allowed) || $o === $parent::MANUAL_STATUS_NONE;
228 },
229 ARRAY_FILTER_USE_KEY
230 );
231
232 $select = new ilSelectInputGUI("", $parent::POST_VAR_STATUS . "[$progress_id]");
233 $select->setOptions($options);
234 $select->setValue($parent::MANUAL_STATUS_NONE);
235
236 return $select->render();
237 }
238
239 protected function getRequiredPointsInput(string $progress_id, int $status, string $points_required): string
240 {
241 if ($status != ilPRGProgress::STATUS_IN_PROGRESS) {
242 return $points_required;
243 }
244
245 $parent = $this->getParentObject();
246 $input = new ilNumberInputGUI("", $parent::POST_VAR_REQUIRED_POINTS . "[$progress_id]");
247 $input->setValue($points_required);
248 $input->setSize(5);
249 return $input->render();
250 }
251
252 protected function getDeadlineInput(string $progress_id, $deadline): string
253 {
254 $parent = $this->getParentObject();
255 $gui = new ilDateTimeInputGUI("", $parent::POST_VAR_DEADLINE . "[$progress_id]");
256 $gui->setDate($deadline ? new ilDateTime($deadline->format('Y-m-d H:i:s'), IL_CAL_DATETIME) : null);
257 return $gui->render();
258 }
259}
const IL_CAL_DATETIME
return true
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@classDescription Date and time handling
This class represents a number property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(int $obj_id)
static _lookupLogin(int $a_user_id)
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
static getAllowedTargetStatusFor(int $status_from)
This class represents a selection list property in a property form.
getRequiredPointsInput(string $progress_id, int $status, string $points_required)
__construct(ilObjStudyProgrammeIndividualPlanGUI $parent_obj, ilPRGAssignment $ass)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
determineOffsetAndOrder(bool $a_omit_offset=false)
setExternalSegmentation(bool $a_val)
setEnableTitle(bool $a_enabletitle)
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)
setTopCommands(bool $a_val)
setExternalSorting(bool $a_val)
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.
setMaxCount(int $a_max_count)
set max.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$cols
Definition: xhr_table.php:11