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();
80  $this->determineOffsetAndOrder();
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) {
110  case self::SEL_COLUMN_ASSIGNMENT_DATE:
111  $this->tpl->setCurrentBlock("assignment_date");
112  $this->tpl->setVariable("ASSIGNMENT_DATE", $a_set["assignment_date"]);
113  $this->tpl->parseCurrentBlock("assignment_date");
114  break;
115  case self::SEL_COLUMN_DEADLINE:
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;
120  case self::SEL_COLUMN_COMPLETION_DATE:
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 
138  $cols[self::SEL_COLUMN_ASSIGNMENT_DATE] = array(
139  "txt" => $this->lng->txt("assignment_date"));
140  $cols[self::SEL_COLUMN_DEADLINE] = array(
141  "txt" => $this->lng->txt("prg_deadline"));
142  $cols[self::SEL_COLUMN_COMPLETION_DATE] = array(
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 }
static _lookupLogin($a_user_id)
lookup login
setExternalSorting($a_val)
Set external sorting.
const IL_CAL_DATETIME
$type
setExternalSegmentation($a_val)
Set external segmentation.
static getAllowedTargetStatusFor(int $status_from)
static _lookupTitle($a_id)
lookup object title
determineLimit()
Determine the limit.
__construct(ilObjStudyProgrammeIndividualPlanGUI $a_parent_obj, ilStudyProgrammeAssignment $a_ass, ilStudyProgrammeProgressRepository $sp_user_progress_db)
getParentObject()
Get parent object.
setId($a_val)
Set id.
This class represents a date/time property in a property form.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
static _lookupTitle($a_obj_id)
Overwitten from base class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
global $DIC
Definition: goto.php:24
Represents one assignment of the user to a program tree.
getSelectedColumns()
Get selected columns.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
__construct(Container $dic, ilPlugin $plugin)
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.
global $ilDB
Covers the persistence of settings belonging to a study programme (SP).
setEnableHeader($a_enableheader)
Set Enable Header.
setMaxCount($a_max_count)
set max.
setEnableTitle($a_enabletitle)
Set Enable Title.
if(! $in) $columns
Definition: Utf8Test.php:45
$cols
Definition: xhr_table.php:11
getRequiredPointsInput($a_progress_id, $a_status, $a_points_required)