ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTestLearningObjectivesStatusGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Container/classes/class.ilContainerObjectiveGUI.php';
5
13{
17 protected $lng = null;
18
22 private $crsObjId = null;
23
27 private $usrId = null;
28
29 public function __construct(ilLanguage $lng)
30 {
31 $this->lng = $lng;
32 }
33
37 public function getCrsObjId()
38 {
39 return $this->crsObjId;
40 }
41
45 public function setCrsObjId($crsObjId)
46 {
47 $this->crsObjId = $crsObjId;
48 }
49
53 public function getUsrId()
54 {
55 return $this->usrId;
56 }
57
61 public function setUsrId($usrId)
62 {
63 $this->usrId = $usrId;
64 }
65
66 public function getHTML($objectiveId = null)
67 {
68 $this->lng->loadLanguageModule('crs');
69
70 $tpl = new ilTemplate('tpl.tst_lo_status.html', true, true, 'Modules/Test');
71
72 $tpl->setCurrentBlock('objectives_progress_header');
73 $tpl->setVariable('OBJECTIVES_PROGRESS_HEADER', $this->lng->txt($this->getHeaderLangVar($objectiveId)));
74 $tpl->parseCurrentBlock();
75
76 $this->renderStatus($tpl, $objectiveId, $this->getUsersObjectivesStatus(
77 $this->getCrsObjId(), $this->getUsrId()
78 ));
79
80 return $tpl->get();
81 }
82
83 private function getHeaderLangVar($objectiveId)
84 {
85 if($objectiveId)
86 {
87 return 'tst_objective_progress_header';
88 }
89
90 return 'tst_objectives_progress_header';
91 }
92
93 private function renderStatus($tpl, $objectiveId, $loStatusData)
94 {
95 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
96 $loc_settings = ilLOSettings::getInstanceByObjId($this->getCrsObjId());
97 $has_initial_test = (bool)$loc_settings->getInitialTest();
98
99 foreach($loStatusData as $objtv)
100 {
101 if($objectiveId && $objtv['id'] != $objectiveId)
102 {
103 continue;
104 }
105
106 $tpl->setCurrentBlock("objective_nolink_bl");
107 $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
108 $tpl->parseCurrentBlock();
109
110 $objtv_icon = ilUtil::getTypeIconPath("lobj", $objtv["id"]);
111
112 $tpl->setCurrentBlock("objective_bl");
113 $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
114 $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
115
116 if($objtv["type"])
117 {
118 $tpl->setVariable("LP_OBJTV_PROGRESS",
119 ilContainerObjectiveGUI::buildObjectiveProgressBar($has_initial_test, $objtv["id"], $objtv, true)
120 );
121 }
122
123 $tpl->parseCurrentBlock();
124 }
125
126 $tpl->setCurrentBlock("objectives_bl");
127 $tpl->setVariable("OBJTV_LIST_CRS_ID", $this->getCrsObjId());
128 $tpl->parseCurrentBlock();
129 }
130
132 {
133 $res = array();
134
135 // we need the collection for the correct order
136 include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
137 include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php";
139 $coll_objtv = $coll_objtv->getItems();
140 if($coll_objtv)
141 {
142 // #13373
143 $lo_results = $this->getUsersObjectivesResults($crsObjId, $usrId);
144
145 include_once "Modules/Course/classes/Objectives/class.ilLOTestAssignments.php";
147
148 $tmp = array();
149
150 include_once "Modules/Course/classes/class.ilCourseObjective.php";
151 foreach($coll_objtv as $objective_id)
152 {
153 // patch optes start
154
155 $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
156
157 $tmp[$objective_id] = array(
158 "id" => $objective_id,
159 "title" => $title["title"],
160 "desc" => $title["description"],
161 "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
162 "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
163 );
164
165 // patch optes end
166
167 if(array_key_exists($objective_id, $lo_results))
168 {
169 $lo_result = $lo_results[$objective_id];
170 $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
171 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
172 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
173 $tmp[$objective_id]["status"] = $lo_result["status"];
174 $tmp[$objective_id]["type"] = $lo_result["type"];
175 $tmp[$objective_id]["initial"] = $lo_result["initial"];
176 }
177 }
178
179 // order
180 foreach($coll_objtv as $objtv_id)
181 {
182 $res[] = $tmp[$objtv_id];
183 }
184 }
185
186 return $res;
187 }
188
190 {
191 $res = array();
192
193 include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
194 $lur = new ilLOUserResults($crsObjId, $usrId);
195
196 foreach($lur->getCourseResultsForUserPresentation() as $objective_id => $types)
197 {
198 // show either initial or qualified for objective
199 if(isset($types[ilLOUserResults::TYPE_INITIAL]))
200 {
201 $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
202 }
203
204 // qualified test has priority
205 if(isset($types[ilLOUserResults::TYPE_QUALIFIED]))
206 {
209 $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL];
210 }
211 else
212 {
215 }
216
217 $result["initial_status"] = $initial_status;
218
219 $res[$objective_id] = $result;
220 }
221
222 return $res;
223 }
224}
$result
global $tpl
Definition: ilias.php:8
static buildObjectiveProgressBar($a_has_initial_test, $a_objective_id, array $a_lo_result, $a_list_mode=false, $a_sub=false, $a_tt_suffix=null)
Render progressbar(s) for given objective and result data.
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
language handling
special template class to simplify handling of ITX/PEAR
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...