ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLPStatusFactory Class Reference

Class ilLPStatusFactory Creates status class instances for learning progress modes of an object. More...

+ Collaboration diagram for ilLPStatusFactory:

Static Public Member Functions

static _getClassById (int $a_obj_id, ?int $a_mode=null)
 
static _getClassByIdAndType (int $a_obj_id, string $a_type)
 
static _getInstance (int $a_obj_id, ?int $a_mode=null)
 

Private Member Functions

 __construct ()
 
 getLogger ()
 

Static Private Member Functions

static getFactoryInstance ()
 

Private Attributes

ilLogger $logger
 

Static Private Attributes

static self $instance = null
 
static array $class_by_obj_id = array()
 

Detailed Description

Class ilLPStatusFactory Creates status class instances for learning progress modes of an object.

E.g obj_id of course returns an instance of ilLPStatusManual, ilLPStatusObjectives ...

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

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

Constructor & Destructor Documentation

◆ __construct()

ilLPStatusFactory::__construct ( )
private

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

References $DIC, and ILIAS\Repository\logger().

30  {
31  global $DIC;
32 
33  $this->logger = $DIC->logger()->trac();
34  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ _getClassById()

static ilLPStatusFactory::_getClassById ( int  $a_obj_id,
?int  $a_mode = null 
)
static

Definition at line 41 of file class.ilLPStatusFactory.php.

References $factory, $message, ilLogLevel\ERROR, ilLPObjSettings\getClassMap(), ilObjectLP\getInstance(), and ilLPObjSettings\LP_MODE_UNDEFINED.

Referenced by ilLPStatusWrapper\_getCompleted(), ilLPStatusWrapper\_getFailed(), ilLPStatusWrapper\_getInProgress(), ilLPStatusWrapper\_getNotAttempted(), ilLPStatusWrapper\_getStatusInfo(), ilLPStatusWrapper\_getTypicalLearningTime(), ilLPStatusWrapper\_lookupCompletedForObject(), ilLPStatusWrapper\_lookupFailedForObject(), ilLPStatusWrapper\_lookupInProgressForObject(), ilLMExplorerGUI\checkLPIcon(), ilTrQuery\getParticipantsForObject(), ilLearningProgressGUI\initCollectionManualForm(), ilLearningProgressGUI\showtlt(), and ilLearningProgressGUI\updateManual().

44  : string {
45  if ($a_mode === null) {
46  $olp = ilObjectLP::getInstance($a_obj_id);
47  $a_mode = $olp->getCurrentMode();
48 
49  // please keep the cache in this if-block, otherwise default values
50  if (isset(self::$class_by_obj_id[$a_obj_id])) {
51  return self::$class_by_obj_id[$a_obj_id];
52  }
53  }
54 
56 
57  if (array_key_exists($a_mode, $map)) {
58  $class = $map[$a_mode];
59 
60  // undefined? try object lp directly
61  if ($class === null) {
62  $olp = ilObjectLP::getInstance($a_obj_id);
63  $mode = $olp->getCurrentMode();
65  return self::_getClassById($a_obj_id, $mode);
66  }
67  } else {
68  self::$class_by_obj_id[$a_obj_id] = $class;
69  return $class;
70  }
71  }
72 
73  $factory = self::getFactoryInstance();
74  $message = 'Unknown LP mode given: ' . $a_mode;
75  $factory->getLogger()->logStack(ilLogLevel::ERROR, $message);
77  }
$message
Definition: xapiexit.php:32
static getInstance(int $obj_id)
$factory
Definition: metadata.php:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getClassByIdAndType()

static ilLPStatusFactory::_getClassByIdAndType ( int  $a_obj_id,
string  $a_type 
)
static

Definition at line 79 of file class.ilLPStatusFactory.php.

References $factory, $message, and ilLogLevel\ERROR.

Referenced by ilLPStatusWrapper\_getCompletedByType(), ilLPStatusWrapper\_getFailedByType(), ilLPStatusWrapper\_getInProgressByType(), ilLPStatusWrapper\_getNotAttemptedByType(), and ilLPStatusWrapper\_getStatusInfoByType().

82  : string {
83  // id is ignored in the moment
84  switch ($a_type) {
85  case 'event':
86  return 'ilLPStatusEvent';
87 
88  default:
89  $factory = self::getFactoryInstance();
90  $message = 'Unknown LP type given: ' . $a_type;
91  $factory->getLogger()->logStack(ilLogLevel::ERROR, $message);
93  }
94  }
$message
Definition: xapiexit.php:32
$factory
Definition: metadata.php:75
+ Here is the caller graph for this function:

◆ _getInstance()

static ilLPStatusFactory::_getInstance ( int  $a_obj_id,
?int  $a_mode = null 
)
static

Definition at line 96 of file class.ilLPStatusFactory.php.

References $factory, $message, ilLogLevel\ERROR, ilLPObjSettings\getClassMap(), ilObjectLP\getInstance(), and ilLPObjSettings\LP_MODE_UNDEFINED.

Referenced by ilLPStatusWrapper\_determineStatus(), ilLPStatusWrapper\_refreshStatus(), ilLPStatusWrapper\_setDirty(), ilLPStatusWrapper\_updateStatus(), ilLPStatus\checkStatusForObject(), ilTrQuery\getObjectIds(), and ilTestLP\resetCustomLPDataForUserIds().

99  : ilLPStatus {
100  if ($a_mode === null) {
101  $olp = ilObjectLP::getInstance($a_obj_id);
102  $a_mode = $olp->getCurrentMode();
103  }
104 
106 
107  if (array_key_exists($a_mode, $map)) {
108  $class = $map[$a_mode];
109 
110  // undefined? try object lp directly
111  if ($class === null) {
112  $olp = ilObjectLP::getInstance($a_obj_id);
113  $mode = $olp->getCurrentMode();
114  if ($mode != ilLPObjSettings::LP_MODE_UNDEFINED) {
115  return self::_getInstance($a_obj_id, $mode);
116  }
117  } else {
118  return new $class($a_obj_id);
119  }
120  }
121 
122  $factory = self::getFactoryInstance();
123  $message = 'Unknown LP mode given: ' . $a_mode;
124  $factory->getLogger()->logStack(ilLogLevel::ERROR, $message);
126  }
$message
Definition: xapiexit.php:32
static getInstance(int $obj_id)
$factory
Definition: metadata.php:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFactoryInstance()

static ilLPStatusFactory::getFactoryInstance ( )
staticprivate

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

22  {
23  if (!self::$instance) {
24  self::$instance = new self();
25  }
26  return self::$instance;
27  }
Class ilLPStatusFactory Creates status class instances for learning progress modes of an object...

◆ getLogger()

ilLPStatusFactory::getLogger ( )
private

Definition at line 36 of file class.ilLPStatusFactory.php.

References $logger.

36  : ilLogger
37  {
38  return $this->logger;
39  }

Field Documentation

◆ $class_by_obj_id

array ilLPStatusFactory::$class_by_obj_id = array()
staticprivate

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

◆ $instance

self ilLPStatusFactory::$instance = null
staticprivate

Definition at line 16 of file class.ilLPStatusFactory.php.

◆ $logger

ilLogger ilLPStatusFactory::$logger
private

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

Referenced by getLogger().


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