ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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_DEADLINE = "prg_deadline";
20
21 protected $assignment;
26
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 $status = $this->sp_user_progress_db->statusToRepr($a_set["status"]);
89 $this->tpl->setVariable("STATUS", $status);
90
91 $title = $a_set["title"];
92 if ($a_set["program_status"] == ilStudyProgramme::STATUS_DRAFT) {
93 $title .= " (" . $this->lng->txt("prg_status_draft") . ")";
94 } elseif ($a_set["program_status"] == ilStudyProgramme::STATUS_OUTDATED) {
95 $title .= " (" . $this->lng->txt("prg_status_outdated") . ")";
96 }
97
98 $this->tpl->setVariable("TITLE", $title);
99 $this->tpl->setVariable("POINTS_CURRENT", $a_set["points_current"]);
100 $this->tpl->setVariable("POINTS_REQUIRED", $this->getRequiredPointsInput($a_set["progress_id"], $a_set["status"], $a_set["points_required"]));
101 $this->tpl->setVariable("MANUAL_STATUS", $this->getManualStatusSelect($a_set["progress_id"], $a_set["status"]));
102 $this->tpl->setVariable("POSSIBLE", $a_set["possible"] ? $this->possible_image : $this->not_possible_image);
103 $this->tpl->setVariable("CHANGED_BY", $a_set["changed_by"]);
104 $this->tpl->setVariable("COMPLETION_BY", $a_set["completion_by"]);
105
106 foreach ($this->getSelectedColumns() as $column) {
107 switch ($column) {
109 $this->tpl->setCurrentBlock("deadline");
110 $this->tpl->setVariable("DEADLINE", $this->getDeadlineInput($a_set["progress_id"], $a_set["deadline"]));
111 $this->tpl->parseCurrentBlock("deadline");
112 break;
113 }
114 }
115 }
116
122 public function getSelectableColumns()
123 {
124 $cols = array();
125
127 "txt" => $this->lng->txt("prg_deadline"));
128
129 return $cols;
130 }
131
132 protected function fetchData()
133 {
134 $prg = $this->assignment->getStudyProgramme();
135 $prg_id = $prg->getId();
136 $ass_id = $this->assignment->getId();
137 $usr_id = $this->assignment->getUserId();
138 $plan = array();
139
140 $prg->applyToSubTreeNodes(function ($node) use ($prg_id, $ass_id, $usr_id, &$plan) {
141 $progress = $this->sp_user_progress_db->getInstance($ass_id, $node->getId(), $usr_id);
142 $completion_by_id = $progress->getCompletionBy();
143 if ($completion_by_id) {
144 $completion_by = ilObjUser::_lookupLogin($completion_by_id);
145 if (!$completion_by) {
146 $type = ilObject::_lookupType($completion_by_id);
147 if ($type == "crsr") {
148 $completion_by = ilContainerReference::_lookupTitle($completion_by_id);
149 } else {
150 $completion_by = ilObject::_lookupTitle($completion_by_id);
151 }
152 }
153 } else {
154 $completion_by = implode(", ", $progress->getNamesOfCompletedOrAccreditedChildren());
155 }
156 $plan[] = array( "status" => $progress->getStatus()
157 , "title" => $node->getTitle()
158 , "points_current" => $progress->getCurrentAmountOfPoints()
159 , "points_required" => $progress->getAmountOfPoints()
160 , "possible" => $progress->isSuccessful() || $progress->canBeCompleted() || !$progress->isRelevant()
161 , "changed_by" => ilObjUser::_lookupLogin($progress->getLastChangeBy())
162 , "completion_by" => $completion_by
163 , "progress_id" => $progress->getId()
164 , "program_status" => $progress->getStudyProgramme()->getStatus()
165 , "deadline" =>$progress->getDeadline()
166 );
167 });
168 return $plan;
169 }
170
171 protected function getManualStatusSelect($a_progress_id, $a_status)
172 {
174 return "";
175 }
176
177 $parent = $this->getParentObject();
178 $status_title = $parent->getManualStatusPostVarTitle();
179 $manual_status_none = $parent->getManualStatusNone();
180 $manual_status_not_relevant = $parent->getManualStatusNotRelevant();
181 $manual_status_accredited = $parent->getManualStatusAccredited();
182
183 require_once("Services/Form/classes/class.ilSelectInputGUI.php");
184 $select = new ilSelectInputGUI("", $status_title . "[$a_progress_id]");
185 $select->setOptions(array( $manual_status_none => "-"
186 , $manual_status_accredited => $this->lng->txt("prg_status_accredited")
187 , $manual_status_not_relevant => $this->lng->txt("prg_status_not_relevant")
188 ));
190 $select->setValue($manual_status_not_relevant);
191 } elseif ($a_status == ilStudyProgrammeProgress::STATUS_ACCREDITED) {
192 $select->setValue($manual_status_accredited);
193 }
194
195 return $select->render();
196 }
197
198 protected function getRequiredPointsInput($a_progress_id, $a_status, $a_points_required)
199 {
201 return $a_points_required;
202 }
203
204 $required_points_title = $this->getParentObject()->getRequiredPointsPostVarTitle();
205
206 require_once("Services/Form/classes/class.ilNumberInputGUI.php");
207 $input = new ilNumberInputGUI("", $required_points_title . "[$a_progress_id]");
208 $input->setValue($a_points_required);
209 $input->setSize(5);
210 return $input->render();
211 }
212
213 protected function getDeadlineInput($a_progress_id, $deadline)
214 {
215 require_once("Services/Form/classes/class.ilDateTimeInputGUI.php");
216
217 $deadline_title = $this->getParentObject()->getDeadlinePostVarTitle();
218 $gui = new ilDateTimeInputGUI("", $deadline_title . "[$a_progress_id]");
219 $gui->setDate($deadline);
220
221 return $gui->render();
222 }
223}
$column
Definition: 39dropdown.php:62
if(! $in) $columns
Definition: Utf8Test.php:45
PHPExcel root directory.
Definition: PHPExcel.php:30
An exception for terminatinating execution or to throw for unit testing.
static _lookupTitle($a_obj_id)
Overwitten from base class.
This class represents a date/time property 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)
global $ilCtrl
Definition: ilias.php:18
$type
global $DIC
Definition: saml.php:7
global $ilDB
$cols
Definition: xhr_table.php:11