ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilLOUserResults Class Reference
+ Collaboration diagram for ilLOUserResults:

Public Member Functions

 __construct ($a_course_obj_id, $a_user_id)
 Constructor. More...
 
 delete ()
 Delete for user and course @global type $ilDB. More...
 
 saveObjectiveResult ($a_objective_id, $a_type, $a_status, $a_result_percentage, $a_limit_percentage, $a_tries, $a_is_final)
 Save objective result. More...
 
 getCompletedObjectiveIdsByType ($a_type)
 All completed objectives by type. More...
 
 getSuggestedObjectiveIds ()
 Get all objectives where the user failed the initial test. More...
 
 getCompletedObjectiveIds ()
 Get all objectives where the user completed the qualified test. More...
 
 getFailedObjectiveIds ($a_is_final=true)
 Get all objectives where the user failed the qualified test. More...
 
 getCourseResultsForUserPresentation ()
 Get all results for course and user. More...
 

Static Public Member Functions

static lookupResult ($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
 Lookup user result. More...
 
static resetFinalByObjective ($a_objective_id)
 
static deleteResultsForUser ($a_user_id)
 Delete all result entries for user. More...
 
static deleteResultsForCourse ($a_course_id)
 Delete all result entries for course. More...
 
static deleteResultsFromLP ($a_course_id, array $a_user_ids, $a_remove_initial, $a_remove_qualified)
 Delete all (qualified) result entries for course members. More...
 
static getObjectiveStatusForLP ($a_user_id, array $a_objective_ids)
 
static getSummarizedObjectiveStatusForLP (array $a_objective_ids, $a_user_id=null)
 
static hasResults ($a_container_id, $a_user_id)
 

Data Fields

const TYPE_INITIAL = 1
 
const TYPE_QUALIFIED = 2
 
const STATUS_COMPLETED = 1
 
const STATUS_FAILED = 2
 

Protected Member Functions

 findObjectiveIds ($a_type=null, $a_status=null, $a_is_final=null)
 Find objective ids by type and/or status. More...
 

Static Protected Member Functions

static isValidType ($a_type)
 Is given type valid? More...
 
static isValidStatus ($a_status)
 Is given status valid? More...
 

Protected Attributes

 $course_obj_id
 
 $user_id
 

Detailed Description

Definition at line 11 of file class.ilLOUserResults.php.

Constructor & Destructor Documentation

◆ __construct()

ilLOUserResults::__construct (   $a_course_obj_id,
  $a_user_id 
)

Constructor.

Parameters
int$a_course_obj_id
int$a_user_id
Returns
ilLOUserResults

Definition at line 29 of file class.ilLOUserResults.php.

30 {
31 $this->course_obj_id = (int)$a_course_obj_id;
32 $this->user_id = (int)$a_user_id;
33 }

Member Function Documentation

◆ delete()

ilLOUserResults::delete ( )

Delete for user and course @global type $ilDB.

Definition at line 142 of file class.ilLOUserResults.php.

143 {
144 global $ilDB;
145
146 $query = 'DELETE FROM loc_user_results '.
147 'WHERE course_id = '.$ilDB->quote($this->course_obj_id).' '.
148 'AND user_id = '.$ilDB->quote($this->user_id);
149 $ilDB->manipulate($query);
150 }
global $ilDB

References $ilDB, and $query.

◆ deleteResultsForCourse()

static ilLOUserResults::deleteResultsForCourse (   $a_course_id)
static

Delete all result entries for course.

Parameters
int$a_course_id
Returns
bool

Definition at line 124 of file class.ilLOUserResults.php.

125 {
126 global $ilDB;
127
128 if(!(int)$a_course_id)
129 {
130 return false;
131 }
132
133 $ilDB->manipulate("DELETE FROM loc_user_results".
134 " WHERE course_id = ".$ilDB->quote($a_course_id, "integer"));
135 return true;
136 }

References $ilDB.

◆ deleteResultsForUser()

static ilLOUserResults::deleteResultsForUser (   $a_user_id)
static

Delete all result entries for user.

Parameters
int$a_user_id
Returns
bool

Definition at line 103 of file class.ilLOUserResults.php.

104 {
105 global $ilDB;
106
107 if(!(int)$a_user_id)
108 {
109 return false;
110 }
111
112 $ilDB->manipulate("DELETE FROM loc_user_results".
113 " WHERE user_id = ".$ilDB->quote($a_user_id, "integer"));
114 return true;
115 }

References $ilDB.

Referenced by ilObjCourse\_deleteUser().

+ Here is the caller graph for this function:

◆ deleteResultsFromLP()

static ilLOUserResults::deleteResultsFromLP (   $a_course_id,
array  $a_user_ids,
  $a_remove_initial,
  $a_remove_qualified 
)
static

Delete all (qualified) result entries for course members.

Parameters
int$a_course_id
array$a_user_ids
bool$a_remove_initial
bool$a_remove_qualified
Returns
bool

Definition at line 161 of file class.ilLOUserResults.php.

162 {
163 global $ilDB;
164
165 if(!(int)$a_course_id || !sizeof($a_user_ids))
166 {
167 return false;
168 }
169
170 $sql = "DELETE FROM loc_user_results".
171 " WHERE course_id = ".$ilDB->quote($a_course_id, "integer").
172 " AND ".$ilDB->in("user_id", $a_user_ids, "", "integer");
173
174 if(!(bool)$a_remove_initial || !(bool)$a_remove_qualified)
175 {
176 if((bool)$a_remove_initial)
177 {
178 $sql .= " AND type = ".$ilDB->quote(self::TYPE_INITIAL, "integer");
179 }
180 else
181 {
182 $sql .= " AND type = ".$ilDB->quote(self::TYPE_QUALIFIED, "integer");
183 }
184 }
185
186 $ilDB->manipulate($sql);
187 return true;
188 }

References $ilDB.

Referenced by ilTestLP\resetCustomLPDataForUserIds().

+ Here is the caller graph for this function:

◆ findObjectiveIds()

ilLOUserResults::findObjectiveIds (   $a_type = null,
  $a_status = null,
  $a_is_final = null 
)
protected

Find objective ids by type and/or status.

Parameters
int$a_type
int$a_status
bool$a_is_final
Returns
array

Definition at line 239 of file class.ilLOUserResults.php.

240 {
241 global $ilDB;
242
243 $res = array();
244
245 $sql = "SELECT objective_id".
246 " FROM loc_user_results".
247 " WHERE course_id = ".$ilDB->quote($this->course_obj_id, "integer").
248 " AND user_id = ".$ilDB->quote($this->user_id, "integer");
249
250 if($this->isValidType($a_type))
251 {
252 $sql .= " AND type = ".$ilDB->quote($a_type, "integer");
253 }
254 if($this->isValidStatus($a_status))
255 {
256 $sql .= " AND status = ".$ilDB->quote($a_status, "integer");
257 }
258 if($a_is_final !== null)
259 {
260 $sql .= " AND is_final = ".$ilDB->quote($a_is_final, "integer");
261 }
262
263 $set = $ilDB->query($sql);
264 while($row = $ilDB->fetchAssoc($set))
265 {
266 $res[] = $row["objective_id"];
267 }
268
269 return $res;
270 }
static isValidType($a_type)
Is given type valid?
static isValidStatus($a_status)
Is given status valid?

References $ilDB, $res, $row, isValidStatus(), and isValidType().

Referenced by getCompletedObjectiveIds(), getCompletedObjectiveIdsByType(), getFailedObjectiveIds(), and getSuggestedObjectiveIds().

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

◆ getCompletedObjectiveIds()

ilLOUserResults::getCompletedObjectiveIds ( )

Get all objectives where the user completed the qualified test.

Returns
array objective-ids

Definition at line 297 of file class.ilLOUserResults.php.

298 {
299 return $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED);
300 }
findObjectiveIds($a_type=null, $a_status=null, $a_is_final=null)
Find objective ids by type and/or status.

References findObjectiveIds().

+ Here is the call graph for this function:

◆ getCompletedObjectiveIdsByType()

ilLOUserResults::getCompletedObjectiveIdsByType (   $a_type)

All completed objectives by type.

Parameters
type$a_type
Returns
type

Definition at line 277 of file class.ilLOUserResults.php.

278 {
279 return $this->findObjectiveIds($a_type, self::STATUS_COMPLETED);
280 }

References findObjectiveIds().

+ Here is the call graph for this function:

◆ getCourseResultsForUserPresentation()

ilLOUserResults::getCourseResultsForUserPresentation ( )

Get all results for course and user.

Returns
array

Definition at line 318 of file class.ilLOUserResults.php.

319 {
320 global $ilDB;
321
322 $res = array();
323
324 $set = $ilDB->query("SELECT *".
325 " FROM loc_user_results".
326 " WHERE course_id = ".$ilDB->quote($this->course_obj_id, "integer").
327 " AND user_id = ".$ilDB->quote($this->user_id, "integer"));
328 while($row = $ilDB->fetchAssoc($set))
329 {
330 $objective_id = $row["objective_id"];
331 $type = $row["type"];
332 unset($row["objective_id"]);
333 unset($row["type"]);
334 $res[$objective_id][$type] = $row;
335 }
336
337 return $res;
338 }

References $ilDB, $res, and $row.

◆ getFailedObjectiveIds()

ilLOUserResults::getFailedObjectiveIds (   $a_is_final = true)

Get all objectives where the user failed the qualified test.

Parameters
bool$a_is_final
Returns
array objective-ids

Definition at line 308 of file class.ilLOUserResults.php.

309 {
310 return $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_FAILED, $a_is_final);
311 }

References findObjectiveIds().

+ Here is the call graph for this function:

◆ getObjectiveStatusForLP()

static ilLOUserResults::getObjectiveStatusForLP (   $a_user_id,
array  $a_objective_ids 
)
static

Definition at line 340 of file class.ilLOUserResults.php.

341 {
342 global $ilDB;
343
344 // this method returns LP status codes!
345 include_once "Services/Tracking/classes/class.ilLPStatus.php";
346
347 $res = array();
348
349 $sql = "SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final".
350 " FROM loc_user_results lor".
351 " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)".
352 " WHERE ".$ilDB->in("lor.objective_id", $a_objective_ids, "", "integer").
353 " AND lor.type = ".$ilDB->quote(self::TYPE_QUALIFIED, "integer").
354 " AND lor.user_id = ".$ilDB->quote($a_user_id, "integer").
355 " AND cobj.active = ".$ilDB->quote(1, "integer");
356 $set = $ilDB->query($sql);
357 while($row = $ilDB->fetchAssoc($set))
358 {
359 switch($row["status"])
360 {
363 break;
364
367 break;
368
369 default:
370 /*
371 $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
372 break;
373 */
374 continue;
375 }
376
377 $res[$row["objective_id"]] = $status;
378 }
379
380 return $res;
381 }
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_FAILED_NUM

References $ilDB, $res, $row, ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED_NUM, STATUS_COMPLETED, and STATUS_FAILED.

Referenced by ilTrQuery\getObjectivesStatusForUser().

+ Here is the caller graph for this function:

◆ getSuggestedObjectiveIds()

ilLOUserResults::getSuggestedObjectiveIds ( )

Get all objectives where the user failed the initial test.

Returns
array objective-ids

Definition at line 287 of file class.ilLOUserResults.php.

288 {
289 return $this->findObjectiveIds(self::TYPE_INITIAL, self::STATUS_FAILED);
290 }

References findObjectiveIds().

+ Here is the call graph for this function:

◆ getSummarizedObjectiveStatusForLP()

static ilLOUserResults::getSummarizedObjectiveStatusForLP ( array  $a_objective_ids,
  $a_user_id = null 
)
static

Definition at line 383 of file class.ilLOUserResults.php.

384 {
385 global $ilDB;
386
387 // this method returns LP status codes!
388 include_once "Services/Tracking/classes/class.ilLPStatus.php";
389
390 $res = $tmp_completed = array();
391
392 $sql = "SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final".
393 " FROM loc_user_results lor".
394 " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)".
395 " WHERE ".$ilDB->in("lor.objective_id", $a_objective_ids, "", "integer").
396 " AND lor.type = ".$ilDB->quote(self::TYPE_QUALIFIED, "integer").
397 " AND cobj.active = ".$ilDB->quote(1, "integer");
398 if($a_user_id)
399 {
400 $sql .= " AND lor.user_id = ".$ilDB->quote($a_user_id, "integer");
401 }
402 $set = $ilDB->query($sql);
403 while($row = $ilDB->fetchAssoc($set))
404 {
405 $user_id = (int)$row["user_id"];
406 $status = (int)$row["status"];
407
408 // user did do something
410
411 switch($status)
412 {
414 $tmp_completed[$user_id]++;
415 break;
416
418 if((bool)$row["is_final"])
419 {
420 // object is failed when at least 1 objective is failed without any tries left
422 }
423 break;
424 }
425 }
426
427 $all_nr = sizeof($a_objective_ids);
428 foreach($tmp_completed as $user_id => $counter)
429 {
430 // if used as precondition object should be completed ASAP, status can be lost on subsequent tries
431 if($counter == $all_nr)
432 {
434 }
435 }
436
437 if($a_user_id)
438 {
439 // might return null!
440 return $res[$a_user_id];
441 }
442 else
443 {
444 return $res;
445 }
446 }
const LP_STATUS_IN_PROGRESS_NUM

References $ilDB, $res, $row, $user_id, ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED_NUM, ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, STATUS_COMPLETED, and STATUS_FAILED.

Referenced by ilLPStatusObjectives\_getStatusInfo(), and ilLPStatusObjectives\determineStatus().

+ Here is the caller graph for this function:

◆ hasResults()

static ilLOUserResults::hasResults (   $a_container_id,
  $a_user_id 
)
static

Definition at line 449 of file class.ilLOUserResults.php.

450 {
451 global $ilDB;
452
453 $query = 'SELECT objective_id FROM loc_user_results '.
454 'WHERE course_id = '.$ilDB->quote($a_container_id,'integer').' '.
455 'AND user_id = '.$ilDB->quote($a_user_id,'integer');
456
457 $res = $ilDB->query($query);
458 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
459 {
460 return true;
461 }
462 return false;
463 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilContainerObjectiveGUI\getMainContent().

+ Here is the caller graph for this function:

◆ isValidStatus()

static ilLOUserResults::isValidStatus (   $a_status)
staticprotected

Is given status valid?

Parameters
int$a_status
Returns
bool

Definition at line 92 of file class.ilLOUserResults.php.

93 {
94 return in_array((int)$a_status, array(self::STATUS_COMPLETED, self::STATUS_FAILED));
95 }

Referenced by findObjectiveIds().

+ Here is the caller graph for this function:

◆ isValidType()

static ilLOUserResults::isValidType (   $a_type)
staticprotected

Is given type valid?

Parameters
int$a_type
Returns
bool

Definition at line 81 of file class.ilLOUserResults.php.

82 {
83 return in_array((int)$a_type, array(self::TYPE_INITIAL, self::TYPE_QUALIFIED));
84 }

Referenced by findObjectiveIds().

+ Here is the caller graph for this function:

◆ lookupResult()

static ilLOUserResults::lookupResult (   $a_course_obj_id,
  $a_user_id,
  $a_objective_id,
  $a_tst_type 
)
static

Lookup user result.

Definition at line 38 of file class.ilLOUserResults.php.

39 {
40 global $ilDB;
41
42 $query = 'SELECT * FROM loc_user_results '.
43 'WHERE user_id = '.$ilDB->quote($a_user_id,'integer').' '.
44 'AND course_id = '.$ilDB->quote($a_course_obj_id,'integer').' '.
45 'AND objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
46 'AND type = '.$ilDB->quote($a_tst_type,'integer');
47 $res = $ilDB->query($query);
48 $ur = array(
49 'status' => self::STATUS_FAILED,
50 'result_perc' => 0,
51 'limit_perc' => 0,
52 'tries' => 0,
53 'is_final' => 0
54 );
55 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
56 {
57 $ur['status'] = $row->status;
58 $ur['result_perc'] = $row->result_perc;
59 $ur['limit_perc'] = $row->limit_perc;
60 $ur['tries'] = $row->tries;
61 $ur['is_final'] = $row->is_final;
62 }
63 return $ur;
64 }

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilContainerObjectiveGUI\addItemDetails(), ilLOTestQuestionAdapter\initUserResult(), and ilLOTestQuestionAdapter\updateQuestionResult().

+ Here is the caller graph for this function:

◆ resetFinalByObjective()

static ilLOUserResults::resetFinalByObjective (   $a_objective_id)
static

Definition at line 66 of file class.ilLOUserResults.php.

67 {
68 $query = 'UPDATE loc_user_results '.
69 'SET is_final = '.$GLOBALS['ilDB']->quote(0,'integer').' '.
70 'WHERE objective_id = '.$GLOBALS['ilDB']->quote($a_objective_id,'integer');
71 $GLOBALS['ilDB']->manipulate($query);
72 }
$GLOBALS['ct_recipient']

References $GLOBALS, and $query.

◆ saveObjectiveResult()

ilLOUserResults::saveObjectiveResult (   $a_objective_id,
  $a_type,
  $a_status,
  $a_result_percentage,
  $a_limit_percentage,
  $a_tries,
  $a_is_final 
)

Save objective result.

Parameters
int$a_objective_id
int$a_type
int$a_status
int$a_result_percentage
int$a_limit_percentage
int$a_tries
bool$a_is_final
Returns
bool

Definition at line 203 of file class.ilLOUserResults.php.

204 {
205 global $ilDB;
206
207 if(!self::isValidType($a_type) ||
208 !self::isValidStatus($a_status))
209 {
210 return false;
211 }
212 $ilDB->replace("loc_user_results",
213 array(
214 "course_id" => array("integer", $this->course_obj_id),
215 "user_id" => array("integer", $this->user_id),
216 "objective_id" => array("integer", $a_objective_id),
217 "type" => array("integer", $a_type)
218 ),
219 array(
220 "status" => array("integer", $a_status),
221 "result_perc" => array("integer", $a_result_percentage),
222 "limit_perc" => array("integer", $a_limit_percentage),
223 "tries" => array("integer", $a_tries),
224 "is_final" => array("integer", $a_is_final),
225 "tstamp" => array("integer", time()),
226 )
227 );
228 return true;
229 }

References $ilDB.

Field Documentation

◆ $course_obj_id

ilLOUserResults::$course_obj_id
protected

Definition at line 13 of file class.ilLOUserResults.php.

◆ $user_id

ilLOUserResults::$user_id
protected

Definition at line 14 of file class.ilLOUserResults.php.

Referenced by getSummarizedObjectiveStatusForLP().

◆ STATUS_COMPLETED

◆ STATUS_FAILED

◆ TYPE_INITIAL

◆ TYPE_QUALIFIED


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