ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilStudyProgrammeIndividualPlanTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
13{
14 const SEL_COLUMN_COMPLETION_DATE = "completion_date";
15 const SEL_COLUMN_DEADLINE = "prg_deadline";
16 const SEL_COLUMN_ASSIGNMENT_DATE = "assignment_date";
17
18 protected $assignment;
23
24 public function __construct(
28 ) {
29 $this->setId("manage_indiv");
30
31 $this->sp_user_progress_db = $sp_user_progress_db;
32
33 parent::__construct($a_parent_obj, 'manage');
34
35 global $DIC;
36 $ilCtrl = $DIC['ilCtrl'];
37 $lng = $DIC['lng'];
38 $ilDB = $DIC['ilDB'];
39 $this->ctrl = $ilCtrl;
40 $this->lng = $lng;
41 $this->db = $ilDB;
42
43 $this->assignment = $a_ass;
44
45 $this->setEnableTitle(true);
46 $this->setTopCommands(false);
47 $this->setEnableHeader(true);
48 // TODO: switch this to internal sorting/segmentation
49 $this->setExternalSorting(false);
50 $this->setExternalSegmentation(false);
51 $this->setRowTemplate("tpl.individual_plan_table_row.html", "Modules/StudyProgramme");
52 $this->setDefaultOrderDirection("asc");
53
54 $this->getParentObject()->appendIndividualPlanActions($this);
55
56 $columns = array( "status"
57 , "title"
58 , "prg_points_current"
59 , "prg_points_required"
60 , "prg_manual_status"
61 , "prg_possible"
62 , "prg_changed_by"
63 , "prg_completion_by"
64 );
65
66 foreach ($this->getSelectedColumns() as $column) {
67 $columns[] = $column;
68 }
69
70 foreach ($columns as $lng_var) {
71 $this->addColumn($lng->txt($lng_var));
72 }
73
74 $plan = $this->fetchData();
75
76 $this->setMaxCount(count($plan));
77 $this->setData($plan);
78
79 $this->determineLimit();
81
82 $this->possible_image = "<img src='" . ilUtil::getImagePath("icon_ok.svg") . "' alt='ok'>";
83 $this->not_possible_image = "<img src='" . ilUtil::getImagePath("icon_not_ok.svg") . "' alt='not ok'>";
84 }
85
86 protected function fillRow($a_set)
87 {
88 $this->tpl->setVariable("STATUS", $a_set['status_repr']);
89
90 $title = $a_set["title"];
91 if ($a_set["program_status"] == ilStudyProgrammeSettings::STATUS_DRAFT) {
92 $title .= " (" . $this->lng->txt("prg_status_draft") . ")";
93 } elseif ($a_set["program_status"] == ilStudyProgrammeSettings::STATUS_OUTDATED) {
94 $title .= " (" . $this->lng->txt("prg_status_outdated") . ")";
95 }
96
97 $this->tpl->setVariable("TITLE", $title);
98 $this->tpl->setVariable("POINTS_CURRENT", $a_set["points_current"]);
99 $this->tpl->setVariable("POINTS_REQUIRED", $this->getRequiredPointsInput($a_set["progress_id"], $a_set["status"], $a_set["points_required"]));
100 $this->tpl->setVariable("MANUAL_STATUS", $this->getManualStatusSelect(
101 $a_set["progress_id"],
102 $a_set["status"]
103 ));
104 $this->tpl->setVariable("POSSIBLE", $a_set["possible"] ? $this->possible_image : $this->not_possible_image);
105 $this->tpl->setVariable("CHANGED_BY", $a_set["changed_by"]);
106 $this->tpl->setVariable("COMPLETION_BY", $a_set["completion_by"]);
107
108 foreach ($this->getSelectedColumns() as $column) {
109 switch ($column) {
111 $this->tpl->setCurrentBlock("assignment_date");
112 $this->tpl->setVariable("ASSIGNMENT_DATE", $a_set["assignment_date"]);
113 $this->tpl->parseCurrentBlock("assignment_date");
114 break;
116 $this->tpl->setCurrentBlock("deadline");
117 $this->tpl->setVariable("DEADLINE", $this->getDeadlineInput($a_set["progress_id"], $a_set["deadline"]));
118 $this->tpl->parseCurrentBlock("deadline");
119 break;
121 $this->tpl->setCurrentBlock("completion_date");
122 $this->tpl->setVariable("COMPLETION_DATE", $a_set["completion_date"]);
123 $this->tpl->parseCurrentBlock("completion_date");
124 break;
125 }
126 }
127 }
128
134 public function getSelectableColumns()
135 {
136 $cols = array();
137
139 "txt" => $this->lng->txt("assignment_date"));
141 "txt" => $this->lng->txt("prg_deadline"));
143 "txt" => $this->lng->txt("completion_date"));
144 return $cols;
145 }
146
147 protected function fetchData()
148 {
149 $prg_id = $this->assignment->getRootId();
151
152 $ass_id = $this->assignment->getId();
153 $usr_id = $this->assignment->getUserId();
154 $plan = array();
155
156 $prg->applyToSubTreeNodes(
157 function ($node) use ($prg_id, $ass_id, $usr_id, &$plan, $prg) {
158 $progress = $this->sp_user_progress_db->getByIds($node->getId(), $ass_id);
159 $completion_by_id = $progress->getCompletionBy();
160
161 if ($completion_by_id) {
162 $completion_by = ilObjUser::_lookupLogin($completion_by_id);
163 if (!$completion_by) {
164 $type = ilObject::_lookupType($completion_by_id);
165 if ($type == "crsr") {
166 $completion_by = ilContainerReference::_lookupTitle($completion_by_id);
167 } else {
168 $completion_by = ilObject::_lookupTitle($completion_by_id);
169 }
170 }
171 } else {
172 $completion_by = '';
173 if ($progress->isSuccessful()) {
174 $names = $node->getNamesOfCompletedOrAccreditedChildren($ass_id);
175 $completion_by = implode(", ", $names);
176 }
177 }
178
179 $programme = ilObjStudyProgramme::getInstanceByObjId($progress->getNodeId());
180 $plan[] = array( "status" => $progress->getStatus()
181 , "status_repr" => $programme->statusToRepr($progress->getStatus())
182 , "title" => $node->getTitle()
183 , "points_current" => $progress->getCurrentAmountOfPoints()
184 , "points_required" => $progress->getAmountOfPoints()
185 , "possible" => $progress->isSuccessful()
186 || $programme->canBeCompleted($progress)
187 || !$progress->isRelevant()
188 , "changed_by" => ilObjUser::_lookupLogin($progress->getLastChangeBy())
189 , "completion_by" => $completion_by
190 , "progress_id" => $progress->getId()
191 //draft/active/outdated
192 , "program_status" => $programme->getStatus()
193 , "assignment_date" => $progress->getAssignmentDate()->format('d.m.Y')
194 , "deadline" => $progress->getDeadline()
195 , "completion_date" => $progress->getCompletionDate() ? $progress->getCompletionDate()->format('d.m.Y') : ''
196 );
197 },
198 true
199 );
200 return $plan;
201 }
202
203 protected function getManualStatusSelect($a_progress_id, $a_status)
204 {
205 $parent = $this->getParentObject();
206 $options = [
207 $parent::MANUAL_STATUS_NONE => '-',
208 ilStudyProgrammeProgress::STATUS_IN_PROGRESS => $this->lng->txt("prg_status_in_progress"),
209 ilStudyProgrammeProgress::STATUS_ACCREDITED => $this->lng->txt("prg_status_accredited"),
210 ilStudyProgrammeProgress::STATUS_NOT_RELEVANT => $this->lng->txt("prg_status_not_relevant")
211 //COMPLETED/FAILED are not to be set manually.
212 ];
213
215
216 $options = array_filter(
217 $options,
218 function ($o) use ($allowed, $parent) {
219 return in_array($o, $allowed) || $o === $parent::MANUAL_STATUS_NONE;
220 },
221 ARRAY_FILTER_USE_KEY
222 );
223
224 $select = new ilSelectInputGUI("", $parent::POST_VAR_STATUS . "[$a_progress_id]");
225 $select->setOptions($options);
226 $select->setValue($parent::MANUAL_STATUS_NONE);
227
228 return $select->render();
229 }
230
231 protected function getRequiredPointsInput($a_progress_id, $a_status, $a_points_required)
232 {
234 return $a_points_required;
235 }
236
237 $parent = $this->getParentObject();
238 $input = new ilNumberInputGUI("", $parent::POST_VAR_REQUIRED_POINTS . "[$a_progress_id]");
239 $input->setValue($a_points_required);
240 $input->setSize(5);
241 return $input->render();
242 }
243
244 protected function getDeadlineInput($a_progress_id, $deadline)
245 {
246 $parent = $this->getParentObject();
247 $gui = new ilDateTimeInputGUI("", $parent::POST_VAR_DEADLINE . "[$a_progress_id]");
248 $gui->setDate($deadline ? new ilDateTime($deadline->format('Y-m-d H:i:s'), IL_CAL_DATETIME) : null);
249 return $gui->render();
250 }
251}
if(! $in) $columns
Definition: Utf8Test.php:45
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
static _lookupTitle($a_obj_id)
Overwitten from base class.
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 _lookupLogin($a_user_id)
lookup login
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a selection list property in a property form.
Represents one assignment of the user to a program tree.
getRequiredPointsInput($a_progress_id, $a_status, $a_points_required)
__construct(ilObjStudyProgrammeIndividualPlanGUI $a_parent_obj, ilStudyProgrammeAssignment $a_ass, ilStudyProgrammeProgressRepository $sp_user_progress_db)
static getAllowedTargetStatusFor(int $status_from)
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
getParentObject()
Get parent object.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
determineLimit()
Determine the limit.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setMaxCount($a_max_count)
set max.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
global $DIC
Definition: goto.php:24
Covers the persistence of settings belonging to a study programme (SP).
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
global $ilDB
$cols
Definition: xhr_table.php:11