ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
5require_once("Services/Table/classes/class.ilTable2GUI.php");
6require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
7require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
8require_once("Services/Utilities/classes/class.ilUtil.php");
9
18{
19 const SEL_COLUMN_COMPLETION_DATE = "completion_date";
20 const SEL_COLUMN_DEADLINE = "prg_deadline";
21 const SEL_COLUMN_ASSIGNMENT_DATE = "assignment_date";
22
23
24 protected $assignment;
29
31 {
32 $this->setId("manage_indiv");
33
34 $this->sp_user_progress_db = $sp_user_progress_db;
35
36 parent::__construct($a_parent_obj, 'manage');
37
38 global $DIC;
39 $ilCtrl = $DIC['ilCtrl'];
40 $lng = $DIC['lng'];
41 $ilDB = $DIC['ilDB'];
42 $this->ctrl = $ilCtrl;
43 $this->lng = $lng;
44 $this->db = $ilDB;
45
46 $this->assignment = $a_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 = array( "status"
60 , "title"
61 , "prg_points_current"
62 , "prg_points_required"
63 , "prg_manual_status"
64 , "prg_possible"
65 , "prg_changed_by"
66 , "prg_completion_by"
67 );
68
69 foreach ($this->getSelectedColumns() as $column) {
70 $columns[] = $column;
71 }
72
73 foreach ($columns as $lng_var) {
74 $this->addColumn($lng->txt($lng_var));
75 }
76
77 $plan = $this->fetchData();
78
79 $this->setMaxCount(count($plan));
80 $this->setData($plan);
81
82 $this->determineLimit();
84
85 $this->possible_image = "<img src='" . ilUtil::getImagePath("icon_ok.svg") . "' alt='ok'>";
86 $this->not_possible_image = "<img src='" . ilUtil::getImagePath("icon_not_ok.svg") . "' alt='not ok'>";
87 }
88
89 protected function fillRow($a_set)
90 {
91 $status = $this->sp_user_progress_db->statusToRepr($a_set["status"]);
92 $this->tpl->setVariable("STATUS", $status);
93
94 $title = $a_set["title"];
95 if ($a_set["program_status"] == ilStudyProgrammeSettings::STATUS_DRAFT) {
96 $title .= " (" . $this->lng->txt("prg_status_draft") . ")";
97 } elseif ($a_set["program_status"] == ilStudyProgrammeSettings::STATUS_OUTDATED) {
98 $title .= " (" . $this->lng->txt("prg_status_outdated") . ")";
99 }
100
101 $this->tpl->setVariable("TITLE", $title);
102 $this->tpl->setVariable("POINTS_CURRENT", $a_set["points_current"]);
103 $this->tpl->setVariable("POINTS_REQUIRED", $this->getRequiredPointsInput($a_set["progress_id"], $a_set["status"], $a_set["points_required"]));
104 $this->tpl->setVariable("MANUAL_STATUS", $this->getManualStatusSelect($a_set["progress_id"], $a_set["status"]));
105 $this->tpl->setVariable("POSSIBLE", $a_set["possible"] ? $this->possible_image : $this->not_possible_image);
106 $this->tpl->setVariable("CHANGED_BY", $a_set["changed_by"]);
107 $this->tpl->setVariable("COMPLETION_BY", $a_set["completion_by"]);
108
109 foreach ($this->getSelectedColumns() as $column) {
110 switch ($column) {
112 $this->tpl->setCurrentBlock("assignment_date");
113 $this->tpl->setVariable("ASSIGNMENT_DATE", $a_set["assignment_date"]);
114 $this->tpl->parseCurrentBlock("assignment_date");
115 break;
117 $this->tpl->setCurrentBlock("deadline");
118 $this->tpl->setVariable("DEADLINE", $this->getDeadlineInput($a_set["progress_id"], $a_set["deadline"]));
119 $this->tpl->parseCurrentBlock("deadline");
120 break;
122 $this->tpl->setCurrentBlock("completion_date");
123 $this->tpl->setVariable("COMPLETION_DATE", $a_set["completion_date"]);
124 $this->tpl->parseCurrentBlock("completion_date");
125 break;
126 }
127 }
128 }
129
135 public function getSelectableColumns()
136 {
137 $cols = array();
138
140 "txt" => $this->lng->txt("assignment_date"));
142 "txt" => $this->lng->txt("prg_deadline"));
144 "txt" => $this->lng->txt("completion_date"));
145 return $cols;
146 }
147
148 protected function fetchData()
149 {
150 $prg = $this->assignment->getStudyProgramme();
151 $prg_id = $prg->getId();
152 $ass_id = $this->assignment->getId();
153 $usr_id = $this->assignment->getUserId();
154 $plan = array();
155
156 $prg->applyToSubTreeNodes(function ($node) use ($prg_id, $ass_id, $usr_id, &$plan) {
157 $progress = $this->sp_user_progress_db->getInstance($ass_id, $node->getId(), $usr_id);
158 $completion_by_id = $progress->getCompletionBy();
159 if ($completion_by_id) {
160 $completion_by = ilObjUser::_lookupLogin($completion_by_id);
161 if (!$completion_by) {
162 $type = ilObject::_lookupType($completion_by_id);
163 if ($type == "crsr") {
164 $completion_by = ilContainerReference::_lookupTitle($completion_by_id);
165 } else {
166 $completion_by = ilObject::_lookupTitle($completion_by_id);
167 }
168 }
169 } else {
170 $completion_by = implode(", ", $progress->getNamesOfCompletedOrAccreditedChildren());
171 }
172 $plan[] = array( "status" => $progress->getStatus()
173 , "title" => $node->getTitle()
174 , "points_current" => $progress->getCurrentAmountOfPoints()
175 , "points_required" => $progress->getAmountOfPoints()
176 , "possible" => $progress->isSuccessful() || $progress->canBeCompleted() || !$progress->isRelevant()
177 , "changed_by" => ilObjUser::_lookupLogin($progress->getLastChangeBy())
178 , "completion_by" => $completion_by
179 , "progress_id" => $progress->getId()
180 , "program_status" => $progress->getStudyProgramme()->getStatus()
181 , "assignment_date" => $progress->getAssignmentDate()->format('d.m.Y')
182 , "deadline" => $progress->getDeadline()
183 , "completion_date" => $progress->getCompletionDate() ? $progress->getCompletionDate()->format('d.m.Y') : ''
184 );
185 }, true);
186 return $plan;
187 }
188
189 protected function getManualStatusSelect($a_progress_id, $a_status)
190 {
191 $parent = $this->getParentObject();
192 $status_title = $parent->getManualStatusPostVarTitle();
194 $inv_select = new ilNonEditableValueGUI("", $status_title . "[$a_progress_id]");
195 $inv_select->setValue($this->lng->txt('no_manual_status'));
196 return $inv_select->render();
197 }
198
199
200
201 $manual_status_none = $parent->getManualStatusNone();
202 $manual_status_not_relevant = $parent->getManualStatusNotRelevant();
203 $manual_status_accredited = $parent->getManualStatusAccredited();
204
205 require_once("Services/Form/classes/class.ilSelectInputGUI.php");
206 $select = new ilSelectInputGUI("", $status_title . "[$a_progress_id]");
207 $select->setOptions(array( $manual_status_none => "-"
208 , $manual_status_accredited => $this->lng->txt("prg_status_accredited")
209 , $manual_status_not_relevant => $this->lng->txt("prg_status_not_relevant")
210 ));
212 $select->setValue($manual_status_not_relevant);
213 } elseif ($a_status == ilStudyProgrammeProgress::STATUS_ACCREDITED) {
214 $select->setValue($manual_status_accredited);
215 }
216
217 return $select->render();
218 }
219
220 protected function getRequiredPointsInput($a_progress_id, $a_status, $a_points_required)
221 {
223 return $a_points_required;
224 }
225
226 $required_points_title = $this->getParentObject()->getRequiredPointsPostVarTitle();
227
228 require_once("Services/Form/classes/class.ilNumberInputGUI.php");
229 $input = new ilNumberInputGUI("", $required_points_title . "[$a_progress_id]");
230 $input->setValue($a_points_required);
231 $input->setSize(5);
232 return $input->render();
233 }
234
235 protected function getDeadlineInput($a_progress_id, $deadline)
236 {
237 require_once("Services/Form/classes/class.ilDateTimeInputGUI.php");
238
239 $deadline_title = $this->getParentObject()->getDeadlinePostVarTitle();
240 $gui = new ilDateTimeInputGUI("", $deadline_title . "[$a_progress_id]");
241 $gui->setDate($deadline ? new ilDateTime($deadline->format('Y-m-d H:i:s'), IL_CAL_DATETIME) : null);
242
243 return $gui->render();
244 }
245}
if(! $in) $columns
Definition: Utf8Test.php:45
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
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 non editable value in a property form.
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.
getRequiredPointsInput($a_progress_id, $a_status, $a_points_required)
__construct(ilObjStudyProgrammeIndividualPlanGUI $a_parent_obj, ilStudyProgrammeUserAssignment $a_ass, \ilStudyProgrammeUserProgressDB $sp_user_progress_db)
Represents one assignment of a user to a study programme.
Storage implementation for ilStudyProgrammeUserProgress.
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 $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
global $ilDB
$DIC
Definition: xapitoken.php:46
$cols
Definition: xhr_table.php:11