ILIAS  release_4-4 Revision
ilLPStatus Class Reference

Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ... More...

+ Inheritance diagram for ilLPStatus:
+ Collaboration diagram for ilLPStatus:

Public Member Functions

 ilLPStatus ($a_obj_id)
 
 _getCountNotAttempted ($a_obj_id)
 
 _getNotAttempted ($a_obj_id)
 
 _getCountInProgress ($a_obj_id)
 
 _getInProgress ($a_obj_id)
 
 _getCountCompleted ($a_obj_id)
 
 _getCompleted ($a_obj_id)
 
 _getFailed ($a_obj_id)
 
 _getCountFailed ()
 
 _getStatusInfo ($a_obj_id)
 
 _getTypicalLearningTime ($a_obj_id)
 
 _updateStatus ($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
 New status handling (st: status, nr: accesses, p: percentage, t: time spent, m: mark) More...
 
 determinePercentage ($a_obj_id, $a_usr_id, $a_obj=null)
 Determine percentage. More...
 
 determineStatus ($a_obj_id, $a_usr_id, $a_obj=null)
 Determine status. More...
 
 refreshStatus ($a_obj_id, $a_users=null)
 Refresh status. More...
 
 _lookupStatusChanged ($a_obj_id, $a_user_id)
 Lookup status changed. More...
 

Static Public Member Functions

static checkStatusForObject ($a_obj_id, $a_users=false)
 This function checks whether the status for a given number of users is dirty and must be recalculated. More...
 
static writeStatus ($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false)
 Write status for user and object. More...
 
static setInProgressIfNotAttempted ($a_obj_id, $a_user_id)
 This function shoudl be clalled for normal "read events". More...
 
static setAllDirty ()
 Sets all status to dirty. More...
 
static setDirty ($a_obj_id)
 Sets status of an object to dirty. More...
 
static _lookupStatus ($a_obj_id, $a_user_id)
 Lookup status. More...
 
static _hasUserCompleted ($a_obj_id, $a_user_id)
 Lookup user object completion. More...
 
static _lookupCompletedForObject ($a_obj_id, $a_user_ids=null)
 Get completed users for object. More...
 
static _lookupFailedForObject ($a_obj_id, $a_user_ids=null)
 Get failed users for object. More...
 
static _lookupInProgressForObject ($a_obj_id, $a_user_ids=null)
 Get in progress users for object. More...
 
static preloadListGUIData ($a_obj_ids)
 
static getListGUIStatus ($a_obj_id)
 

Data Fields

 $obj_id = null
 
 $db = null
 
const LP_STATUS_NOT_ATTEMPTED = 'trac_no_attempted'
 
const LP_STATUS_IN_PROGRESS = 'trac_in_progress'
 
const LP_STATUS_COMPLETED = 'trac_completed'
 
const LP_STATUS_FAILED = 'trac_failed'
 
const LP_STATUS_NOT_ATTEMPTED_NUM = 0
 
const LP_STATUS_IN_PROGRESS_NUM = 1
 
const LP_STATUS_COMPLETED_NUM = 2
 
const LP_STATUS_FAILED_NUM = 3
 
const LP_STATUS_REGISTERED = 'trac_registered'
 
const LP_STATUS_NOT_REGISTERED = 'trac_not_registered'
 
const LP_STATUS_PARTICIPATED = 'trac_participated'
 
const LP_STATUS_NOT_PARTICIPATED = 'trac_not_participated'
 

Static Public Attributes

static $list_gui_cache
 

Protected Member Functions

 raiseEvent ($a_obj_id, $a_usr_id, $a_status, $a_percentage)
 

Static Protected Member Functions

static _lookupStatusForObject ($a_obj_id, $a_status, $a_user_ids=null)
 Get users with given status for object. More...
 

Detailed Description

Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 15 of file class.ilLPStatus.php.

Member Function Documentation

◆ _getCompleted()

ilLPStatus::_getCompleted (   $a_obj_id)

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

70  {
71  return array();
72  }

◆ _getCountCompleted()

ilLPStatus::_getCountCompleted (   $a_obj_id)

Definition at line 65 of file class.ilLPStatus.php.

66  {
67  return 0;
68  }

◆ _getCountFailed()

ilLPStatus::_getCountFailed ( )

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

78  {
79  return 0;
80  }

◆ _getCountInProgress()

ilLPStatus::_getCountInProgress (   $a_obj_id)

Definition at line 56 of file class.ilLPStatus.php.

57  {
58  return 0;
59  }

◆ _getCountNotAttempted()

ilLPStatus::_getCountNotAttempted (   $a_obj_id)

Definition at line 46 of file class.ilLPStatus.php.

47  {
48  return 0;
49  }

◆ _getFailed()

ilLPStatus::_getFailed (   $a_obj_id)

Definition at line 73 of file class.ilLPStatus.php.

74  {
75  return array();
76  }

◆ _getInProgress()

ilLPStatus::_getInProgress (   $a_obj_id)

Definition at line 60 of file class.ilLPStatus.php.

61  {
62  return array();
63  }

◆ _getNotAttempted()

ilLPStatus::_getNotAttempted (   $a_obj_id)

Definition at line 51 of file class.ilLPStatus.php.

52  {
53  return array();
54  }

◆ _getStatusInfo()

ilLPStatus::_getStatusInfo (   $a_obj_id)

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

82  {
83  return array();
84  }

◆ _getTypicalLearningTime()

ilLPStatus::_getTypicalLearningTime (   $a_obj_id)

Definition at line 85 of file class.ilLPStatus.php.

References ilMDEducational\_getTypicalLearningTimeSeconds().

86  {
87  include_once 'Services/MetaData/classes/class.ilMDEducational.php';
89  }
_getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
+ Here is the call graph for this function:

◆ _hasUserCompleted()

static ilLPStatus::_hasUserCompleted (   $a_obj_id,
  $a_user_id 
)
static

Lookup user object completion.

Parameters
int$a_obj_id
int$a_user_id
Returns
bool

Definition at line 568 of file class.ilLPStatus.php.

Referenced by ilConditionHandler\_checkCondition(), ilObjSAHSLearningModuleAccess\_lookupUserCertificate(), ilTimingCache\_showWarning(), ilObjCourse\checkLPStatusSync(), ilSCORMVerificationTableGUI\getItems(), and ilCourseStart\isFullfilled().

569  {
570  return (self::_lookupStatus($a_obj_id, $a_user_id) == self::LP_STATUS_COMPLETED_NUM);
571  }
+ Here is the caller graph for this function:

◆ _lookupCompletedForObject()

static ilLPStatus::_lookupCompletedForObject (   $a_obj_id,
  $a_user_ids = null 
)
static

Get completed users for object.

Parameters
int$a_obj_id
array$a_user_ids
Returns
array

Definition at line 653 of file class.ilLPStatus.php.

654  {
655  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
656  }

◆ _lookupFailedForObject()

static ilLPStatus::_lookupFailedForObject (   $a_obj_id,
  $a_user_ids = null 
)
static

Get failed users for object.

Parameters
int$a_obj_id
array$a_user_ids
Returns
array

Definition at line 665 of file class.ilLPStatus.php.

666  {
667  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_FAILED_NUM, $a_user_ids);
668  }

◆ _lookupInProgressForObject()

static ilLPStatus::_lookupInProgressForObject (   $a_obj_id,
  $a_user_ids = null 
)
static

Get in progress users for object.

Parameters
int$a_obj_id
array$a_user_ids
Returns
array

Definition at line 677 of file class.ilLPStatus.php.

678  {
679  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
680  }

◆ _lookupStatus()

static ilLPStatus::_lookupStatus (   $a_obj_id,
  $a_user_id 
)
static

Lookup status.

Parameters
int$a_obj_idobject id
int$a_user_iduser id

Definition at line 532 of file class.ilLPStatus.php.

References ilLPStatusWrapper\_updateStatus().

Referenced by ilLearningProgressBaseGUI\__readStatus(), ilLearningProgressBaseGUI\__showEditUser(), ilSoapSCORMAdministration\getSCORMCompletionStatus(), and ilObjSCORMInitData\getStatus().

533  {
534  global $ilDB;
535 
536  $set = $ilDB->query("SELECT status FROM ut_lp_marks WHERE ".
537  " status_dirty = ".$ilDB->quote(0, "integer").
538  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
539  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
540  );
541  if ($rec = $ilDB->fetchAssoc($set))
542  {
543  return $rec["status"];
544  }
545  else
546  {
547  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
548  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
549  $set = $ilDB->query("SELECT status FROM ut_lp_marks WHERE ".
550  " status_dirty = ".$ilDB->quote(0, "integer").
551  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
552  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
553  );
554  if ($rec = $ilDB->fetchAssoc($set))
555  {
556  return $rec["status"];
557  }
558  }
559  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupStatusChanged()

ilLPStatus::_lookupStatusChanged (   $a_obj_id,
  $a_user_id 
)

Lookup status changed.

Parameters
int$a_obj_idobject id
int$a_user_iduser id

Definition at line 579 of file class.ilLPStatus.php.

References ilLPStatusWrapper\_updateStatus().

Referenced by ilCertificateAdapter\getUserCompletionDate().

580  {
581  global $ilDB;
582 
583  $set = $ilDB->query("SELECT status_changed FROM ut_lp_marks WHERE ".
584  " status_dirty = ".$ilDB->quote(0, "integer").
585  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
586  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
587  );
588  if ($rec = $ilDB->fetchAssoc($set))
589  {
590  return $rec["status_changed"];
591  }
592  else
593  {
594  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
595  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
596  $set = $ilDB->query("SELECT status_changed FROM ut_lp_marks WHERE ".
597  " status_dirty = ".$ilDB->quote(0, "integer").
598  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
599  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
600  );
601  if ($rec = $ilDB->fetchAssoc($set))
602  {
603  return $rec["status_changed"];
604  }
605  }
606  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupStatusForObject()

static ilLPStatus::_lookupStatusForObject (   $a_obj_id,
  $a_status,
  $a_user_ids = null 
)
staticprotected

Get users with given status for object.

Parameters
int$a_obj_id
int$a_status
array$a_user_ids
Returns
array

Definition at line 616 of file class.ilLPStatus.php.

References $res.

617  {
618  global $ilDB;
619 
620  $sql = "SELECT usr_id, status, status_dirty FROM ut_lp_marks".
621  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer").
622  " AND status = ".$ilDB->quote($a_status, "integer");
623  if($a_user_ids)
624  {
625  $sql .= " AND ".$ilDB->in("usr_id", $a_user_ids, "", "integer");
626  }
627 
628  $set = $ilDB->query($sql);
629  $res = array();
630  while($rec = $ilDB->fetchAssoc($set))
631  {
632  if($res["status_dirty"])
633  {
634  // update status and check again
635  if(self::_lookupStatus($a_obj_id, $rec["usr_id"]) != $a_status)
636  {
637  continue;
638  }
639  }
640  $res[] = $rec["usr_id"];
641  }
642 
643  return $res;
644  }

◆ _updateStatus()

ilLPStatus::_updateStatus (   $a_obj_id,
  $a_usr_id,
  $a_obj = null,
  $a_percentage = false,
  $a_no_raise = false,
  $a_force_raise = false 
)

New status handling (st: status, nr: accesses, p: percentage, t: time spent, m: mark)

Learning progress:

Added determine Status to:

Updating the status:

- ilLearningProgress->_tracProgress() added to:

  • ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id); added to: – ilInfoScreenGUI->saveProgress() – ilLMPresentation->ilPage() – ilLPListOfObjectsGUI->updateUser() – ilCourseObjectiveResult->reset() – ilCourseObjectiveResult->__updatePassed() – ilEventParticipants->updateUser() – ilEventParticipants->_updateParticipation() – ilEventParticipants->_register() – ilEventParticipants->_unregister() – ilExerciseMembers->assignMember() – ilExerciseMembers->deassignMember() – ilExerciseMembers->ilClone() – ilExerciseMembers->writeStatus() – ilExerciseMembers->writeReturned() – ilSCORM13Player->writeGObjective() – ilObjSCORM2004LearningModule->deleteTrackingDataOfUsers() – ilObjSCORM2004LearningModule->importSuccess() – ilObjSCORM2004LearningModuleGUI->confirmedDeleteTracking() – ilSCORM13Player->removeCMIData() – ilSCORM13Player->setCMIData() – ilObjSCORMLearningModule->importSuccess() – ilObjSCORMLearningModule->importRaw() – ilObjSCORMLearningModuleGUI->confirmedDelete() – ilObjSCORMLearningModuleGUI->decreaseAttempt() – ilObjSCORMTracking->store() – ilObjSCORMTracking-> _insertTrackData() – ilSCORMPresentationGUI->increase_attemptAndsave_module_version() – ilTestScoringGUI->setPointsManual() – ilTestSession->increaseTestPass() – ilTestSession->saveToDb()
  • ilLPStatusWrapper::_refreshStatus($a_ojb_id); aufgenommen in: – ilCourseObjective->add() – ilCourseObjective->delete() – ilCourseObjective->deleteAll() – ilExerciseMembers->delete() – ilSCORM13Package->removeCMIData() – ilAICCCourse->delete() – ilAICCUnit->delete() – ilObjAICCLearningModule->delete() – ilSCORMItem->delete() – ilLPStatusWrapper->update() – ilLPListOfSettingsGUI->assign() – ilLPListOfSettingsGUI->deassign() – ilLPListOfSettingsGUI->groupMaterials() – ilLPListOfSettingsGUI->releaseMaterials() – ilObjTestGUI->confirmDeleteAllUserResultsObject move to ilObjTest but this can ba called for each single question – ilConditionHandlerInterface->updateCondition()
  • external time/access values for read events ilChangeEvent::_recordReadEvent($a_obj_id, $a_user_id, false, $attempts, $time); – ilObjSCORMTracking->_syncReadEvent in ilObjSCORMTracking->store() (add to refresh) – ilSCORM2004Tracking->_syncReadEvent in ilSCORM13Player->setCMIData() Write status
Parameters

Definition at line 195 of file class.ilLPStatus.php.

References $changed, determinePercentage(), and determineStatus().

196  {
197 //global $ilLog;
198 //$ilLog->write("ilLPStatus-_updateStatus-");
199 
200  $status = $this->determineStatus($a_obj_id, $a_usr_id, $a_obj);
201  $percentage = $this->determinePercentage($a_obj_id, $a_usr_id, $a_obj);
202  $changed = self::writeStatus($a_obj_id, $a_usr_id, $status, $percentage);
203 
204  if(!$a_no_raise &&
205  ($changed || $a_force_raise)) // #15529
206  {
207  self::raiseEvent($a_obj_id, $a_usr_id, $status, $percentage);
208  }
209  }
determineStatus($a_obj_id, $a_usr_id, $a_obj=null)
Determine status.
determinePercentage($a_obj_id, $a_usr_id, $a_obj=null)
Determine percentage.
+ Here is the call graph for this function:

◆ checkStatusForObject()

static ilLPStatus::checkStatusForObject (   $a_obj_id,
  $a_users = false 
)
static

This function checks whether the status for a given number of users is dirty and must be recalculated.

"Missing" records are not inserted!

Parameters

Definition at line 241 of file class.ilLPStatus.php.

References $r, and ilLPStatusFactory\_getInstance().

Referenced by ilTrQuery\refreshObjectsStatus().

242  {
243  global $ilDB;
244 
245 //@todo: there maybe the need to add extra handling for sessions here, since the
246 // "in progress" status is time dependent here. On the other hand, if they registered
247 // to the session, they already accessed the course and should have a "in progress"
248 // anyway. But the status on the session itself may not be correct.
249 
250  $sql = "SELECT usr_id FROM ut_lp_marks WHERE ".
251  " obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
252  " status_dirty = ".$ilDB->quote(1, "integer");
253  if(is_array($a_users) && count($a_users) > 0)
254  {
255  $sql .= " AND ".$ilDB->in("usr_id", $a_users, false, "integer");
256  }
257  $set = $ilDB->query($sql);
258  $dirty = false;
259  if ($rec = $ilDB->fetchAssoc($set))
260  {
261  $dirty = true;
262  }
263 
264  // check if any records are missing
265  $missing = false;
266  if (!$dirty && is_array($a_users) && count($a_users) > 0)
267  {
268  $set = $ilDB->query("SELECT count(usr_id) cnt FROM ut_lp_marks WHERE ".
269  " obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
270  $ilDB->in("usr_id", $a_users, false, "integer"));
271  $r = $ilDB->fetchAssoc($set);
272  if ($r["cnt"] < count($a_users))
273  {
274  $missing = true;
275  }
276  }
277 
278  // refresh status, if records are dirty or missing
279  if ($dirty || $missing)
280  {
281  require_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; // #13330
282  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
283  $trac_obj->refreshStatus($a_obj_id, $a_users);
284  }
285  }
_getInstance($a_obj_id, $a_mode=NULL)
$r
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determinePercentage()

ilLPStatus::determinePercentage (   $a_obj_id,
  $a_usr_id,
  $a_obj = null 
)

Determine percentage.

Parameters

Definition at line 217 of file class.ilLPStatus.php.

Referenced by _updateStatus(), and refreshStatus().

218  {
219  return false;
220  }
+ Here is the caller graph for this function:

◆ determineStatus()

ilLPStatus::determineStatus (   $a_obj_id,
  $a_usr_id,
  $a_obj = null 
)

Determine status.

Parameters

Definition at line 228 of file class.ilLPStatus.php.

Referenced by _updateStatus().

229  {
230  return false;
231  }
+ Here is the caller graph for this function:

◆ getListGUIStatus()

static ilLPStatus::getListGUIStatus (   $a_obj_id)
static

Definition at line 769 of file class.ilLPStatus.php.

Referenced by ilObjectListGUI\insertProperties().

770  {
771  return self::$list_gui_cache[$a_obj_id];
772  }
+ Here is the caller graph for this function:

◆ ilLPStatus()

ilLPStatus::ilLPStatus (   $a_obj_id)

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

39  {
40  global $ilDB;
41 
42  $this->obj_id = $a_obj_id;
43  $this->db =& $ilDB;
44  }

◆ preloadListGUIData()

static ilLPStatus::preloadListGUIData (   $a_obj_ids)
static

Definition at line 682 of file class.ilLPStatus.php.

References $ilUser, $lng, $obj_id, $path, $res, $row, $valid, ilObjUserTracking\_enabledLearningProgress(), ilLearningProgressBaseGUI\_getImagePathForStatus(), ilLearningProgressBaseGUI\_getStatusText(), ilObjUserTracking\_hasLearningProgressLearner(), ilObjUserTracking\_hasLearningProgressListGUI(), ilLPObjSettings\_lookupDBModeForObjects(), ilObjectLP\getInstance(), ilUtil\img(), ilLPObjSettings\LP_MODE_DEACTIVATED, and ilLPObjSettings\LP_MODE_UNDEFINED.

Referenced by ilObjectListGUIPreloader\preload().

683  {
684  global $ilDB, $ilUser, $lng;
685 
686  $res = array();
687 
688  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
689  if($ilUser->getId() != ANONYMOUS_USER_ID &&
693  {
694  include_once "Services/Object/classes/class.ilObjectLP.php";
695 
696  // validate objects
697  $valid = array();
698  $existing = ilLPObjSettings::_lookupDBModeForObjects($a_obj_ids);
699  foreach($existing as $obj_id => $obj_mode)
700  {
701  if($obj_mode != ilLPObjSettings::LP_MODE_DEACTIVATED)
702  {
704  }
705  }
706 
707  if(sizeof($existing) != sizeof($a_obj_ids))
708  {
709  // missing objects (default mode)
710  foreach(array_diff($a_obj_ids, $existing) as $obj_id)
711  {
712  $olp = ilObjectLP::getInstance($obj_id);
713  $mode = $olp->getCurrentMode();
715  {
716  // #11141
717  unset($valid[$obj_id]);
718  }
719  else if($mode != ilLPObjSettings::LP_MODE_UNDEFINED)
720  {
722  }
723  }
724  unset($existing);
725  }
726 
727  $valid = array_values($valid);
728 
729  // get user lp data
730  $sql = "SELECT status, status_dirty, obj_id FROM ut_lp_marks".
731  " WHERE ".$ilDB->in("obj_id", $valid, "", "integer").
732  " AND usr_id = ".$ilDB->quote($ilUser->getId(), "integer");
733  $set = $ilDB->query($sql);
734  while($row = $ilDB->fetchAssoc($set))
735  {
736  if(!$row["status_dirty"])
737  {
738  $res[$row["obj_id"]] = $row["status"];
739  }
740  else
741  {
742  $res[$row["obj_id"]] = self::_lookupStatus($row["obj_id"], $ilUser->getId());
743  }
744  }
745 
746  // add not attempted for missing user entries
747  foreach($valid as $obj_id)
748  {
749  if(!isset($res[$obj_id]))
750  {
751  $res[$obj_id] = self::LP_STATUS_NOT_ATTEMPTED_NUM;
752  }
753  }
754 
755  // value to icon
756  $lng->loadLanguageModule("trac");
757  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
758  foreach($res as $obj_id => $status)
759  {
762  $res[$obj_id] = ilUtil::img($path, $text);
763  }
764  }
765 
766  self::$list_gui_cache = $res;
767  }
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="")
Build img tag.
$valid
_getImagePathForStatus($a_status)
Get image path for status.
_getStatusText($a_status)
Get status alt text.
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _lookupDBModeForObjects(array $a_obj_ids)
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
static getInstance($a_obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ raiseEvent()

ilLPStatus::raiseEvent (   $a_obj_id,
  $a_usr_id,
  $a_status,
  $a_percentage 
)
protected

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

288  {
289  global $ilAppEventHandler;
290 
291  $ilAppEventHandler->raise("Services/Tracking", "updateStatus", array(
292  "obj_id" => $a_obj_id,
293  "usr_id" => $a_usr_id,
294  "status" => $a_status,
295  "percentage" => $a_percentage
296  ));
297  }

◆ refreshStatus()

ilLPStatus::refreshStatus (   $a_obj_id,
  $a_users = null 
)

Refresh status.

Parameters

Definition at line 305 of file class.ilLPStatus.php.

References $failed, ilLPStatusWrapper\_getCompleted(), ilLPStatusWrapper\_getFailed(), ilLPStatusWrapper\_getInProgress(), ilLPStatusWrapper\_getNotAttempted(), ilLPStatusWrapper\_updateStatus(), and determinePercentage().

306  {
307  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
308  $not_attempted = ilLPStatusWrapper::_getNotAttempted($a_obj_id);
309  foreach ($not_attempted as $user_id)
310  {
311  $percentage = $this->determinePercentage($a_obj_id, $user_id);
312  if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage, true))
313  {
314  self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage);
315  }
316  }
317  $in_progress = ilLPStatusWrapper::_getInProgress($a_obj_id);
318  foreach ($in_progress as $user_id)
319  {
320  $percentage = $this->determinePercentage($a_obj_id, $user_id);
321  if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage, true))
322  {
323  self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage);
324  }
325  }
326  $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
327  foreach ($completed as $user_id)
328  {
329  $percentage = $this->determinePercentage($a_obj_id, $user_id);
330  if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage, true))
331  {
332  self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage);
333  }
334  }
336  foreach ($failed as $user_id)
337  {
338  $percentage = $this->determinePercentage($a_obj_id, $user_id);
339  if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage, true))
340  {
341  self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage);
342  }
343  }
344  if($a_users)
345  {
346  $missing_users = array_diff($a_users, $not_attempted+$in_progress+$completed+$failed);
347  if($missing_users)
348  {
349  foreach ($missing_users as $user_id)
350  {
351  ilLPStatusWrapper::_updateStatus($a_obj_id, $user_id);
352  }
353  }
354  }
355  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
_getNotAttempted($a_obj_id)
Static function to read the number of user who have the status &#39;not_attempted&#39;.
_getFailed($a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
_getCompleted($a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
$failed
Definition: Utf8Test.php:86
_getInProgress($a_obj_id)
Static function to read users who have the status &#39;in_progress&#39;.
determinePercentage($a_obj_id, $a_usr_id, $a_obj=null)
Determine percentage.
+ Here is the call graph for this function:

◆ setAllDirty()

static ilLPStatus::setAllDirty ( )
static

Sets all status to dirty.

For testing puproses.

Parameters

Definition at line 500 of file class.ilLPStatus.php.

501  {
502  global $ilDB;
503 
504  $ilDB->manipulate("UPDATE ut_lp_marks SET ".
505  " status_dirty = ".$ilDB->quote(1, "integer")
506  );
507 
508  }

◆ setDirty()

static ilLPStatus::setDirty (   $a_obj_id)
static

Sets status of an object to dirty.

Parameters
integerobject id
Returns

Definition at line 516 of file class.ilLPStatus.php.

517  {
518  global $ilDB;
519 
520  $ilDB->manipulate("UPDATE ut_lp_marks SET ".
521  " status_dirty = ".$ilDB->quote(1, "integer").
522  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")
523  );
524  }

◆ setInProgressIfNotAttempted()

static ilLPStatus::setInProgressIfNotAttempted (   $a_obj_id,
  $a_user_id 
)
static

This function shoudl be clalled for normal "read events".

The "in progress" status is only written, if current status is "NOT ATTEMPTED"

Definition at line 461 of file class.ilLPStatus.php.

References ilLPStatusWrapper\_updateStatus().

Referenced by ilLearningProgress\_tracProgress().

462  {
463  global $ilDB;
464 
465  // #11513
466 
467  $needs_update = false;
468 
469  $set = $ilDB->query("SELECT usr_id, status FROM ut_lp_marks WHERE ".
470  " obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
471  " usr_id = ".$ilDB->quote($a_user_id, "integer")
472  );
473  if ($rec = $ilDB->fetchAssoc($set))
474  {
475  // current status is not attempted, so we need to update
476  if($rec["status"] == self::LP_STATUS_NOT_ATTEMPTED_NUM)
477  {
478  $needs_update = true;
479  }
480  }
481  else
482  {
483  // no ut_lp_marks yet, we should update
484  $needs_update = true;
485  }
486 
487  if($needs_update)
488  {
489  require_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
490  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
491  }
492  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeStatus()

static ilLPStatus::writeStatus (   $a_obj_id,
  $a_user_id,
  $a_status,
  $a_percentage = false,
  $a_force_per = false 
)
static

Write status for user and object.

Parameters

Definition at line 363 of file class.ilLPStatus.php.

References $ret, ilObject\_lookupType(), ilLPStatusWrapper\_removeStatusCache(), and ilLPStatusWrapper\_updateStatus().

Referenced by ilLPStatusSCORMPackage\refreshStatus(), ilLPStatusSCORM\refreshStatus(), ilObjSCORMTracking\syncGlobalStatus(), and ilSCORM2004StoreData\syncGlobalStatus().

364  {
365  global $ilDB;
366 
367  $update_collections = false;
368 
369  // get status in DB
370  $set = $ilDB->query("SELECT usr_id,status,status_dirty FROM ut_lp_marks WHERE ".
371  " obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
372  " usr_id = ".$ilDB->quote($a_user_id, "integer")
373  );
374  $rec = $ilDB->fetchAssoc($set);
375 
376  // update
377  if ($rec)
378  {
379  // status has changed: update
380  if ($rec["status"] != $a_status)
381  {
382  $ret = $ilDB->manipulate("UPDATE ut_lp_marks SET ".
383  " status = ".$ilDB->quote($a_status, "integer").",".
384  " status_changed = ".$ilDB->now().",".
385  " status_dirty = ".$ilDB->quote(0, "integer").
386  " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
387  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
388  );
389  if ($ret != 0)
390  {
391  $update_collections = true;
392  }
393  }
394  // status has not changed: reset dirty flag
395  else if ($rec["status_dirty"])
396  {
397  $ilDB->manipulate("UPDATE ut_lp_marks SET ".
398  " status_dirty = ".$ilDB->quote(0, "integer").
399  " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
400  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
401  );
402  }
403  }
404  // insert
405  else
406  {
407  $ilDB->manipulate("INSERT INTO ut_lp_marks ".
408  "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
409  $ilDB->quote($a_status, "integer").",".
410  $ilDB->now().",".
411  $ilDB->quote($a_user_id, "integer").",".
412  $ilDB->quote($a_obj_id, "integer").",".
413  $ilDB->quote(0, "integer").
414  ")");
415  $update_collections = true;
416  }
417 
418  // update percentage
419  if ($a_percentage !== false || $a_force_per)
420  {
421  $a_percentage = max(0, (int) $a_percentage);
422  $a_percentage = min(100, $a_percentage);
423  $ret = $ilDB->manipulate("UPDATE ut_lp_marks SET ".
424  " percentage = ".$ilDB->quote($a_percentage, "integer").
425  " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
426  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
427  );
428  }
429 
430  // update collections
431  if ($update_collections)
432  {
433  // a change occured - remove existing cache entry
434  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
435  ilLPStatusWrapper::_removeStatusCache($a_obj_id, $a_user_id);
436 
437  $set = $ilDB->query("SELECT ut_lp_collections.obj_id obj_id FROM ".
438  "object_reference JOIN ut_lp_collections ON ".
439  "(object_reference.obj_id = ".$ilDB->quote($a_obj_id, "integer").
440  " AND object_reference.ref_id = ut_lp_collections.item_id)");
441  while ($rec = $ilDB->fetchAssoc($set))
442  {
443  if (in_array(ilObject::_lookupType($rec["obj_id"]), array("crs", "grp", "fold")))
444  {
445  // just to make sure - remove existing cache entry
446  ilLPStatusWrapper::_removeStatusCache($rec["obj_id"], $a_user_id);
447 
448  ilLPStatusWrapper::_updateStatus($rec["obj_id"], $a_user_id);
449  }
450  }
451  }
452 
453  return $update_collections;
454  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _removeStatusCache($a_obj_id, $a_usr_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilLPStatus::$db = null

Definition at line 19 of file class.ilLPStatus.php.

◆ $list_gui_cache

ilLPStatus::$list_gui_cache
static

Definition at line 21 of file class.ilLPStatus.php.

◆ $obj_id

ilLPStatus::$obj_id = null

Definition at line 17 of file class.ilLPStatus.php.

Referenced by preloadListGUIData().

◆ LP_STATUS_COMPLETED

◆ LP_STATUS_COMPLETED_NUM

◆ LP_STATUS_FAILED

◆ LP_STATUS_FAILED_NUM

◆ LP_STATUS_IN_PROGRESS

◆ LP_STATUS_IN_PROGRESS_NUM

◆ LP_STATUS_NOT_ATTEMPTED

◆ LP_STATUS_NOT_ATTEMPTED_NUM

◆ LP_STATUS_NOT_PARTICIPATED

const ilLPStatus::LP_STATUS_NOT_PARTICIPATED = 'trac_not_participated'

◆ LP_STATUS_NOT_REGISTERED

const ilLPStatus::LP_STATUS_NOT_REGISTERED = 'trac_not_registered'

◆ LP_STATUS_PARTICIPATED

const ilLPStatus::LP_STATUS_PARTICIPATED = 'trac_participated'

◆ LP_STATUS_REGISTERED

const ilLPStatus::LP_STATUS_REGISTERED = 'trac_registered'

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