ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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", "components/ILIAS/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("standard/icon_ok.svg"), 'ok')->withSize('small')
90 );
91 $this->not_possible_image = $ui_renderer->render(
92 $ui_factory->symbol()->icon()->custom(ilUtil::getImagePath("standard/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 (int) $a_set["program_status"],
117 ));
118 $this->tpl->setVariable("POSSIBLE", $a_set["possible"] ? $this->possible_image : $this->not_possible_image);
119 $this->tpl->setVariable("CHANGED_BY", $a_set["changed_by"]);
120 $this->tpl->setVariable("COMPLETION_BY", $a_set["completion_by"]);
121
122 foreach ($this->getSelectedColumns() as $column) {
123 switch ($column) {
125 $this->tpl->setCurrentBlock("assignment_date");
126 $this->tpl->setVariable("ASSIGNMENT_DATE", $a_set["assignment_date"]);
127 $this->tpl->parseCurrentBlock("assignment_date");
128 break;
130 $this->tpl->setCurrentBlock("deadline");
131 $this->tpl->setVariable("DEADLINE", $this->getDeadlineInput($a_set["progress_id"], $a_set["deadline"]));
132 $this->tpl->parseCurrentBlock("deadline");
133 break;
135 $this->tpl->setCurrentBlock("completion_date");
136 $this->tpl->setVariable("COMPLETION_DATE", $a_set["completion_date"]);
137 $this->tpl->parseCurrentBlock("completion_date");
138 break;
139 }
140 }
141 }
142
143 public function getSelectableColumns(): array
144 {
145 $cols = array();
146
148 "txt" => $this->lng->txt("assignment_date"));
149 $cols[self::SEL_COLUMN_DEADLINE] = array(
150 "txt" => $this->lng->txt("prg_deadline"));
152 "txt" => $this->lng->txt("completion_date"));
153 return $cols;
154 }
155
156 protected function fetchData(): array
157 {
158 $prg_id = $this->assignment->getRootId();
160
161 $ass_id = $this->assignment->getId();
162 $usr_id = $this->assignment->getUserId();
163 $plan = array();
164
165 $prg->applyToSubTreeNodes(
166 function ($node) use ($prg_id, $ass_id, $usr_id, &$plan, $prg) {
167 $progress = $this->assignment->getProgressForNode($node->getId());
168 $completion_by = $progress->getCompletionBy();
169
170 if ($completion_by === ilPRGProgress::COMPLETED_BY_SUBNODES) {
171 $successful_subnodes = array_filter(
172 $progress->getSubnodes(),
173 static fn(ilPRGProgress $pgs): bool => $pgs->isSuccessful()
174 );
175 $successful_subnode_ids = array_map(
176 static fn(ilPRGProgress $pgs): int => $pgs->getNodeId(),
177 $successful_subnodes
178 );
179 $out = array_map(
180 fn(int $node_obj_id): string => ilStudyProgrammeUserTable::lookupTitle($node_obj_id),
181 $successful_subnode_ids
182 );
183 $completion_by = implode(', ', $out);
184 } else {
185 $completion_by = $progress->isSuccessful() ? ilStudyProgrammeUserTable::lookupTitle($completion_by) : '';
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()
196 || $programme->canBeCompleted($progress)
197 || (!$progress->isRelevant() && $programme->getStatus() !== ilStudyProgrammeSettings::STATUS_DRAFT),
198 "changed_by" => ilObjUser::_lookupLogin($progress->getLastChangeBy()),
199 "completion_by" => $completion_by,
200 "progress_id" => $progress->getId(),
201 //draft/active/outdated
202 "program_status" => $programme->getStatus(),
203 "assignment_date" => $progress->getAssignmentDate()->format('d.m.Y'),
204 "deadline" => $progress->isSuccessful() ? null : $progress->getDeadline(),
205 "completion_date" => $progress->getCompletionDate() ? $progress->getCompletionDate()->format('d.m.Y') : ''
206 ];
207 },
208 true
209 );
210 return $plan;
211 }
212
213 protected function getManualStatusSelect(string $progress_id, int $status, int $node_lifecycle_status): string
214 {
215 $parent = $this->getParentObject();
216 $options = [
217 $parent::MANUAL_STATUS_NONE => '-',
218 ilPRGProgress::STATUS_IN_PROGRESS => $this->lng->txt("prg_status_in_progress"),
219 ilPRGProgress::STATUS_ACCREDITED => $this->lng->txt("prg_status_accredited"),
220 ilPRGProgress::STATUS_NOT_RELEVANT => $this->lng->txt("prg_status_not_relevant")
221 //COMPLETED/FAILED are not to be set manually.
222 ];
223
225
226 $options = array_filter(
227 $options,
228 static function ($o) use ($allowed, $parent, $node_lifecycle_status): bool {
229 return (in_array($o, $allowed) || $o === $parent::MANUAL_STATUS_NONE)
230 && ($node_lifecycle_status !== ilStudyProgrammeSettings::STATUS_DRAFT);
231 },
232 ARRAY_FILTER_USE_KEY
233 );
234
235 $select = new ilSelectInputGUI("", $parent::POST_VAR_STATUS . "[$progress_id]");
236 $select->setOptions($options);
237 $select->setValue($parent::MANUAL_STATUS_NONE);
238
239 return $select->render();
240 }
241
242 protected function getRequiredPointsInput(string $progress_id, int $status, string $points_required): string
243 {
244 if ($status != ilPRGProgress::STATUS_IN_PROGRESS) {
245 return $points_required;
246 }
247
248 $parent = $this->getParentObject();
249 $input = new ilNumberInputGUI("", $parent::POST_VAR_REQUIRED_POINTS . "[$progress_id]");
250 $input->setValue($points_required);
251 $input->setSize(5);
252 return $input->render();
253 }
254
255 protected function getDeadlineInput(string $progress_id, $deadline): string
256 {
257 $parent = $this->getParentObject();
258 $gui = new ilDateTimeInputGUI("", $parent::POST_VAR_DEADLINE . "[$progress_id]");
259 $gui->setDate($deadline ? new ilDateTime($deadline->format('Y-m-d H:i:s'), IL_CAL_DATETIME) : null);
260 return $gui->render();
261 }
262}
$out
Definition: buildRTE.php:24
const IL_CAL_DATETIME
return true
This class represents a date/time property in a property form.
@classDescription Date and time handling
This class represents a number property in a property form.
static getInstanceByObjId(int $obj_id)
static _lookupLogin(int $a_user_id)
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
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)
getManualStatusSelect(string $progress_id, int $status, int $node_lifecycle_status)
__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 $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Interface ilDBInterface.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26