ILIAS  release_8 Revision v8.24
ilTestLearningObjectivesStatusGUI Class Reference
+ Collaboration diagram for ilTestLearningObjectivesStatusGUI:

Public Member Functions

 __construct (ilLanguage $lng)
 
 getCrsObjId ()
 
 setCrsObjId ($crsObjId)
 
 getUsrId ()
 
 setUsrId ($usrId)
 
 getHTML ($objectiveId=null)
 

Protected Attributes

 $lng = null
 

Private Member Functions

 getHeaderLangVar ($objectiveId)
 
 renderStatus ($tpl, $objectiveId, $loStatusData)
 
 getUsersObjectivesStatus ($crsObjId, $usrId)
 
 getUsersObjectivesResults ($crsObjId, $usrId)
 

Private Attributes

ILIAS Test InternalRequestService $testrequest
 
 $crsObjId = null
 
 $usrId = null
 

Detailed Description

Definition at line 25 of file class.ilTestLearningObjectivesStatusGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestLearningObjectivesStatusGUI::__construct ( ilLanguage  $lng)

Definition at line 43 of file class.ilTestLearningObjectivesStatusGUI.php.

44 {
45 global $DIC;
46 $this->testrequest = $DIC->test()->internal()->request();
47 $this->lng = $lng;
48 }
global $DIC
Definition: feed.php:28

References $DIC, $lng, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ getCrsObjId()

ilTestLearningObjectivesStatusGUI::getCrsObjId ( )
Returns
integer

Definition at line 53 of file class.ilTestLearningObjectivesStatusGUI.php.

References $crsObjId.

Referenced by getHTML(), and renderStatus().

+ Here is the caller graph for this function:

◆ getHeaderLangVar()

ilTestLearningObjectivesStatusGUI::getHeaderLangVar (   $objectiveId)
private

Definition at line 100 of file class.ilTestLearningObjectivesStatusGUI.php.

100 : string
101 {
102 if ($objectiveId) {
103 return 'tst_objective_progress_header';
104 }
105
106 return 'tst_objectives_progress_header';
107 }

◆ getHTML()

ilTestLearningObjectivesStatusGUI::getHTML (   $objectiveId = null)

Definition at line 82 of file class.ilTestLearningObjectivesStatusGUI.php.

82 : string
83 {
84 $this->lng->loadLanguageModule('crs');
85
86 $tpl = new ilTemplate('tpl.tst_lo_status.html', true, true, 'Modules/Test');
87
88 $tpl->setCurrentBlock('objectives_progress_header');
89 $tpl->setVariable('OBJECTIVES_PROGRESS_HEADER', $this->lng->txt($this->getHeaderLangVar($objectiveId)));
90 $tpl->parseCurrentBlock();
91
92 $this->renderStatus($tpl, $objectiveId, $this->getUsersObjectivesStatus(
93 $this->getCrsObjId(),
94 $this->getUsrId()
95 ));
96
97 return $tpl->get();
98 }
special template class to simplify handling of ITX/PEAR
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References $tpl, getCrsObjId(), getUsersObjectivesStatus(), getUsrId(), ILIAS\Repository\lng(), and renderStatus().

+ Here is the call graph for this function:

◆ getUsersObjectivesResults()

ilTestLearningObjectivesStatusGUI::getUsersObjectivesResults (   $crsObjId,
  $usrId 
)
private

Definition at line 196 of file class.ilTestLearningObjectivesStatusGUI.php.

196 : array
197 {
198 $res = array();
199 $initial_status = null;
200 $lur = new ilLOUserResults($crsObjId, $usrId);
201
202 foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) {
203 // show either initial or qualified for objective
204 if (isset($types[ilLOUserResults::TYPE_INITIAL])) {
205 $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
206 }
207
208 // qualified test has priority
209 if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) {
210 $result = $types[ilLOUserResults::TYPE_QUALIFIED];
211 $result["type"] = ilLOUserResults::TYPE_QUALIFIED;
212 $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL] ?? null;
213 } else {
214 $result = $types[ilLOUserResults::TYPE_INITIAL];
215 $result["type"] = ilLOUserResults::TYPE_INITIAL;
216 }
217
218 $result["initial_status"] = $initial_status;
219
220 $res[$objective_id] = $result;
221 }
222
223 return $res;
224 }
$res
Definition: ltiservices.php:69

References $crsObjId, $res, $usrId, ilLOUserResults\TYPE_INITIAL, and ilLOUserResults\TYPE_QUALIFIED.

Referenced by getUsersObjectivesStatus().

+ Here is the caller graph for this function:

◆ getUsersObjectivesStatus()

ilTestLearningObjectivesStatusGUI::getUsersObjectivesStatus (   $crsObjId,
  $usrId 
)
private

Definition at line 151 of file class.ilTestLearningObjectivesStatusGUI.php.

151 : array
152 {
153 $res = array();
154
156 $coll_objtv = $coll_objtv->getItems();
157 if ($coll_objtv) {
158 // #13373
159 $lo_results = $this->getUsersObjectivesResults($crsObjId, $usrId);
161
162 $tmp = array();
163 foreach ($coll_objtv as $objective_id) {
164 $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
165
166 $tmp[$objective_id] = array(
167 "id" => $objective_id,
168 "title" => $title["title"],
169 "desc" => $title["description"],
170 "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
171 "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
172 );
173
174 // patch optes end
175
176 if (array_key_exists($objective_id, $lo_results)) {
177 $lo_result = $lo_results[$objective_id];
178 $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
179 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
180 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
181 $tmp[$objective_id]["status"] = $lo_result["status"];
182 $tmp[$objective_id]["type"] = $lo_result["type"];
183 $tmp[$objective_id]["initial"] = $lo_result["initial"] ?? null;
184 }
185 }
186
187 // order
188 foreach ($coll_objtv as $objtv_id) {
189 $res[] = $tmp[$objtv_id];
190 }
191 }
192
193 return $res;
194 }
static lookupObjectiveTitle(int $a_objective_id, bool $a_add_description=false)
static getInstance(int $a_container_id)

References $crsObjId, $res, $usrId, ilLOTestAssignments\getInstance(), getUsersObjectivesResults(), ilCourseObjective\lookupObjectiveTitle(), ilLPObjSettings\LP_MODE_OBJECTIVES, ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsrId()

ilTestLearningObjectivesStatusGUI::getUsrId ( )
Returns
integer

Definition at line 69 of file class.ilTestLearningObjectivesStatusGUI.php.

69 : ?int
70 {
71 return $this->usrId;
72 }

References $usrId.

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ renderStatus()

ilTestLearningObjectivesStatusGUI::renderStatus (   $tpl,
  $objectiveId,
  $loStatusData 
)
private

Definition at line 109 of file class.ilTestLearningObjectivesStatusGUI.php.

110 {
111 $loc_settings = ilLOSettings::getInstanceByObjId($this->getCrsObjId());
112 $has_initial_test = (bool) $loc_settings->getInitialTest();
113
114 foreach ($loStatusData as $objtv) {
115 if ($objectiveId && $objtv['id'] != $objectiveId) {
116 continue;
117 }
118
119 $tpl->setCurrentBlock("objective_nolink_bl");
120 $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
121 $tpl->parseCurrentBlock();
122
123 $objtv_icon = ilObject::_getIcon($objtv["id"], "small", "lobj");
124
125 $tpl->setCurrentBlock("objective_bl");
126 $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
127 $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
128
129 if ($objtv["type"]) {
130 $tpl->setVariable(
131 "LP_OBJTV_PROGRESS",
132 ilContainerObjectiveGUI::buildObjectiveProgressBar($has_initial_test, $objtv["id"], $objtv, true)
133 );
134
135 // since ilContainerObjectiveGUI::buildObjectiveProgressBar() "sets an empty ref_id" for ilObjTestGUI,
136 // after creating links for different test refs, the "saved ref_id param" for ilObjTestGUI gets overwritten.
137 // (!) we need to set an explicit ref_id param for ilObjTestGUI again to keep the things running (!)
138
139 global $DIC; /* @var \ILIAS\DI\Container $DIC */
140 $DIC->ctrl()->setParameterByClass('ilObjTestGUI', 'ref_id', $this->testrequest->getRefId());
141 }
142
143 $tpl->parseCurrentBlock();
144 }
145
146 $tpl->setCurrentBlock("objectives_bl");
147 $tpl->setVariable("OBJTV_LIST_CRS_ID", $this->getCrsObjId());
148 $tpl->parseCurrentBlock();
149 }
static buildObjectiveProgressBar(bool $a_has_initial_test, int $a_objective_id, array $a_lo_result, bool $a_list_mode=false, bool $a_sub=false, string $a_tt_suffix=null)
Render progressbar(s) for given objective and result data.
static getInstanceByObjId(int $a_obj_id)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.

References $DIC, $tpl, ilObject\_getIcon(), ilContainerObjectiveGUI\buildObjectiveProgressBar(), getCrsObjId(), ilLOSettings\getInstanceByObjId(), and ILIAS\Repository\lng().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCrsObjId()

ilTestLearningObjectivesStatusGUI::setCrsObjId (   $crsObjId)
Parameters
integer$crsObjId

Definition at line 61 of file class.ilTestLearningObjectivesStatusGUI.php.

62 {
63 $this->crsObjId = $crsObjId;
64 }

References $crsObjId.

◆ setUsrId()

ilTestLearningObjectivesStatusGUI::setUsrId (   $usrId)
Parameters
integer$usrId

Definition at line 77 of file class.ilTestLearningObjectivesStatusGUI.php.

78 {
79 $this->usrId = $usrId;
80 }

References $usrId.

Field Documentation

◆ $crsObjId

ilTestLearningObjectivesStatusGUI::$crsObjId = null
private

◆ $lng

ilTestLearningObjectivesStatusGUI::$lng = null
protected

Definition at line 31 of file class.ilTestLearningObjectivesStatusGUI.php.

Referenced by __construct().

◆ $testrequest

ILIAS Test InternalRequestService ilTestLearningObjectivesStatusGUI::$testrequest
private

Definition at line 27 of file class.ilTestLearningObjectivesStatusGUI.php.

◆ $usrId

ilTestLearningObjectivesStatusGUI::$usrId = null
private

The documentation for this class was generated from the following file: