ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
5 require_once("Services/Table/classes/class.ilTable2GUI.php");
6 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
7 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
8 require_once("Services/Utilities/classes/class.ilUtil.php");
9 
18  protected $assignment;
19 
20  public function __construct($a_parent_obj, ilStudyProgrammeUserAssignment $a_ass) {
21  $this->setId("manage_indiv");
22  parent::__construct($a_parent_obj, 'manage');
23 
24  global $DIC;
25  $ilCtrl = $DIC['ilCtrl'];
26  $lng = $DIC['lng'];
27  $ilDB = $DIC['ilDB'];
28  $this->ctrl = $ilCtrl;
29  $this->lng = $lng;
30  $this->db = $ilDB;
31 
32  $this->assignment = $a_ass;
33 
34  $this->setEnableTitle(true);
35  $this->setTopCommands(false);
36  $this->setEnableHeader(true);
37  // TODO: switch this to internal sorting/segmentation
38  $this->setExternalSorting(false);
39  $this->setExternalSegmentation(false);
40  $this->setRowTemplate("tpl.individual_plan_table_row.html", "Modules/StudyProgramme");
41  $this->setDefaultOrderDirection("asc");
42 
43  $this->getParentObject()->appendIndividualPlanActions($this);
44 
45  $columns = array( "status"
46  , "title"
47  , "prg_points_current"
48  , "prg_points_required"
49  , "prg_manual_status"
50  , "prg_possible"
51  , "prg_changed_by"
52  , "prg_completion_by"
53  );
54  foreach ($columns as $lng_var) {
55  $this->addColumn($lng->txt($lng_var));
56  }
57 
58  $plan = $this->fetchData();
59 
60  $this->setMaxCount(count($plan));
61  $this->setData($plan);
62 
63  $this->determineLimit();
64  $this->determineOffsetAndOrder();
65 
66  $this->possible_image = "<img src='".ilUtil::getImagePath("icon_ok.svg")."' alt='ok'>";
67  $this->not_possible_image = "<img src='".ilUtil::getImagePath("icon_not_ok.svg")."' alt='not ok'>";
68  }
69 
70  protected function fillRow($a_set) {
71  $this->tpl->setVariable("STATUS", ilStudyProgrammeUserProgress::statusToRepr($a_set["status"]));
72 
73  $title = $a_set["title"];
74  if($a_set["program_status"] == ilStudyProgramme::STATUS_DRAFT) {
75  $title .= " (".$this->lng->txt("prg_status_draft").")";
76  } else if ($a_set["program_status"] == ilStudyProgramme::STATUS_OUTDATED) {
77  $title .= " (".$this->lng->txt("prg_status_outdated").")";
78  }
79 
80  $this->tpl->setVariable("TITLE", $title);
81  $this->tpl->setVariable("POINTS_CURRENT", $a_set["points_current"]);
82  $this->tpl->setVariable("POINTS_REQUIRED", $this->getRequiredPointsInput( $a_set["progress_id"]
83  , $a_set["status"]
84  , $a_set["points_required"]));
85  $this->tpl->setVariable("MANUAL_STATUS", $this->getManualStatusSelect($a_set["progress_id"], $a_set["status"]));
86  $this->tpl->setVariable("POSSIBLE", $a_set["possible"] ? $this->possible_image : $this->not_possible_image);
87  $this->tpl->setVariable("CHANGED_BY", $a_set["changed_by"]);
88  $this->tpl->setVariable("COMPLETION_BY", $a_set["completion_by"]);
89  }
90 
91  protected function fetchData() {
92  $prg = $this->assignment->getStudyProgramme();
93  $prg_id = $prg->getId();
94  $ass_id = $this->assignment->getId();
95  $usr_id = $this->assignment->getUserId();
96  $plan = array();
97 
98  $prg->applyToSubTreeNodes(function($node) use ($prg_id, $ass_id, $usr_id, &$plan) {
99  $progress = ilStudyProgrammeUserProgress::getInstance($ass_id, $node->getId(), $usr_id);
100  $completion_by_id = $progress->getCompletionBy();
101  if ($completion_by_id) {
102  $completion_by = ilObjUser::_lookupLogin($completion_by_id);
103  if (!$completion_by) {
104  $type = ilObject::_lookupType($completion_by_id);
105  if($type == "crsr") {
106  $completion_by = ilContainerReference::_lookupTitle($completion_by_id);
107  } else {
108  $completion_by = ilObject::_lookupTitle($completion_by_id);
109  }
110  }
111  } else {
112  $completion_by = implode(", ", $progress->getNamesOfCompletedOrAccreditedChildren());
113  }
114  $plan[] = array( "status" => $progress->getStatus()
115  , "title" => $node->getTitle()
116  , "points_current" => $progress->getCurrentAmountOfPoints()
117  , "points_required" => $progress->getAmountOfPoints()
118  , "possible" => $progress->isSuccessful() || $progress->canBeCompleted() || !$progress->isRelevant()
119  , "changed_by" => ilObjUser::_lookupLogin($progress->getLastChangeBy())
120  , "completion_by" => $completion_by
121  , "progress_id" => $progress->getId()
122  , "program_status" => $progress->getStudyProgramme()->getStatus()
123  );
124  });
125  return $plan;
126  }
127 
128  protected function getManualStatusSelect($a_progress_id, $a_status) {
130  return "";
131  }
132 
133  $parent = $this->getParentObject();
134  $status_title = $parent->getManualStatusPostVarTitle();
135  $manual_status_none = $parent->getManualStatusNone();
136  $manual_status_not_relevant = $parent->getManualStatusNotRelevant();
137  $manual_status_accredited = $parent->getManualStatusAccredited();
138 
139  require_once("Services/Form/classes/class.ilSelectInputGUI.php");
140  $select = new ilSelectInputGUI("", $status_title."[$a_progress_id]");
141  $select->setOptions(array
142  ( $manual_status_none => "-"
143  , $manual_status_accredited => $this->lng->txt("prg_status_accredited")
144  , $manual_status_not_relevant => $this->lng->txt("prg_status_not_relevant")
145  ));
147  $select->setValue($manual_status_not_relevant);
148  }
149  else if ($a_status == ilStudyProgrammeProgress::STATUS_ACCREDITED) {
150  $select->setValue($manual_status_accredited);
151  }
152 
153  return $select->render();
154  }
155 
156  protected function getRequiredPointsInput($a_progress_id, $a_status, $a_points_required) {
158  return $a_points_required;
159  }
160 
161  $required_points_title = $this->getParentObject()->getRequiredPointsPostVarTitle();
162 
163  require_once("Services/Form/classes/class.ilNumberInputGUI.php");
164  $input = new ilNumberInputGUI("", $required_points_title."[$a_progress_id]");
165  $input->setValue($a_points_required);
166  $input->setSize(5);
167  return $input->render();
168  }
169 }
170 
171 ?>
static _lookupLogin($a_user_id)
lookup login
static getInstance($a_assignment_id, $a_program_id, $a_user_id)
Get an instance.
__construct($a_parent_obj, ilStudyProgrammeUserAssignment $a_ass)
setExternalSorting($a_val)
Set external sorting.
static statusToRepr($a_status)
Get a user readable representation of a status.
This class represents a selection list property in a property form.
setExternalSegmentation($a_val)
Set external segmentation.
static _lookupTitle($a_id)
lookup object title
determineLimit()
Determine the limit.
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
Class ilTable2GUI.
static _lookupTitle($a_obj_id)
Overwitten from base class.
This class represents a number property in a property form.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
global $lng
Definition: privfeed.php:17
global $ilDB
setEnableHeader($a_enableheader)
Set Enable Header.
global $DIC
setMaxCount($a_max_count)
set max.
setEnableTitle($a_enabletitle)
Set Enable Title.
if(! $in) $columns
Definition: Utf8Test.php:45
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.
getRequiredPointsInput($a_progress_id, $a_status, $a_points_required)
Represents one assignment of a user to a study programme.