ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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, $a_create=true)
 Lookup status. More...
 
static _lookupPercentage ($a_obj_id, $a_user_id)
 Lookup percentage. 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 606 of file class.ilLPStatus.php.

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

607  {
608  return (self::_lookupStatus($a_obj_id, $a_user_id) == self::LP_STATUS_COMPLETED_NUM);
609  }
+ 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 691 of file class.ilLPStatus.php.

692  {
693  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
694  }

◆ _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 703 of file class.ilLPStatus.php.

704  {
705  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_FAILED_NUM, $a_user_ids);
706  }

◆ _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 715 of file class.ilLPStatus.php.

716  {
717  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
718  }

◆ _lookupPercentage()

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

Lookup percentage.

Parameters
int$a_obj_idobject id
int$a_user_iduser id

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

References $ilDB.

Referenced by ilLearningProgressBaseGUI\__appendLPDetails().

585  {
586  global $ilDB;
587 
588  $set = $ilDB->query("SELECT percentage FROM ut_lp_marks WHERE ".
589  " status_dirty = ".$ilDB->quote(0, "integer").
590  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
591  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
592  );
593  if ($rec = $ilDB->fetchAssoc($set))
594  {
595  return $rec["percentage"];
596  }
597  }
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupStatus()

static ilLPStatus::_lookupStatus (   $a_obj_id,
  $a_user_id,
  $a_create = true 
)
static

Lookup status.

Parameters
int$a_obj_idobject id
int$a_user_iduser id
bool$a_create

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

References $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilLearningProgressBaseGUI\__readStatus(), ilObjSAHSLearningModuleAccess\checkCondition(), ilObjCourse\checkLPStatusSync(), ilSoapSCORMAdministration\getSCORMCompletionStatus(), ilObjSCORMInitData\getStatus(), and ilLearningProgressBaseGUI\initEditUserForm().

550  {
551  global $ilDB;
552 
553  $set = $ilDB->query("SELECT status FROM ut_lp_marks WHERE ".
554  " status_dirty = ".$ilDB->quote(0, "integer").
555  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
556  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
557  );
558  if ($rec = $ilDB->fetchAssoc($set))
559  {
560  return $rec["status"];
561  }
562  else if((bool)$a_create)
563  {
564  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
565  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
566  $set = $ilDB->query("SELECT status FROM ut_lp_marks WHERE ".
567  " status_dirty = ".$ilDB->quote(0, "integer").
568  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
569  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
570  );
571  if ($rec = $ilDB->fetchAssoc($set))
572  {
573  return $rec["status"];
574  }
575  }
576  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
global $ilDB
+ 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 617 of file class.ilLPStatus.php.

References $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilCertificateAdapter\getUserCompletionDate().

618  {
619  global $ilDB;
620 
621  $set = $ilDB->query("SELECT status_changed FROM ut_lp_marks WHERE ".
622  " status_dirty = ".$ilDB->quote(0, "integer").
623  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
624  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
625  );
626  if ($rec = $ilDB->fetchAssoc($set))
627  {
628  return $rec["status_changed"];
629  }
630  else
631  {
632  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
633  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
634  $set = $ilDB->query("SELECT status_changed FROM ut_lp_marks WHERE ".
635  " status_dirty = ".$ilDB->quote(0, "integer").
636  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
637  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
638  );
639  if ($rec = $ilDB->fetchAssoc($set))
640  {
641  return $rec["status_changed"];
642  }
643  }
644  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
global $ilDB
+ 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 654 of file class.ilLPStatus.php.

References $ilDB, and $res.

655  {
656  global $ilDB;
657 
658  $sql = "SELECT usr_id, status, status_dirty FROM ut_lp_marks".
659  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer").
660  " AND status = ".$ilDB->quote($a_status, "integer");
661  if($a_user_ids)
662  {
663  $sql .= " AND ".$ilDB->in("usr_id", $a_user_ids, "", "integer");
664  }
665 
666  $set = $ilDB->query($sql);
667  $res = array();
668  while($rec = $ilDB->fetchAssoc($set))
669  {
670  if($res["status_dirty"])
671  {
672  // update status and check again
673  if(self::_lookupStatus($a_obj_id, $rec["usr_id"]) != $a_status)
674  {
675  continue;
676  }
677  }
678  $res[] = $rec["usr_id"];
679  }
680 
681  return $res;
682  }
global $ilDB

◆ _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 – ilConditionHandlerGUI->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 $ilDB, $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)
global $ilDB
$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 811 of file class.ilLPStatus.php.

Referenced by ilObjectListGUI\insertProperties().

812  {
813  return self::$list_gui_cache[$a_obj_id];
814  }
+ Here is the caller graph for this function:

◆ ilLPStatus()

ilLPStatus::ilLPStatus (   $a_obj_id)

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

References $ilDB.

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

◆ preloadListGUIData()

static ilLPStatus::preloadListGUIData (   $a_obj_ids)
static

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

References $ilDB, $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().

721  {
722  global $ilDB, $ilUser, $lng;
723 
724  $res = array();
725 
726  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
727  if($ilUser->getId() != ANONYMOUS_USER_ID &&
731  {
732  include_once "Services/Object/classes/class.ilObjectLP.php";
733 
734  // validate objects
735  $valid = array();
736  $existing = ilLPObjSettings::_lookupDBModeForObjects($a_obj_ids);
737  foreach($existing as $obj_id => $obj_mode)
738  {
739  if($obj_mode != ilLPObjSettings::LP_MODE_DEACTIVATED)
740  {
742  }
743  }
744 
745  if(sizeof($existing) != sizeof($a_obj_ids))
746  {
747  // missing objects (default mode)
748  foreach(array_diff($a_obj_ids, $existing) as $obj_id)
749  {
750  $olp = ilObjectLP::getInstance($obj_id);
751  $mode = $olp->getCurrentMode();
753  {
754  // #11141
755  unset($valid[$obj_id]);
756  }
757  else if($mode != ilLPObjSettings::LP_MODE_UNDEFINED)
758  {
760  }
761  }
762  unset($existing);
763  }
764 
765  $valid = array_values($valid);
766 
767  // get user lp data
768  $sql = "SELECT status, status_dirty, obj_id FROM ut_lp_marks".
769  " WHERE ".$ilDB->in("obj_id", $valid, "", "integer").
770  " AND usr_id = ".$ilDB->quote($ilUser->getId(), "integer");
771  $set = $ilDB->query($sql);
772  while($row = $ilDB->fetchAssoc($set))
773  {
774  if(!$row["status_dirty"])
775  {
776  $res[$row["obj_id"]] = $row["status"];
777  }
778  else
779  {
780  $res[$row["obj_id"]] = self::_lookupStatus($row["obj_id"], $ilUser->getId());
781  }
782  }
783 
784  // process missing user entries (same as dirty entries, see above)
785  foreach($valid as $obj_id)
786  {
787  if(!isset($res[$obj_id]))
788  {
789  $res[$obj_id] = self::_lookupStatus($obj_id, $ilUser->getId());
790  if($res[$obj_id] === null)
791  {
792  $res[$obj_id] = self::LP_STATUS_NOT_ATTEMPTED_NUM;
793  }
794  }
795  }
796 
797  // value to icon
798  $lng->loadLanguageModule("trac");
799  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
800  foreach($res as $obj_id => $status)
801  {
804  $res[$obj_id] = ilUtil::img($path, $text);
805  }
806  }
807 
808  self::$list_gui_cache = $res;
809  }
$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)
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
global $ilDB
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 516 of file class.ilLPStatus.php.

References $ilDB.

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

◆ setDirty()

static ilLPStatus::setDirty (   $a_obj_id)
static

Sets status of an object to dirty.

Parameters
integerobject id
Returns

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

References $ilDB.

533  {
534  global $ilDB;
535 
536  $ilDB->manipulate("UPDATE ut_lp_marks SET ".
537  " status_dirty = ".$ilDB->quote(1, "integer").
538  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")
539  );
540  }
global $ilDB

◆ 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 477 of file class.ilLPStatus.php.

References $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilLearningProgress\_tracProgress().

478  {
479  global $ilDB;
480 
481  // #11513
482 
483  $needs_update = false;
484 
485  $set = $ilDB->query("SELECT usr_id, status FROM ut_lp_marks WHERE ".
486  " obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
487  " usr_id = ".$ilDB->quote($a_user_id, "integer")
488  );
489  if ($rec = $ilDB->fetchAssoc($set))
490  {
491  // current status is not attempted, so we need to update
492  if($rec["status"] == self::LP_STATUS_NOT_ATTEMPTED_NUM)
493  {
494  $needs_update = true;
495  }
496  }
497  else
498  {
499  // no ut_lp_marks yet, we should update
500  $needs_update = true;
501  }
502 
503  if($needs_update)
504  {
505  require_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
506  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
507  }
508  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
global $ilDB
+ 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 $ilDB, $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  /*
408  $ilDB->manipulate("INSERT INTO ut_lp_marks ".
409  "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
410  $ilDB->quote($a_status, "integer").",".
411  $ilDB->now().",".
412  $ilDB->quote($a_user_id, "integer").",".
413  $ilDB->quote($a_obj_id, "integer").",".
414  $ilDB->quote(0, "integer").
415  ")");
416  */
417 
418  // #13783
419  $ilDB->replace("ut_lp_marks",
420  array(
421  "obj_id" => array("integer", $a_obj_id),
422  "usr_id" => array("integer", $a_user_id)
423  ),
424  array(
425  "status" => array("integer", $a_status),
426  "status_changed" => array("timestamp", date("Y-m-d H:i:s")), // was $ilDB->now()
427  "status_dirty" => array("integer", 0)
428  )
429  );
430 
431  $update_collections = true;
432  }
433 
434  // update percentage
435  if ($a_percentage !== false || $a_force_per)
436  {
437  $a_percentage = max(0, (int) $a_percentage);
438  $a_percentage = min(100, $a_percentage);
439  $ret = $ilDB->manipulate("UPDATE ut_lp_marks SET ".
440  " percentage = ".$ilDB->quote($a_percentage, "integer").
441  " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
442  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
443  );
444  }
445 
446  // update collections
447  if ($update_collections)
448  {
449  // a change occured - remove existing cache entry
450  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
451  ilLPStatusWrapper::_removeStatusCache($a_obj_id, $a_user_id);
452 
453  $set = $ilDB->query("SELECT ut_lp_collections.obj_id obj_id FROM ".
454  "object_reference JOIN ut_lp_collections ON ".
455  "(object_reference.obj_id = ".$ilDB->quote($a_obj_id, "integer").
456  " AND object_reference.ref_id = ut_lp_collections.item_id)");
457  while ($rec = $ilDB->fetchAssoc($set))
458  {
459  if (in_array(ilObject::_lookupType($rec["obj_id"]), array("crs", "grp", "fold")))
460  {
461  // just to make sure - remove existing cache entry
462  ilLPStatusWrapper::_removeStatusCache($rec["obj_id"], $a_user_id);
463 
464  ilLPStatusWrapper::_updateStatus($rec["obj_id"], $a_user_id);
465  }
466  }
467  }
468 
469  return $update_collections;
470  }
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)
global $ilDB
+ 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: