ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLPStatusSCORMPackage.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=0);
4 
5 /*
6  +-----------------------------------------------------------------------------+
7  | ILIAS open source |
8  +-----------------------------------------------------------------------------+
9  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
10  | |
11  | This program is free software; you can redistribute it and/or |
12  | modify it under the terms of the GNU General Public License |
13  | as published by the Free Software Foundation; either version 2 |
14  | of the License, or (at your option) any later version. |
15  | |
16  | This program is distributed in the hope that it will be useful, |
17  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19  | GNU General Public License for more details. |
20  | |
21  | You should have received a copy of the GNU General Public License |
22  | along with this program; if not, write to the Free Software |
23  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
24  +-----------------------------------------------------------------------------+
25 */
26 
28 {
29  public static function _getInProgress(int $a_obj_id): array
30  {
31  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
32  $users = $status_info['in_progress'];
33  return array_unique($users);
34  }
35 
36  public static function _getCompleted(int $a_obj_id): array
37  {
38  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
39  $users = $status_info['completed'];
40  return array_unique($users);
41  }
42 
43  public static function _getFailed(int $a_obj_id): array
44  {
45  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
46  $users = $status_info['failed'];
47  return array_unique($users);
48  }
49 
50  public static function _getStatusInfo(int $a_obj_id): array
51  {
52  $status_info['subtype'] = "scorm2004";
53  $info = ilSCORM2004Tracking::_getProgressInfo($a_obj_id);
54 
55  $status_info['completed'] = $info['completed'];
56  $status_info['failed'] = $info['failed'];
57  $status_info['in_progress'] = $info['in_progress'];
58 
59  return $status_info;
60  }
61 
69  public function determineStatus(
70  int $a_obj_id,
71  int $a_usr_id,
72  object $a_obj = null
73  ): int {
74  global $DIC;
75 
76  $ilObjDataCache = $DIC['ilObjDataCache'];
77  $ilDB = $DIC['ilDB'];
78  $ilLog = $DIC['ilLog'];
79 
81  $a_obj_id,
82  $a_usr_id
83  );
84  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
85  switch ($scorm_status) {
86  case "in_progress":
87  $status = self::LP_STATUS_IN_PROGRESS_NUM;
88  break;
89  case "completed":
90  $status = self::LP_STATUS_COMPLETED_NUM;
91  break;
92  case "failed":
93  $status = self::LP_STATUS_FAILED_NUM;
94  break;
95  }
96 
97  return $status;
98  }
99 
100  public function refreshStatus(int $a_obj_id, ?array $a_users = null): void
101  {
102  parent::refreshStatus($a_obj_id, $a_users);
103 
104  $in_progress = ilLPStatusWrapper::_getInProgress($a_obj_id);
105  $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
106  $failed = ilLPStatusWrapper::_getFailed($a_obj_id);
107  $all_active_users = array_unique(
108  array_merge($in_progress, $completed, $failed)
109  );
110 
111  // get all tracked users regardless of SCOs
112  $all_tracked_users = ilSCORM2004Tracking::_getTrackedUsers($a_obj_id);
113 
114  $not_attempted_users = array_diff(
115  $all_tracked_users,
116  $all_active_users
117  );
118  unset($all_tracked_users);
119  unset($all_active_users);
120 
121  // reset all users which have no data for the current SCOs
122  if ($not_attempted_users) {
123  foreach ($not_attempted_users as $usr_id) {
124  // this will update any (parent) collections if necessary
126  $a_obj_id,
127  $usr_id,
128  self::LP_STATUS_NOT_ATTEMPTED_NUM,
129  0
130  );
131  }
132  }
133  }
134 
135  public function determinePercentage(
136  int $a_obj_id,
137  int $a_usr_id,
138  ?object $a_obj = null
139  ): int {
140  return 0;//todo!
141  }
142 }
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.
determineStatus(int $a_obj_id, int $a_usr_id, object $a_obj=null)
Determine status.
static _getInProgress(int $a_obj_id)
Static function to read users who have the status &#39;in_progress&#39;.
global $DIC
Definition: feed.php:28
static _getFailed(int $a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
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.