ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLPStatusTestPassed Class Reference
+ Inheritance diagram for ilLPStatusTestPassed:
+ Collaboration diagram for ilLPStatusTestPassed:

Public Member Functions

 determineStatus (int $a_obj_id, int $a_usr_id, object $a_obj=null)
 
 determinePercentage (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
- Public Member Functions inherited from ilLPStatus
 __construct (int $a_obj_id)
 
 _updateStatus (int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
 New status handling (st: status, nr: accesses, p: percentage, t: time spent, m: mark) Learning progress: More...
 
 determinePercentage (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
 determineStatus (int $a_obj_id, int $a_usr_id, object $a_obj=null)
 
 refreshStatus (int $a_obj_id, ?array $a_users=null)
 Refresh status. More...
 

Static Public Member Functions

static _getInProgress (int $a_obj_id)
 
static _getCompleted (int $a_obj_id)
 
static _getNotAttempted (int $a_obj_id)
 
static _getFailed (int $a_obj_id)
 
static _getStatusInfo (int $a_obj_id)
 
- Static Public Member Functions inherited from ilLPStatus
static _getCountNotAttempted (int $a_obj_id)
 
static _getNotAttempted (int $a_obj_id)
 
static _getCountInProgress (int $a_obj_id)
 
static _getInProgress (int $a_obj_id)
 
static _getCountCompleted (int $a_obj_id)
 
static _getCompleted (int $a_obj_id)
 
static _getFailed (int $a_obj_id)
 
static _getCountFailed (int $a_obj_id)
 
static _getStatusInfo (int $a_obj_id)
 
static _getTypicalLearningTime (int $a_obj_id)
 
static checkStatusForObject (int $a_obj_id, ?array $a_users=null)
 This function checks whether the status for a given number of users is dirty and must be recalculated. More...
 
static writeStatus (int $a_obj_id, int $a_user_id, int $a_status, int $a_percentage=0, bool $a_force_per=false, ?int &$a_old_status=self::LP_STATUS_NOT_ATTEMPTED_NUM)
 Write status for user and object. More...
 
static setInProgressIfNotAttempted (int $a_obj_id, int $a_user_id)
 This function shoudl be clalled for normal "read events". More...
 
static setAllDirty ()
 Sets all status to dirty. More...
 
static setDirty (int $a_obj_id)
 Sets status of an object to dirty. More...
 
static _lookupStatus (int $a_obj_id, int $a_user_id, bool $a_create=true)
 Lookup status. More...
 
static _lookupPercentage (int $a_obj_id, int $a_user_id)
 Lookup percentage. More...
 
static _hasUserCompleted (int $a_obj_id, int $a_user_id)
 Lookup user object completion. More...
 
static _lookupStatusChanged (int $a_obj_id, int $a_user_id)
 Lookup status changed. More...
 
static _lookupCompletedForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get completed users for object. More...
 
static _lookupFailedForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get failed users for object. More...
 
static _lookupInProgressForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get in progress users for object. More...
 
static preloadListGUIData (array $a_obj_ids)
 
static getListGUIStatus (int $a_obj_id, bool $a_image_only=true)
 
static hasListGUIStatus (int $a_obj_id)
 

Protected Member Functions

 determineStatusForScoreLastPassTests (bool $is_finished, bool $passed)
 
 determineLpStatus (bool $passed)
 

Static Private Member Functions

static getUserIdsByResultArrayStatus ( $objId, $resultArrayStatus)
 

Additional Inherited Members

- Data Fields inherited from ilLPStatus
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 inherited from ilLPStatus
static $list_gui_cache
 
- Static Protected Member Functions inherited from ilLPStatus
static raiseEvent (int $a_obj_id, int $a_usr_id, int $a_status, int $a_old_status, int $a_percentage)
 
static _lookupStatusForObject (int $a_obj_id, int $a_status, ?array $a_user_ids=null)
 Get users with given status for object. More...
 
static validateLPForObjects (int $a_user_id, array $a_obj_ids, int $a_parent_ref_id)
 Process given objects for lp-relevance. More...
 
static checkLPModesForObjects (array $a_obj_ids, array &$a_coll_obj_ids)
 Process lp modes for given objects. More...
 
static getLPStatusForObjects (int $a_user_id, array $a_obj_ids)
 Get LP status for given objects (and user) More...
 
- Protected Attributes inherited from ilLPStatus
int $obj_id
 
ilDBInterface $db
 
ilObjectDataCache $ilObjDataCache
 

Detailed Description

Definition at line 25 of file class.ilLPStatusTestPassed.php.

Member Function Documentation

◆ _getCompleted()

static ilLPStatusTestPassed::_getCompleted ( int  $a_obj_id)
static

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

36  : array
37  {
38  $userIds = self::getUserIdsByResultArrayStatus($a_obj_id, 'passed');
39  return $userIds;
40  }

◆ _getFailed()

static ilLPStatusTestPassed::_getFailed ( int  $a_obj_id)
static

Definition at line 47 of file class.ilLPStatusTestPassed.php.

47  : array
48  {
49  return self::getUserIdsByResultArrayStatus($a_obj_id, 'failed');
50  }

◆ _getInProgress()

static ilLPStatusTestPassed::_getInProgress ( int  $a_obj_id)
static

Definition at line 27 of file class.ilLPStatusTestPassed.php.

27  : array
28  {
29  $userIds = self::getUserIdsByResultArrayStatus(
30  $a_obj_id,
31  'in_progress'
32  );
33  return $userIds;
34  }

◆ _getNotAttempted()

static ilLPStatusTestPassed::_getNotAttempted ( int  $a_obj_id)
static

Definition at line 42 of file class.ilLPStatusTestPassed.php.

42  : array
43  {
44  return self::getUserIdsByResultArrayStatus($a_obj_id, 'not_attempted');
45  }

◆ _getStatusInfo()

static ilLPStatusTestPassed::_getStatusInfo ( int  $a_obj_id)
static

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

References ilObjTestAccess\_getPassedUsers().

69  : array
70  {
71  $status_info['results'] = ilObjTestAccess::_getPassedUsers($a_obj_id);
72  return $status_info;
73  }
static _getPassedUsers($a_obj_id)
Returns an array containing the users who passed the test.
+ Here is the call graph for this function:

◆ determineLpStatus()

ilLPStatusTestPassed::determineLpStatus ( bool  $passed)
protected

Definition at line 151 of file class.ilLPStatusTestPassed.php.

Referenced by determineStatus(), and determineStatusForScoreLastPassTests().

151  : int
152  {
153  $status = self::LP_STATUS_FAILED_NUM;
154 
155  if ($passed) {
156  $status = self::LP_STATUS_COMPLETED_NUM;
157  }
158 
159  return $status;
160  }
+ Here is the caller graph for this function:

◆ determinePercentage()

ilLPStatusTestPassed::determinePercentage ( int  $a_obj_id,
int  $a_usr_id,
?object  $a_obj = null 
)

Definition at line 162 of file class.ilLPStatusTestPassed.php.

166  : int {
167  $set = $this->db->query(
168  "SELECT tst_result_cache.*, tst_active.user_fi FROM " .
169  "tst_result_cache JOIN tst_active ON (tst_active.active_id = tst_result_cache.active_fi)" .
170  " JOIN tst_tests ON (tst_tests.test_id = tst_active.test_fi) " .
171  " WHERE tst_tests.obj_fi = " . $this->db->quote(
172  $a_obj_id,
173  "integer"
174  ) .
175  " AND tst_active.user_fi = " . $this->db->quote(
176  $a_usr_id,
177  "integer"
178  )
179  );
180  $per = 0;
181  if ($rec = $this->db->fetchAssoc($set)) {
182  if ($rec["max_points"] > 0) {
183  $per = min(
184  100,
185  100 / $rec["max_points"] * $rec["reached_points"]
186  );
187  } else {
188  // According to mantis #12305
189  $per = 0;
190  }
191  }
192  return (int) $per;
193  }

◆ determineStatus()

ilLPStatusTestPassed::determineStatus ( int  $a_obj_id,
int  $a_usr_id,
object  $a_obj = null 
)

Definition at line 75 of file class.ilLPStatusTestPassed.php.

References $res, ilObjTestAccess\_isPassed(), ilLPStatus\_lookupStatus(), determineLpStatus(), determineStatusForScoreLastPassTests(), SCORE_BEST_PASS, and SCORE_LAST_PASS.

79  : int {
80  $old_status = ilLPStatus::_lookupStatus($a_obj_id, $a_usr_id, false);
81  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
82 
83  $res = $this->db->query(
84  "
85  SELECT tst_active.active_id, tst_active.tries, count(tst_sequence.active_fi) " . $this->db->quoteIdentifier(
86  "sequences"
87  ) . ", tst_active.last_finished_pass,
88  CASE WHEN
89  (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass
90  THEN '1'
91  ELSE '0'
92  END is_last_pass
93  FROM tst_active
94  LEFT JOIN tst_sequence
95  ON tst_sequence.active_fi = tst_active.active_id
96  LEFT JOIN tst_tests
97  ON tst_tests.test_id = tst_active.test_fi
98  WHERE tst_active.user_fi = {$this->db->quote($a_usr_id, "integer")}
99  AND tst_active.test_fi = {$this->db->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id), ilDBConstants::T_INTEGER)}
100  GROUP BY tst_active.active_id, tst_active.tries, is_last_pass
101  "
102  );
103 
104  if (
105  ($rec = $this->db->fetchAssoc($res))
106  && $rec['sequences'] > 0
107  ) {
108  $test_obj = new ilObjTest($a_obj_id, false);
109  $is_passed = ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
110 
111  if ($test_obj->getPassScoring() === SCORE_LAST_PASS) {
112  $is_finished = false;
113  if ($rec['last_finished_pass'] !== null && $rec['sequences'] - 1 == $rec['last_finished_pass']) {
114  $is_finished = true;
115  }
116  $status = $this->determineStatusForScoreLastPassTests(
117  $is_finished,
118  $is_passed
119  );
120  } elseif ($test_obj->getPassScoring() === SCORE_BEST_PASS) {
121  $status = self::LP_STATUS_IN_PROGRESS_NUM;
122 
123  if ($rec['last_finished_pass'] !== null) {
124  $status = $this->determineLpStatus($is_passed);
125  }
126  }
127  }
128 
129  if ($old_status !== null
130  && $old_status !== self::LP_STATUS_NOT_ATTEMPTED_NUM
131  && $status === self::LP_STATUS_IN_PROGRESS_NUM) {
132  return $old_status;
133  }
134 
135  return $status;
136  }
$res
Definition: ltiservices.php:69
const SCORE_LAST_PASS
static _isPassed($user_id, $a_obj_id)
Returns TRUE if the user with the user id $user_id passed the test with the object id $a_obj_id...
determineStatusForScoreLastPassTests(bool $is_finished, bool $passed)
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
const SCORE_BEST_PASS
+ Here is the call graph for this function:

◆ determineStatusForScoreLastPassTests()

ilLPStatusTestPassed::determineStatusForScoreLastPassTests ( bool  $is_finished,
bool  $passed 
)
protected

Definition at line 138 of file class.ilLPStatusTestPassed.php.

References determineLpStatus().

Referenced by determineStatus().

141  : int {
142  $status = self::LP_STATUS_IN_PROGRESS_NUM;
143 
144  if ($is_finished) {
145  $status = $this->determineLpStatus($passed);
146  }
147 
148  return $status;
149  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserIdsByResultArrayStatus()

static ilLPStatusTestPassed::getUserIdsByResultArrayStatus (   $objId,
  $resultArrayStatus 
)
staticprivate

Definition at line 52 of file class.ilLPStatusTestPassed.php.

References $objId, ilLPStatusWrapper\_getStatusInfo(), and ILIAS\Repository\int().

55  {
57 
58  $user_ids = array();
59 
60  foreach ($status_info['results'] as $user_data) {
61  if (isset($user_data[$resultArrayStatus]) && $user_data[$resultArrayStatus]) {
62  $user_ids[] = (int) $user_data['user_id'];
63  }
64  }
65 
66  return $user_ids;
67  }
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
$objId
Definition: xapitoken.php:57
+ Here is the call graph for this function:

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