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