ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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 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, $a_obj_id, array $a_objective_ids)
 
static getSummarizedObjectiveStatusForLP ($a_obj_id, 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 type $ilDB.

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

References $ilDB, and $query.

Referenced by ilObjCourseGUI\resetObject().

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
+ Here is the caller graph for this function:

◆ 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.

References $ilDB.

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  }
global $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.

References $ilDB.

Referenced by ilObjCourse\_deleteUser().

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  }
global $ilDB
+ 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.

References $ilDB.

Referenced by ilTestLP\resetCustomLPDataForUserIds().

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  }
global $ilDB
+ 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.

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

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

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  }
global $ilDB
static isValidStatus($a_status)
Is given status valid?
static isValidType($a_type)
Is given type valid?
+ 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.

References findObjectiveIds(), and ilLOSettings\getInstanceByObjId().

298  {
299  include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
300  $settings = ilLOSettings::getInstanceByObjId($this->course_obj_id);
301 
302  if(!$settings->isInitialTestQualifying() or !$settings->worksWithInitialTest())
303  {
304  return $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED);
305  }
306 
307  // qualifying initial
308  return array_unique(
309  array_merge(
310  $this->findObjectiveIds(self::TYPE_INITIAL, self::STATUS_COMPLETED),
311  $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED)
312  )
313  );
314  }
static getInstanceByObjId($a_obj_id)
get singleton instance
findObjectiveIds($a_type=null, $a_status=null, $a_is_final=null)
Find objective ids by type and/or status.
+ 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.

References findObjectiveIds().

278  {
279  return $this->findObjectiveIds($a_type, self::STATUS_COMPLETED);
280  }
findObjectiveIds($a_type=null, $a_status=null, $a_is_final=null)
Find objective ids by type and/or status.
+ Here is the call graph for this function:

◆ getCourseResultsForUserPresentation()

ilLOUserResults::getCourseResultsForUserPresentation ( )

Get all results for course and user.

Returns
array

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

References $ilDB, $res, and $row.

333  {
334  global $ilDB;
335 
336  $res = array();
337 
338  $set = $ilDB->query("SELECT *".
339  " FROM loc_user_results".
340  " WHERE course_id = ".$ilDB->quote($this->course_obj_id, "integer").
341  " AND user_id = ".$ilDB->quote($this->user_id, "integer"));
342  while($row = $ilDB->fetchAssoc($set))
343  {
344  $objective_id = $row["objective_id"];
345  $type = $row["type"];
346  unset($row["objective_id"]);
347  unset($row["type"]);
348  $res[$objective_id][$type] = $row;
349  }
350 
351  return $res;
352  }
global $ilDB

◆ 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 322 of file class.ilLOUserResults.php.

References findObjectiveIds().

323  {
324  return $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_FAILED, $a_is_final);
325  }
findObjectiveIds($a_type=null, $a_status=null, $a_is_final=null)
Find objective ids by type and/or status.
+ Here is the call graph for this function:

◆ getObjectiveStatusForLP()

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

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

References $ilDB, $res, $row, ilLOSettings\getInstanceByObjId(), ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED_NUM, and ilLPStatus\LP_STATUS_IN_PROGRESS_NUM.

Referenced by ilTrQuery\getObjectivesStatusForUser().

355  {
356  global $ilDB;
357 
358  // are initital test(s) qualifying?
359  include_once "Modules/Course/classes/Objectives/class.ilLOSettings.php";
360  $lo_set = ilLOSettings::getInstanceByObjId($a_obj_id);
361  $initial_qualifying = $lo_set->isInitialTestQualifying();
362 
363  // this method returns LP status codes!
364  include_once "Services/Tracking/classes/class.ilLPStatus.php";
365 
366  $res = array();
367 
368  $sql = "SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final".
369  " FROM loc_user_results lor".
370  " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)".
371  " WHERE ".$ilDB->in("lor.objective_id", $a_objective_ids, "", "integer");
372  if(!(bool)$initial_qualifying)
373  {
374  $sql .= " AND lor.type = ".$ilDB->quote(self::TYPE_QUALIFIED, "integer");
375  }
376  $sql .= " AND lor.user_id = ".$ilDB->quote($a_user_id, "integer").
377  " AND cobj.active = ".$ilDB->quote(1, "integer").
378  " ORDER BY lor.type"; // qualified must come last!
379  $set = $ilDB->query($sql);
380  while($row = $ilDB->fetchAssoc($set))
381  {
382  switch($row["status"])
383  {
384  case self::STATUS_FAILED:
385  if((bool)$row["is_final"])
386  {
388  }
389  else
390  {
391  // #15379
393  }
394  break;
395 
396  case self::STATUS_COMPLETED:
398  break;
399 
400  default:
401  /*
402  $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
403  break;
404  */
405  continue;
406  }
407 
408  // if both initial and qualified, qualified will overwrite initial
409  $res[$row["objective_id"]] = $status;
410  }
411 
412  return $res;
413  }
const LP_STATUS_COMPLETED_NUM
static getInstanceByObjId($a_obj_id)
get singleton instance
const LP_STATUS_IN_PROGRESS_NUM
global $ilDB
const LP_STATUS_FAILED_NUM
+ Here is the call graph for this function:
+ 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.

References findObjectiveIds().

288  {
289  return $this->findObjectiveIds(self::TYPE_INITIAL, self::STATUS_FAILED);
290  }
findObjectiveIds($a_type=null, $a_status=null, $a_is_final=null)
Find objective ids by type and/or status.
+ Here is the call graph for this function:

◆ getSummarizedObjectiveStatusForLP()

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

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

References $ilDB, $res, $row, $user_id, ilLOSettings\getInstanceByObjId(), ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED_NUM, and ilLPStatus\LP_STATUS_IN_PROGRESS_NUM.

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

416  {
417  global $ilDB;
418 
419  // change event is NOT parsed here!
420 
421  // are initital test(s) qualifying?
422  include_once "Modules/Course/classes/Objectives/class.ilLOSettings.php";
423  $lo_set = ilLOSettings::getInstanceByObjId($a_obj_id);
424  $initial_qualifying = $lo_set->isInitialTestQualifying();
425 
426  // this method returns LP status codes!
427  include_once "Services/Tracking/classes/class.ilLPStatus.php";
428 
429  $res = $tmp_completed = array();
430 
431  $sql = "SELECT lor.objective_id, lor.user_id, lor.status, lor.type".
432  " FROM loc_user_results lor".
433  " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)".
434  " WHERE ".$ilDB->in("lor.objective_id", $a_objective_ids, "", "integer").
435  " AND cobj.active = ".$ilDB->quote(1, "integer");
436  if(!(bool)$initial_qualifying)
437  {
438  $sql .= " AND lor.type = ".$ilDB->quote(self::TYPE_QUALIFIED, "integer");
439  }
440  if($a_user_id)
441  {
442  $sql .= " AND lor.user_id = ".$ilDB->quote($a_user_id, "integer");
443  }
444  $sql .= " ORDER BY lor.type DESC"; // qualified must come first!
445  $set = $ilDB->query($sql);
446  while($row = $ilDB->fetchAssoc($set))
447  {
448  $user_id = (int)$row["user_id"];
449  $status = (int)$row["status"];
450 
451  // initial tests only count if no qualified test
452  if($row["type"] == self::TYPE_INITIAL &&
453  isset($res[$user_id]))
454  {
455  continue;
456  }
457 
458  // user did do something
460 
461  switch($status)
462  {
463  case self::STATUS_COMPLETED:
464  $tmp_completed[$user_id]++;
465  break;
466 
467  case self::STATUS_FAILED:
468  if((bool)$row["is_final"])
469  {
470  // object is failed when at least 1 objective is failed without any tries left
472  }
473  break;
474  }
475  }
476 
477  $all_nr = sizeof($a_objective_ids);
478  foreach($tmp_completed as $user_id => $counter)
479  {
480  // if used as precondition object should be completed ASAP, status can be lost on subsequent tries
481  if($counter == $all_nr)
482  {
484  }
485  }
486 
487  if($a_user_id)
488  {
489  // might return null!
490  return $res[$a_user_id];
491  }
492  else
493  {
494  return $res;
495  }
496  }
const LP_STATUS_COMPLETED_NUM
static getInstanceByObjId($a_obj_id)
get singleton instance
const LP_STATUS_IN_PROGRESS_NUM
global $ilDB
const LP_STATUS_FAILED_NUM
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasResults()

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

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

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

Referenced by ilContainerObjectiveGUI\getMainContent().

499  {
500  global $ilDB;
501 
502  $query = 'SELECT objective_id FROM loc_user_results '.
503  'WHERE course_id = '.$ilDB->quote($a_container_id,'integer').' '.
504  'AND user_id = '.$ilDB->quote($a_user_id,'integer');
505 
506  $res = $ilDB->query($query);
507  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
508  {
509  return true;
510  }
511  return false;
512  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ 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.

Referenced by findObjectiveIds().

93  {
94  return in_array((int)$a_status, array(self::STATUS_COMPLETED, self::STATUS_FAILED));
95  }
+ 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.

Referenced by findObjectiveIds().

82  {
83  return in_array((int)$a_type, array(self::TYPE_INITIAL, self::TYPE_QUALIFIED));
84  }
+ 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.

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

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

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  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ 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.

References $GLOBALS, and $query.

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['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

◆ 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.

References $ilDB.

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  }
global $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

const ilLOUserResults::STATUS_FAILED = 2

◆ TYPE_INITIAL

◆ TYPE_QUALIFIED


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