ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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_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...
 
static validateLPForObjects ($a_user_id, $a_obj_ids, $a_parent_ref_id)
 Process given objects for lp-relevance. More...
 
static checkLPModesForObjects ($a_obj_ids, array &$a_coll_obj_ids)
 Process lp modes for given objects. More...
 
static getLPStatusForObjects ($a_user_id, $a_obj_ids)
 Get LP status for given objects (and user) 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 605 of file class.ilLPStatus.php.

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

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

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

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

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

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

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

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

References $ilDB.

Referenced by ilLearningProgressBaseGUI\__appendLPDetails(), and ilObjSCORMLearningModule\importRaw().

584  {
585  global $ilDB;
586 
587  $set = $ilDB->query("SELECT percentage FROM ut_lp_marks WHERE ".
588  " status_dirty = ".$ilDB->quote(0, "integer").
589  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
590  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
591  );
592  if ($rec = $ilDB->fetchAssoc($set))
593  {
594  return $rec["percentage"];
595  }
596  }
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 548 of file class.ilLPStatus.php.

References $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilLearningProgressBaseGUI\__readStatus(), ilObjSAHSLearningModuleAccess\checkCondition(), ilObjCourse\checkLPStatusSync(), ilCourseMailTemplateTutorContext\getDescription(), ilScormMailTemplateLPContext\getDescription(), ilSoapSCORMAdministration\getSCORMCompletionStatus(), ilObjSCORMInitData\getStatus(), ilObjSCORMLearningModule\importRaw(), and ilLearningProgressBaseGUI\initEditUserForm().

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

References $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilCertificateAdapter\getUserCompletionDate().

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

References $ilDB, and $res.

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

◆ _updateStatus()

ilLPStatus::_updateStatus (   $a_obj_id,
  $a_usr_id,
  $a_obj = null,
  $a_percentage = 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($changed || (bool)$a_force_raise) // #15529
205  {
206  self::raiseEvent($a_obj_id, $a_usr_id, $status, $percentage);
207  }
208  }
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:

◆ checkLPModesForObjects()

static ilLPStatus::checkLPModesForObjects (   $a_obj_ids,
array &  $a_coll_obj_ids 
)
staticprotected

Process lp modes for given objects.

Parameters
array$a_obj_ids
Returns
array

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

References $obj_id, $valid, ilLPObjSettings\_lookupDBModeForObjects(), ilLPCollection\getCollectionModes(), ilObjectLP\getInstance(), ilLPObjSettings\LP_MODE_DEACTIVATED, and ilLPObjSettings\LP_MODE_UNDEFINED.

756  {
757  $valid = array();
758 
759  // all lp modes with collections (gathered separately)
760  include_once "Services/Tracking/classes/collection/class.ilLPCollection.php";
761  $coll_modes = ilLPCollection::getCollectionModes();
762 
763  include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
764 
765  // check if objects have LP activated at all (DB entries)
766  $existing = ilLPObjSettings::_lookupDBModeForObjects($a_obj_ids);
767  foreach($existing as $obj_id => $obj_mode)
768  {
769  if($obj_mode != ilLPObjSettings::LP_MODE_DEACTIVATED)
770  {
772 
773  if(in_array($obj_mode, $coll_modes))
774  {
775  $a_coll_obj_ids[] = $obj_id;
776  }
777  }
778  }
779 
780  // missing objects in DB (default mode)
781  include_once "Services/Object/classes/class.ilObjectLP.php";
782  if(sizeof($existing) != sizeof($a_obj_ids))
783  {
784  foreach(array_diff($a_obj_ids, $existing) as $obj_id)
785  {
786  $olp = ilObjectLP::getInstance($obj_id);
787  $mode = $olp->getCurrentMode();
789  {
790  // #11141
791  unset($valid[$obj_id]);
792  }
793  else if($mode != ilLPObjSettings::LP_MODE_UNDEFINED)
794  {
796 
797  if(in_array($mode, $coll_modes))
798  {
799  $a_coll_obj_ids[] = $obj_id;
800  }
801  }
802  }
803  unset($existing);
804  }
805 
806  return array_values($valid);
807  }
$valid
static _lookupDBModeForObjects(array $a_obj_ids)
static getInstance($a_obj_id)
+ 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 240 of file class.ilLPStatus.php.

References $ilDB, $r, and ilLPStatusFactory\_getInstance().

Referenced by ilTrQuery\refreshObjectsStatus().

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

Referenced by _updateStatus(), and refreshStatus().

217  {
218  return false;
219  }
+ 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 227 of file class.ilLPStatus.php.

Referenced by ilLPStatusDownloaded\_getCompleted(), and _updateStatus().

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

◆ getListGUIStatus()

static ilLPStatus::getListGUIStatus (   $a_obj_id)
static

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

Referenced by ilObjectListGUI\insertProperties().

901  {
902  return self::$list_gui_cache[$a_obj_id];
903  }
+ Here is the caller graph for this function:

◆ getLPStatusForObjects()

static ilLPStatus::getLPStatusForObjects (   $a_user_id,
  $a_obj_ids 
)
staticprotected

Get LP status for given objects (and user)

Parameters
int$a_user_id
array$a_obj_ids
Returns
array

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

References $ilDB, $obj_id, $res, and $row.

817  {
818  global $ilDB;
819 
820  $res = array();
821 
822  // get user lp data
823  $sql = "SELECT status, status_dirty, obj_id FROM ut_lp_marks".
824  " WHERE ".$ilDB->in("obj_id", $a_obj_ids, "", "integer").
825  " AND usr_id = ".$ilDB->quote($a_user_id, "integer");
826  $set = $ilDB->query($sql);
827  while($row = $ilDB->fetchAssoc($set))
828  {
829  if(!$row["status_dirty"])
830  {
831  $res[$row["obj_id"]] = $row["status"];
832  }
833  else
834  {
835  $res[$row["obj_id"]] = self::_lookupStatus($row["obj_id"], $a_user_id);
836  }
837  }
838 
839  // process missing user entries (same as dirty entries, see above)
840  foreach($a_obj_ids as $obj_id)
841  {
842  if(!isset($res[$obj_id]))
843  {
844  $res[$obj_id] = self::_lookupStatus($obj_id, $a_user_id);
845  if($res[$obj_id] === null)
846  {
847  $res[$obj_id] = self::LP_STATUS_NOT_ATTEMPTED_NUM;
848  }
849  }
850  }
851 
852  return $res;
853  }
global $ilDB

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

References $_GET, $ilUser, $lng, $obj_id, $path, $res, $text, ilObjUserTracking\_enabledLearningProgress(), ilLearningProgressBaseGUI\_getImagePathForStatus(), ilLearningProgressBaseGUI\_getStatusText(), ilObjUserTracking\_hasLearningProgressLearner(), ilObjUserTracking\_hasLearningProgressListGUI(), and ilUtil\img().

Referenced by ilObjectListGUIPreloader\preload().

856  {
857  global $ilUser, $lng;
858 
859  $user_id = $ilUser->getId();
860 
861  $res = array();
862 
863  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
864  if($ilUser->getId() != ANONYMOUS_USER_ID &&
868  {
869  // -- validate
870 
871  // :TODO: we need the parent ref id, but this is awful
872  $a_obj_ids = self::validateLPForObjects($user_id, $a_obj_ids, (int)$_GET["ref_id"]);
873 
874  // we are not handling the collections differently yet
875  $coll_obj_ids = array();
876  $a_obj_ids = self::checkLPModesForObjects($a_obj_ids, $coll_obj_ids);
877 
878 
879  // -- gather
880 
881  $res = self::getLPStatusForObjects($user_id, $a_obj_ids);
882 
883 
884  // -- render
885 
886  // value to icon
887  $lng->loadLanguageModule("trac");
888  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
889  foreach($res as $obj_id => $status)
890  {
894  }
895  }
896 
897  self::$list_gui_cache = $res;
898  }
$_GET["client_id"]
_getImagePathForStatus($a_status)
Get image path for status.
static _enabledLearningProgress()
check wether learing progress is enabled or not
_getStatusText($a_status, $a_lng=null)
Get status alt text.
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
$text
+ 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 286 of file class.ilLPStatus.php.

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

◆ refreshStatus()

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

Refresh status.

Parameters

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

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

305  {
306  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
307  $not_attempted = ilLPStatusWrapper::_getNotAttempted($a_obj_id);
308  foreach ($not_attempted as $user_id)
309  {
310  $percentage = $this->determinePercentage($a_obj_id, $user_id);
311  if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage, true))
312  {
313  self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage);
314  }
315  }
316  $in_progress = ilLPStatusWrapper::_getInProgress($a_obj_id);
317  foreach ($in_progress as $user_id)
318  {
319  $percentage = $this->determinePercentage($a_obj_id, $user_id);
320  if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage, true))
321  {
322  self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage);
323  }
324  }
325  $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
326  foreach ($completed as $user_id)
327  {
328  $percentage = $this->determinePercentage($a_obj_id, $user_id);
329  if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage, true))
330  {
331  self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage);
332  }
333  }
335  foreach ($failed as $user_id)
336  {
337  $percentage = $this->determinePercentage($a_obj_id, $user_id);
338  if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage, true))
339  {
340  self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage);
341  }
342  }
343  if($a_users)
344  {
345  $missing_users = array_diff($a_users, $not_attempted+$in_progress+$completed+$failed);
346  if($missing_users)
347  {
348  foreach ($missing_users as $user_id)
349  {
350  ilLPStatusWrapper::_updateStatus($a_obj_id, $user_id);
351  }
352  }
353  }
354  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=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 515 of file class.ilLPStatus.php.

References $ilDB.

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

◆ setDirty()

static ilLPStatus::setDirty (   $a_obj_id)
static

Sets status of an object to dirty.

Parameters
integerobject id
Returns

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

References $ilDB.

532  {
533  global $ilDB;
534 
535  $ilDB->manipulate("UPDATE ut_lp_marks SET ".
536  " status_dirty = ".$ilDB->quote(1, "integer").
537  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")
538  );
539  }
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 476 of file class.ilLPStatus.php.

References $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilLearningProgress\_tracProgress().

477  {
478  global $ilDB;
479 
480  // #11513
481 
482  $needs_update = false;
483 
484  $set = $ilDB->query("SELECT usr_id, status FROM ut_lp_marks WHERE ".
485  " obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
486  " usr_id = ".$ilDB->quote($a_user_id, "integer")
487  );
488  if ($rec = $ilDB->fetchAssoc($set))
489  {
490  // current status is not attempted, so we need to update
491  if($rec["status"] == self::LP_STATUS_NOT_ATTEMPTED_NUM)
492  {
493  $needs_update = true;
494  }
495  }
496  else
497  {
498  // no ut_lp_marks yet, we should update
499  $needs_update = true;
500  }
501 
502  if($needs_update)
503  {
504  require_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
505  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
506  }
507  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=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:

◆ validateLPForObjects()

static ilLPStatus::validateLPForObjects (   $a_user_id,
  $a_obj_ids,
  $a_parent_ref_id 
)
staticprotected

Process given objects for lp-relevance.

Parameters
int$a_user_id
array$a_obj_ids
int$a_parent_ref_id
Returns
arraye

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

References $obj_id, and ilObjectLP\getLPMemberships().

733  {
734  $lp_invalid = array();
735 
736  include_once "Services/Object/classes/class.ilObjectLP.php";
737  $memberships = ilObjectLP::getLPMemberships($a_user_id, $a_obj_ids, $a_parent_ref_id);
738  foreach($memberships as $obj_id => $status)
739  {
740  if(!$status)
741  {
742  $lp_invalid[] = $obj_id;
743  }
744  }
745 
746  return array_diff($a_obj_ids, $lp_invalid);
747  }
static getLPMemberships($a_usr_id, array $a_obj_ids, $a_parent_ref_id=null, $a_mapped_ref_ids=false)
Get all objects where given user is member (from LP POV)
+ Here is the call 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 362 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().

363  {
364  global $ilDB;
365 
366  $update_collections = false;
367 
368  // get status in DB
369  $set = $ilDB->query("SELECT usr_id,status,status_dirty FROM ut_lp_marks WHERE ".
370  " obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
371  " usr_id = ".$ilDB->quote($a_user_id, "integer")
372  );
373  $rec = $ilDB->fetchAssoc($set);
374 
375  // update
376  if ($rec)
377  {
378  // status has changed: update
379  if ($rec["status"] != $a_status)
380  {
381  $ret = $ilDB->manipulate("UPDATE ut_lp_marks SET ".
382  " status = ".$ilDB->quote($a_status, "integer").",".
383  " status_changed = ".$ilDB->now().",".
384  " status_dirty = ".$ilDB->quote(0, "integer").
385  " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
386  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
387  );
388  if ($ret != 0)
389  {
390  $update_collections = true;
391  }
392  }
393  // status has not changed: reset dirty flag
394  else if ($rec["status_dirty"])
395  {
396  $ilDB->manipulate("UPDATE ut_lp_marks SET ".
397  " status_dirty = ".$ilDB->quote(0, "integer").
398  " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
399  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
400  );
401  }
402  }
403  // insert
404  else
405  {
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  */
416 
417  // #13783
418  $ilDB->replace("ut_lp_marks",
419  array(
420  "obj_id" => array("integer", $a_obj_id),
421  "usr_id" => array("integer", $a_user_id)
422  ),
423  array(
424  "status" => array("integer", $a_status),
425  "status_changed" => array("timestamp", date("Y-m-d H:i:s")), // was $ilDB->now()
426  "status_dirty" => array("integer", 0)
427  )
428  );
429 
430  $update_collections = true;
431  }
432 
433  // update percentage
434  if ($a_percentage !== false || $a_force_per)
435  {
436  $a_percentage = max(0, (int) $a_percentage);
437  $a_percentage = min(100, $a_percentage);
438  $ret = $ilDB->manipulate("UPDATE ut_lp_marks SET ".
439  " percentage = ".$ilDB->quote($a_percentage, "integer").
440  " WHERE usr_id = ".$ilDB->quote($a_user_id, "integer").
441  " AND obj_id = ".$ilDB->quote($a_obj_id, "integer")
442  );
443  }
444 
445  // update collections
446  if ($update_collections)
447  {
448  // a change occured - remove existing cache entry
449  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
450  ilLPStatusWrapper::_removeStatusCache($a_obj_id, $a_user_id);
451 
452  $set = $ilDB->query("SELECT ut_lp_collections.obj_id obj_id FROM ".
453  "object_reference JOIN ut_lp_collections ON ".
454  "(object_reference.obj_id = ".$ilDB->quote($a_obj_id, "integer").
455  " AND object_reference.ref_id = ut_lp_collections.item_id)");
456  while ($rec = $ilDB->fetchAssoc($set))
457  {
458  if (in_array(ilObject::_lookupType($rec["obj_id"]), array("crs", "grp", "fold")))
459  {
460  // just to make sure - remove existing cache entry
461  ilLPStatusWrapper::_removeStatusCache($rec["obj_id"], $a_user_id);
462 
463  ilLPStatusWrapper::_updateStatus($rec["obj_id"], $a_user_id);
464  }
465  }
466  }
467 
468  return $update_collections;
469  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=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

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