ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLPStatusSCORMPackage.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=0);
20 
22 {
23  public static function _getInProgress(int $a_obj_id): array
24  {
25  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
26  $users = $status_info['in_progress'];
27  return array_unique($users);
28  }
29 
30  public static function _getCompleted(int $a_obj_id): array
31  {
32  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
33  $users = $status_info['completed'];
34  return array_unique($users);
35  }
36 
37  public static function _getFailed(int $a_obj_id): array
38  {
39  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
40  $users = $status_info['failed'];
41  return array_unique($users);
42  }
43 
44  public static function _getStatusInfo(int $a_obj_id): array
45  {
46  $status_info['subtype'] = "scorm2004";
47  $info = ilSCORM2004Tracking::_getProgressInfo($a_obj_id);
48 
49  $status_info['completed'] = $info['completed'];
50  $status_info['failed'] = $info['failed'];
51  $status_info['in_progress'] = $info['in_progress'];
52 
53  return $status_info;
54  }
55 
63  public function determineStatus(
64  int $a_obj_id,
65  int $a_usr_id,
66  ?object $a_obj = null
67  ): int {
68  global $DIC;
69 
70  $ilObjDataCache = $DIC['ilObjDataCache'];
71  $ilDB = $DIC['ilDB'];
72  $ilLog = $DIC['ilLog'];
73 
75  $a_obj_id,
76  $a_usr_id
77  );
78  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
79  switch ($scorm_status) {
80  case "in_progress":
81  $status = self::LP_STATUS_IN_PROGRESS_NUM;
82  break;
83  case "completed":
84  $status = self::LP_STATUS_COMPLETED_NUM;
85  break;
86  case "failed":
87  $status = self::LP_STATUS_FAILED_NUM;
88  break;
89  }
90 
91  return $status;
92  }
93 
94  public function refreshStatus(int $a_obj_id, ?array $a_users = null): void
95  {
96  parent::refreshStatus($a_obj_id, $a_users);
97 
98  $in_progress = ilLPStatusWrapper::_getInProgress($a_obj_id);
99  $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
100  $failed = ilLPStatusWrapper::_getFailed($a_obj_id);
101  $all_active_users = array_unique(
102  array_merge($in_progress, $completed, $failed)
103  );
104 
105  // get all tracked users regardless of SCOs
106  $all_tracked_users = ilSCORM2004Tracking::_getTrackedUsers($a_obj_id);
107 
108  $not_attempted_users = array_diff(
109  $all_tracked_users,
110  $all_active_users
111  );
112  unset($all_tracked_users);
113  unset($all_active_users);
114 
115  // reset all users which have no data for the current SCOs
116  if ($not_attempted_users) {
117  foreach ($not_attempted_users as $usr_id) {
118  // this will update any (parent) collections if necessary
120  $a_obj_id,
121  $usr_id,
122  self::LP_STATUS_NOT_ATTEMPTED_NUM,
123  0
124  );
125  }
126  }
127  }
128 
129  public function determinePercentage(
130  int $a_obj_id,
131  int $a_usr_id,
132  ?object $a_obj = null
133  ): int {
134  return 0;//todo!
135  }
136 }
static _getProgressInfoOfUser(int $a_obj_id, int $a_user_id)
Get overall scorm status.
static _getProgressInfo(int $a_obj_id)
Get overall scorm status.
refreshStatus(int $a_obj_id, ?array $a_users=null)
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
static _getTrackedUsers(int $a_obj_id)
Get all tracked users.
static _getInProgress(int $a_obj_id)
Static function to read users who have the status &#39;in_progress&#39;.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getFailed(int $a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
global $DIC
Definition: shib_login.php:22
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
Determine status.
ilObjectDataCache $ilObjDataCache
static _getInProgress(int $a_obj_id)
determinePercentage(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _getStatusInfo(int $a_obj_id)
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.