ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSCORMOfflineMode Class Reference

Class ilSCORMOfflineMode. More...

+ Collaboration diagram for ilSCORMOfflineMode:

Public Member Functions

 __construct ()
 Constructor. More...
 
 il2sop ()
 
 getClientIdSop ()
 
 il2sopUserData ()
 
 il2sopSahsUser ()
 
 sop2il ()
 
 scormPlayerUnloadForSop2il ($data)
 
 setOfflineMode ($a_mode)
 
 getOfflineMode ()
 

Static Public Member Functions

static checkIfAnyoneIsInOfflineMode ($obj_id)
 
static usersInOfflineMode ($obj_id)
 
static stopOfflineModeForUser ($obj_id, $user_id)
 

Data Fields

 $type
 
 $obj_id
 
 $offlineMode
 

Private Member Functions

 read ()
 

Detailed Description

Class ilSCORMOfflineMode.

Class for scorm offline player connection

Author
Uwe Kohnle kohnl.nosp@m.e@in.nosp@m.terne.nosp@m.tleh.nosp@m.rer-g.nosp@m.mbh..nosp@m.de
Version
Id
class.ilSCORMOfflineMode.php

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

Constructor & Destructor Documentation

◆ __construct()

ilSCORMOfflineMode::__construct ( )

Constructor.

Parameters
int$a_idObject ID public

Definition at line 28 of file class.ilSCORMOfflineMode.php.

References $_GET, ilObject\_lookupObjectId(), ilObjSAHSLearningModule\_lookupSubType(), and read().

29  {
30  global $ilias;
31  $this->ilias = $ilias;
32  $this->id = $_GET['ref_id'];
33  $this->obj_id = ilObject::_lookupObjectId($_GET['ref_id']);
34  include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
35  $this->type = ilObjSAHSLearningModule::_lookupSubType($this->obj_id);
36  $this->read();
37  }
$_GET["client_id"]
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, aicc, hacp)
static _lookupObjectId($a_ref_id)
lookup object id
redirection script todo: (a better solution should control the processing via a xml file) ...
+ Here is the call graph for this function:

Member Function Documentation

◆ checkIfAnyoneIsInOfflineMode()

static ilSCORMOfflineMode::checkIfAnyoneIsInOfflineMode (   $obj_id)
static

Definition at line 295 of file class.ilSCORMOfflineMode.php.

References $ilDB, $res, and array.

Referenced by ilObjSCORM2004LearningModuleGUI\initPropertiesForm(), and ilObjSCORMLearningModuleGUI\properties().

295  {
296  global $ilDB;
297  $res = $ilDB->queryF("SELECT count(*) cnt FROM sahs_user WHERE obj_id=%s AND offline_mode = 'offline'",
298  array('integer'),
299  array($obj_id)
300  );
301  $val_rec = $ilDB->fetchAssoc($res);
302  if ($val_rec["cnt"] == 0) return false;
303  return true;
304  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getClientIdSop()

ilSCORMOfflineMode::getClientIdSop ( )

Definition at line 110 of file class.ilSCORMOfflineMode.php.

110  {
111  $iliasDomain = substr(ILIAS_HTTP_PATH,7);
112  if (substr($iliasDomain,0,1) == "\/") $iliasDomain = substr($iliasDomain,1);
113  if (substr($iliasDomain,0,4) == "www.") $iliasDomain = substr($iliasDomain,4);
114  return $iliasDomain.';'.CLIENT_ID;
115  }

◆ getOfflineMode()

ilSCORMOfflineMode::getOfflineMode ( )

Definition at line 275 of file class.ilSCORMOfflineMode.php.

References $offlineMode.

275  {
276  return $this->offlineMode;
277  }

◆ il2sop()

ilSCORMOfflineMode::il2sop ( )

Definition at line 39 of file class.ilSCORMOfflineMode.php.

References $_GET, $ilUser, $obj_id, $result, ilObject\_lookupDescription(), ilObject\_lookupTitle(), array, ilObjSCORMInitData\get_max_attempts(), ilObjSCORMInitData\getIliasScormData(), ilObjSCORMInitData\getIliasScormResources(), ilObjSCORMInitData\getIliasScormTree(), ilObjSCORMInitData\getIliasScormVars(), ilObjectLP\getInstance(), header, il2sopSahsUser(), il2sopUserData(), and setOfflineMode().

39  {
40  global $ilUser, $ilias;
41  $this->setOfflineMode("il2sop");
42  header('Content-Type: text/javascript; charset=UTF-8');
43 
44  include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
45  $ob = new ilObjSAHSLearningModule($this->id);
46  $module_version = $ob->getModuleVersion();
47  $sahs_user = $this->il2sopSahsUser();
48  $support_mail = "";//TODO
49  $scorm_version = "1.2";
50  if ($this->type == "scorm2004") $scorm_version = "2004";
51  $tree="";
52 
53  $learning_progress_enabled = 1;
54  include_once './Services/Object/classes/class.ilObjectLP.php';
55  $olp = ilObjectLP::getInstance($this->obj_id);
56  if ($olp->getCurrentMode() == 0) $learning_progress_enabled = 0;
57 
58  $certificate_enabled = 0;
59 
60  $adlact_data = null;
61  $ilias_version = $ilias->getSetting("ilias_version");
62 
63  if ($this->type == 'scorm2004') {
64  include_once "./Modules/Scorm2004/classes/ilSCORM13Player.php";
65  $ob2004 = new ilSCORM13Player();
66  $init_data = $ob2004->getConfigForPlayer();
67  $resources = json_decode($ob2004->getCPDataInit());
68  $cmi = $ob2004->getCMIData($ilUser->getID(), $this->obj_id);
69  $max_attempt = $ob2004->get_max_attempts();
70  $adlact_data = json_decode($ob2004->getADLActDataInit());
71  //$globalobj_data = $ob2004->readGObjectiveInit();
72  } else {
73  include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMInitData.php";
74  $slm_obj = new ilObjSCORMLearningModule($_GET["ref_id"]);
75  $init_data = ilObjSCORMInitData::getIliasScormVars($slm_obj);
76  $resources = json_decode(ilObjSCORMInitData::getIliasScormResources($this->obj_id));
77  $tree = json_decode(ilObjSCORMInitData::getIliasScormTree($this->obj_id));
78  $cmi = json_decode(ilObjSCORMInitData::getIliasScormData($this->obj_id));
79  $max_attempt = ilObjSCORMInitData::get_max_attempts($this->obj_id);
80  }
81  if ($max_attempt == null) $max_attempt = 0;
82  $result = array(
83  'client_data' => array(
84  $support_mail
85  ),
86  'user_data' => $this->il2sopUserData(),
87  'lm' => array(
88  ilObject::_lookupTitle($this->obj_id),
89  ilObject::_lookupDescription($this->obj_id),
90  $scorm_version,
91  1,//active
92  $init_data,
93  $resources,
94  $tree,
95  $module_version,
96  "", //offline_zip_created!!!!!!!!
97  $learning_progress_enabled,
98  $certificate_enabled,
99  $max_attempt,
100  $adlact_data,
101  $ilias_version
102  ),
103  'sahs_user' => $sahs_user,
104  'cmi' => $cmi
105  );
106 
107  print(json_encode($result));
108  }
static getIliasScormData($a_packageId)
static getIliasScormResources($a_packageId)
$result
$_GET["client_id"]
static _lookupTitle($a_id)
lookup object title
static getIliasScormVars($slm_obj)
static get_max_attempts($a_packageId)
Get max.
static _lookupDescription($a_id)
lookup object description
$ilUser
Definition: imgupload.php:18
Add a drawing to the header
Definition: 04printing.php:69
Create styles array
The data for the language used.
static getInstance($a_obj_id)
Class ilObjSCORMLearningModule.
Class ilObjSCORMLearningModule.
static getIliasScormTree($a_packageId)
+ Here is the call graph for this function:

◆ il2sopSahsUser()

ilSCORMOfflineMode::il2sopSahsUser ( )

Definition at line 129 of file class.ilSCORMOfflineMode.php.

References $ilDB, $ilUser, $res, $row, ilChangeEvent\_lookupReadEvents(), and array.

Referenced by il2sop().

129  {
130  global $ilDB,$ilUser;
131  $package_attempts = 0;
132  $module_version = 1;//if module_version in sop is different...
133  $last_visited = "";
134  $first_access = null;
135  $last_access = null;
136  $last_status_change = null;
137  $total_time_sec = null;
138  $sco_total_time_sec = 0;
139  $status = 0;
140  $percentage_completed = 0;
141  $user_data = "";
142 
143  global $ilDB,$ilUser;
144  $res = $ilDB->queryF('SELECT * FROM sahs_user WHERE obj_id=%s AND user_id=%s',
145  array('integer','integer'),
146  array($this->obj_id,$ilUser->getID())
147  );
148  while($row = $ilDB->fetchAssoc($res))
149  {
150  $package_attempts = $row['package_attempts'];
151  $module_version = $row['module_version'];
152  $last_visited = $row['last_visited'];
153  if ($row['first_access'] != null) {
154  $first_access = strtotime($row['first_access'])*1000;//check Oracle!
155  }
156  if ($row['last_access'] != null) {
157  $last_access = strtotime($row['last_access'])*1000;//check Oracle!
158  }
159  $total_time_sec = $row['total_time_sec'];
160  $sco_total_time_sec = $row['sco_total_time_sec'];
161  $status = $row['status'];
162  $percentage_completed = $row['percentage_completed'];
163  }
164  if ($first_access == null) {
165  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
166  $all = ilChangeEvent::_lookupReadEvents($this->obj_id,$ilUser->getID());
167  foreach($all as $event)
168  {
169  $first_access = strtotime($event['first_access'])*1000;//
170  }
171  }
172  return array($package_attempts, $module_version, $last_visited, $first_access, $last_access, $last_status_change, $total_time_sec, $sco_total_time_sec, $status, $percentage_completed, $user_data);
173  }
$ilUser
Definition: imgupload.php:18
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object which happened after the last time the user caught ...
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ il2sopUserData()

ilSCORMOfflineMode::il2sopUserData ( )

Definition at line 117 of file class.ilSCORMOfflineMode.php.

References $ilUser, and array.

Referenced by il2sop().

117  {
118  global $ilUser;
119  return array(
120  $ilUser->getLogin(),
121  "",
122  $ilUser->getFirstname(),
123  $ilUser->getLastname(),
124  $ilUser->getUTitle(),
125  $ilUser->getGender(),
126  $ilUser->getID()
127  );
128  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ read()

ilSCORMOfflineMode::read ( )
private

Definition at line 279 of file class.ilSCORMOfflineMode.php.

References $ilDB, $ilUser, $res, $row, and array.

Referenced by __construct().

279  {
280  global $ilDB,$ilUser;
281  $res = $ilDB->queryF('SELECT offline_mode FROM sahs_user WHERE obj_id=%s AND user_id=%s',
282  array('integer','integer'),
283  array($this->obj_id,$ilUser->getId())
284  );
285  while($row = $ilDB->fetchAssoc($res))
286  {
287  if ($row['offline_mode'] != null) {
288  $this->offlineMode = $row['offline_mode'];
289  } else {
290  $this->offlineMode = "online";
291  }
292  }
293  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ scormPlayerUnloadForSop2il()

ilSCORMOfflineMode::scormPlayerUnloadForSop2il (   $data)

Definition at line 242 of file class.ilSCORMOfflineMode.php.

References $data, $GLOBALS, $ilDB, $ilUser, $res, ilChangeEvent\_updateAccessForScormOfflinePlayer(), array, and date.

242  {
243  global $ilDB,$ilUser;
244  $first_access=null;
245  if($data->first_access != null) $first_access=date('Y-m-d H:i:s',round($data->first_access/1000));
246  $last_access=null;
247  $i_last_access=null;
248  if($data->last_access != null) {
249  $i_last_access = round($data->last_access/1000);
250  $last_access=date('Y-m-d H:i:s',$i_last_access);
251  include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
252  ilChangeEvent::_updateAccessForScormOfflinePlayer($this->obj_id,$ilUser->getId(), $i_last_access, $first_access);
253  }
254  $last_status_change=null;
255  if($data->last_status_change != null) $last_status_change=date('Y-m-d H:i:s',round($data->last_status_change/1000));
256  $GLOBALS['ilLog']->write('first_access='.$first_access);
257  $res = $ilDB->queryF('UPDATE sahs_user SET first_access=%s, last_access=%s, last_status_change=%s, last_visited=%s, module_version=%s WHERE obj_id=%s AND user_id=%s',
258  array('timestamp','timestamp','timestamp','text','integer','integer','integer'),
259  array($first_access,$last_access,$last_status_change,$data->last_visited,$data->module_version, $this->obj_id,$ilUser->getId())
260  );
261 
262  //populate last_status_change
263  return true;
264  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _updateAccessForScormOfflinePlayer($obj_id, $usr_id, $i_last_access, $t_first_access)
_updateAccessForScormOfflinePlayer needed to synchronize last_access and first_access when learning m...
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ setOfflineMode()

ilSCORMOfflineMode::setOfflineMode (   $a_mode)

Definition at line 267 of file class.ilSCORMOfflineMode.php.

References $ilDB, $ilUser, $res, and array.

Referenced by il2sop().

267  {
268  global $ilDB,$ilUser;
269  $res = $ilDB->queryF('UPDATE sahs_user SET offline_mode=%s WHERE obj_id=%s AND user_id=%s',
270  array('text','integer','integer'),
271  array($a_mode, $this->obj_id,$ilUser->getId())
272  );
273  $this->offlineMode=$a_mode;
274  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ sop2il()

ilSCORMOfflineMode::sop2il ( )

Definition at line 175 of file class.ilSCORMOfflineMode.php.

References $data, $GLOBALS, $ilDB, $ilUser, $in, $lm_set, $result, $ret, array, exit, header, ilSCORM2004StoreData\setCMIData(), ilObjSCORMTracking\storeJsApiCmi(), ilObjSCORMTracking\syncGlobalStatus(), ilSCORM2004StoreData\syncGlobalStatus(), and ilUtil\yn2tf().

175  {
176 // sleep(5);
177  global $ilDB,$ilUser;
178  $in = file_get_contents("php://input");
179  $GLOBALS['ilLog']->write($in);
180  $ret = array('msg'=>array(),'err'=>array());
181 
182  if (!$in || $in == "") {
183  $ret['err'][] = "no post data recieved";
184  print(json_encode($ret));
185  exit;
186  }
187  $userId=$ilUser->getID();
188  $result=true;
189 
190  if ($this->type == 'scorm2004') {
191  $lm_set = $ilDB->queryF('SELECT default_lesson_mode, interactions, objectives, comments, time_from_lms FROM sahs_lm WHERE id = %s', array('integer'),array($this->obj_id));
192  while($lm_rec = $ilDB->fetchAssoc($lm_set))
193  {
194  $defaultLessonMode=($lm_rec["default_lesson_mode"]);
195  $interactions=(ilUtil::yn2tf($lm_rec["interactions"]));
196  $objectives=(ilUtil::yn2tf($lm_rec["objectives"]));
197  $comments=(ilUtil::yn2tf($lm_rec["comments"]));
198  $time_from_lms=(ilUtil::yn2tf($lm_rec["time_from_lms"]));
199  }
200  include_once './Modules/Scorm2004/classes/class.ilSCORM2004StoreData.php';
201  $data = json_decode($in);
202  $GLOBALS['ilLog']->write('cmi_count='.count($data->cmi));
203  for ($i=0; $i<count($data->cmi); $i++) {
204  if($result==true) {
205  //$a_r=array();
206  $cdata=$data->cmi[$i];
208  $userId,
209  $this->obj_id,
210  $data->cmi[$i],//json_decode($data->cmi[$i]),
211  $comments,
212  $interactions,
213  $objectives
214  );
215  if (!is_array($a_r)) $result=false;
216  }
217  }
218  if ($result==true) {
219  $result=ilSCORM2004StoreData::syncGlobalStatus($userId, $this->obj_id, $data, $data->now_global_status, $time_from_lms);
220  }
221  } else {
222  include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php";
223  $data = json_decode($in);
224  $result=ilObjSCORMTracking::storeJsApiCmi($userId,$this->obj_id,$data);
225  if ($result==true) {
226  $result=ilObjSCORMTracking::syncGlobalStatus($userId, $this->obj_id, $data, $data->now_global_status);
227  }
228  }
229  if ($result==true) {
230  $result=self::scormPlayerUnloadForSOP2il($data);
231  }
232 
233  if ($result==false) {
234  $ret['err'][] = "invalid post data recieved";
235  } else {
236  $ret['msg'][] = "post data recieved";
237  }
238  header('Content-Type: text/plain; charset=UTF-8');
239  print json_encode($ret);
240  }
static syncGlobalStatus($userId, $packageId, $data, $new_global_status, $time_from_lms)
static storeJsApiCmi($user_id, $obj_id, $data)
$result
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$ilUser
Definition: imgupload.php:18
Add a drawing to the header
Definition: 04printing.php:69
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
static setCMIData($userId, $packageId, $data, $getComments, $getInteractions, $getObjectives)
$lm_set
global $ilDB
$ret
Definition: parser.php:6
static syncGlobalStatus($userId, $packageId, $data, $new_global_status)
static yn2tf($a_yn)
convert "y"/"n" to true/false
+ Here is the call graph for this function:

◆ stopOfflineModeForUser()

static ilSCORMOfflineMode::stopOfflineModeForUser (   $obj_id,
  $user_id 
)
static

Definition at line 321 of file class.ilSCORMOfflineMode.php.

References $ilDB, $res, and array.

Referenced by ilObjSCORMLearningModuleGUI\confirmedStopUserOfflineMode().

321  {
322  global $ilDB;
323  $res = $ilDB->queryF("UPDATE sahs_user SET offline_mode='online' WHERE obj_id=%s AND user_id=%s",
324  array('integer','integer'),
325  array($obj_id,$user_id)
326  );
327  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ usersInOfflineMode()

static ilSCORMOfflineMode::usersInOfflineMode (   $obj_id)
static

Definition at line 306 of file class.ilSCORMOfflineMode.php.

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

Referenced by ilSCORMOfflineModeUsersTableGUI\parse().

306  {
307  global $ilDB;
308  $users = array();
309  $res = $ilDB->queryF("SELECT user_id, lastname, firstname FROM sahs_user, usr_data "
310  ."WHERE sahs_user.obj_id=%s AND sahs_user.offline_mode = 'offline' AND sahs_user.user_id=usr_data.usr_id",
311  array('integer'),
312  array($obj_id)
313  );
314  while($row = $ilDB->fetchAssoc($res))
315  {
316  $users[] = $row;
317  }
318  return $users;
319  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $obj_id

ilSCORMOfflineMode::$obj_id

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

Referenced by il2sop().

◆ $offlineMode

ilSCORMOfflineMode::$offlineMode

Definition at line 20 of file class.ilSCORMOfflineMode.php.

Referenced by getOfflineMode().

◆ $type

ilSCORMOfflineMode::$type

Definition at line 18 of file class.ilSCORMOfflineMode.php.


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