18 $data = json_decode(is_string(
$data) ?
$data : file_get_contents(
'php://input'));
20 if ($userId == null) {
21 $userId=(int)
$data->p;
25 if (
$data->last !=
"") $last_visited =
$data->last;
27 $total_time_sec = null;
28 if (
$data->total_time_sec !=
"") {
29 $total_time_sec =
$data->total_time_sec;
30 $ilDB->manipulateF(
'UPDATE sahs_user 31 SET total_time_sec = %s, last_visited = %s, hash_end =%s, last_access = %s 32 WHERE obj_id = %s AND user_id = %s',
33 array(
'integer',
'text',
'timestamp',
'timestamp',
'integer',
'integer'),
36 if ($time_from_lms==
true) {
37 self::ensureObjectDataCacheExistence();
38 global $ilObjDataCache;
40 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php");
45 $ilDB->manipulateF(
'UPDATE sahs_user 46 SET last_visited = %s, hash_end =%s, last_access = %s 47 WHERE obj_id = %s AND user_id = %s',
48 array(
'text',
'timestamp',
'timestamp',
'integer',
'integer'),
53 header(
'Content-Type: text/plain; charset=UTF-8');
58 public static function persistCMIData($userId=null,
$packageId, $defaultLessonMode, $comments, $interactions, $objectives, $time_from_lms,
$data = null)
62 if ($defaultLessonMode ==
"browse") {
return;}
64 $jsMode = strpos(
$_SERVER[
'HTTP_ACCEPT'],
'text/javascript')!==
false;
66 $data = json_decode(is_string(
$data) ?
$data : file_get_contents(
'php://input'));
67 $ilLog->write(
"dataTo_setCMIData: ".file_get_contents(
'php://input'));
69 if ($userId == null) {
70 $userId=(int)
$data->p;
86 $new_global_status =
$data->now_global_status;
87 $return[
"new_global_status"] = $new_global_status;
91 $ilLog->write(
"SCORM: return of persistCMIData: ".json_encode($return));
94 header(
'Content-Type: text/javascript; charset=UTF-8');
95 print(json_encode($return));
99 header(
'Content-Type: text/html; charset=UTF-8');
100 print(var_export($return,
true));
106 $res = $ilDB->queryF(
'select hash from sahs_user where obj_id=%s AND user_id=%s AND hash_end>%s',
107 array(
'integer',
'integer',
'timestamp'),
110 $rowtmp=$ilDB->fetchAssoc(
$res);
111 if ($rowtmp[
'hash']==$hash)
return;
112 else die(
"not allowed");
122 $i_check=
$data->i_check;
124 $b_node_update=
false;
126 $a_map_cmi_interaction_id=
array();
128 $tables =
array(
'node',
'comment',
'interaction',
'objective',
'correct_response');
130 foreach($tables as $table)
132 if (!is_array(
$data->$table))
continue;
134 $ilLog->write(
"SCORM: setCMIData, table -".$table.
"-");
139 $ilLog->write(
"Checking table: ".$table);
145 $res = $ilDB->queryF(
146 'SELECT cmi_node_id FROM cmi_node WHERE cp_node_id = %s and user_id = %s',
147 array(
'integer',
'integer'),
148 array($row[19],$userId)
150 $rowtmp=$ilDB->fetchAssoc(
$res);
151 $cmi_node_id=$rowtmp[
'cmi_node_id'];
152 if ($cmi_node_id!=null) $b_node_update=
true;
154 $cmi_node_id = $ilDB->nextId(
'cmi_node');
155 $b_node_update=
false;
157 $ilLog->write(
"setCMIdata with cmi_node_id = ".$cmi_node_id);
159 'accesscount' =>
array(
'integer', $row[0]),
160 'accessduration' =>
array(
'text', $row[1]),
161 'accessed' =>
array(
'text', $row[2]),
162 'activityabsduration' =>
array(
'text', $row[3]),
163 'activityattemptcount' =>
array(
'integer', $row[4]),
164 'activityexpduration' =>
array(
'text', $row[5]),
165 'activityprogstatus' =>
array(
'integer', $row[6]),
166 'attemptabsduration' =>
array(
'text', $row[7]),
167 'attemptcomplamount' =>
array(
'float', $row[8]),
168 'attemptcomplstatus' =>
array(
'integer', $row[9]),
169 'attemptexpduration' =>
array(
'text', $row[10]),
170 'attemptprogstatus' =>
array(
'integer', $row[11]),
171 'audio_captioning' =>
array(
'integer', $row[12]),
172 'audio_level' =>
array(
'float', $row[13]),
173 'availablechildren' =>
array(
'text', $row[14]),
174 'cmi_node_id' =>
array(
'integer', $cmi_node_id),
175 'completion' =>
array(
'float', $row[16]),
176 'completion_status' =>
array(
'text', $row[17]),
177 'completion_threshold' =>
array(
'text', $row[18]),
178 'cp_node_id' =>
array(
'integer', $row[19]),
179 'created' =>
array(
'text', $row[20]),
180 'credit' =>
array(
'text', $row[21]),
181 'delivery_speed' =>
array(
'float', $row[22]),
182 'c_entry' =>
array(
'text', $row[23]),
183 'c_exit' =>
array(
'text', $row[24]),
184 'c_language' =>
array(
'text', $row[25]),
185 'launch_data' =>
array(
'clob', $row[26]),
186 'learner_name' =>
array(
'text', $row[27]),
187 'location' =>
array(
'text', $row[28]),
188 'c_max' =>
array(
'float', $row[29]),
189 'c_min' =>
array(
'float', $row[30]),
190 'c_mode' =>
array(
'text', $row[31]),
191 'modified' =>
array(
'text', $row[32]),
192 'progress_measure' =>
array(
'float', $row[33]),
193 'c_raw' =>
array(
'float', $row[34]),
194 'scaled' =>
array(
'float', $row[35]),
195 'scaled_passing_score' =>
array(
'float', $row[36]),
196 'session_time' =>
array(
'text', $row[37]),
197 'success_status' =>
array(
'text', $row[38]),
198 'suspend_data' =>
array(
'clob', $row[39]),
199 'total_time' =>
array(
'text', $row[40]),
200 'user_id' =>
array(
'integer', $userId),
201 'c_timestamp' =>
array(
'timestamp',
date(
'Y-m-d H:i:s')),
202 'additional_tables' =>
array(
'integer', $i_check)
205 if($b_node_update==
false) {
206 $ilLog->write(
"Want to insert row: ".count($row) );
207 $ilDB->insert(
'cmi_node', $a_data);
209 $ilDB->update(
'cmi_node', $a_data,
array(
'cmi_node_id' =>
array(
'integer', $cmi_node_id)));
210 $ilLog->write(
"updated");
213 if($b_node_update==
true) {
218 $q =
'DELETE FROM cmi_comment WHERE cmi_node_id = %s';
219 $ilDB->manipulateF($q,
array(
'integer'),
array($cmi_node_id));
224 if ($getInteractions) {
225 $q =
'DELETE FROM cmi_correct_response 226 WHERE cmi_interaction_id IN ( 227 SELECT cmi_interaction.cmi_interaction_id FROM cmi_interaction WHERE cmi_interaction.cmi_node_id = %s)';
228 $ilDB->manipulateF($q,
array(
'integer'),
array($cmi_node_id));
233 if ($getInteractions) {
234 $q =
'DELETE FROM cmi_interaction WHERE cmi_node_id = %s';
235 $ilDB->manipulateF($q,
array(
'integer'),
array($cmi_node_id));
240 if ($getObjectives) {
241 $q =
'DELETE FROM cmi_objective WHERE cmi_node_id = %s';
242 $ilDB->manipulateF($q,
array(
'integer'),
array($cmi_node_id));
252 $row[0] = $ilDB->nextId(
'cmi_comment');
254 $ilDB->insert(
'cmi_comment',
array(
255 'cmi_comment_id' =>
array(
'integer', $row[0]),
256 'cmi_node_id' =>
array(
'integer', $cmi_node_id),
257 'c_comment' =>
array(
'clob', $row[2]),
258 'c_timestamp' =>
array(
'text', $row[3]),
259 'location' =>
array(
'text', $row[4]),
260 'sourceislms' =>
array(
'integer', $row[5])
265 $cmi_interaction_id = $ilDB->nextId(
'cmi_interaction');
266 $a_map_cmi_interaction_id[]=
array($row[0],$cmi_interaction_id);
267 $ilDB->insert(
'cmi_interaction',
array(
268 'cmi_interaction_id' =>
array(
'integer', $cmi_interaction_id),
269 'cmi_node_id' =>
array(
'integer', $cmi_node_id),
270 'description' =>
array(
'clob', $row[2]),
271 'id' =>
array(
'text', $row[3]),
272 'latency' =>
array(
'text', $row[4]),
273 'learner_response' =>
array(
'clob', $row[5]),
274 'result' =>
array(
'text', $row[6]),
275 'c_timestamp' =>
array(
'text', $row[7]),
276 'c_type' =>
array(
'text', $row[8]),
277 'weighting' =>
array(
'float', $row[9])
282 $row[2] = $ilDB->nextId(
'cmi_objective');
283 $cmi_interaction_id = null;
284 if ($row[0] != null) {
285 for($i=0;$i<count($a_map_cmi_interaction_id);$i++)
286 if ($row[0] == $a_map_cmi_interaction_id[$i][0]) $cmi_interaction_id=$a_map_cmi_interaction_id[$i][1];
288 $ilDB->insert(
'cmi_objective',
array(
289 'cmi_interaction_id' =>
array(
'integer', $cmi_interaction_id),
290 'cmi_node_id' =>
array(
'integer', $cmi_node_id),
291 'cmi_objective_id' =>
array(
'integer', $row[2]),
292 'completion_status' =>
array(
'text', $row[3]),
293 'description' =>
array(
'clob', $row[4]),
294 'id' =>
array(
'text', $row[5]),
295 'c_max' =>
array(
'float', $row[6]),
296 'c_min' =>
array(
'float', $row[7]),
297 'c_raw' =>
array(
'float', $row[8]),
298 'scaled' =>
array(
'float', $row[9]),
299 'progress_measure' =>
array(
'float', $row[10]),
300 'success_status' =>
array(
'text', $row[11]),
301 'scope' =>
array(
'text', $row[12])
305 case 'correct_response':
306 $cmi_interaction_id = null;
307 if ($row[1] !== null) {
308 for($i=0;$i<count($a_map_cmi_interaction_id);$i++)
309 if ($row[1] == $a_map_cmi_interaction_id[$i][0]) $cmi_interaction_id=$a_map_cmi_interaction_id[$i][1];
310 $row[0] = $ilDB->nextId(
'cmi_correct_response');
311 $ilDB->insert(
'cmi_correct_response',
array(
312 'cmi_correct_resp_id' =>
array(
'integer', $row[0]),
313 'cmi_interaction_id' =>
array(
'integer', $cmi_interaction_id),
314 'pattern' =>
array(
'text', $row[2])
352 $changed_seq_utilities=
$data->changed_seq_utilities;
353 $ilLog->write(
"SCORM2004 adl_seq_utilities changed: ".$changed_seq_utilities);
354 if ($changed_seq_utilities == 1) {
362 $saved_global_status=
$data->saved_global_status;
363 $ilLog->write(
"saved_global_status=".$saved_global_status);
367 $totalTime=(int)
$data->totalTimeCentisec;
368 $totalTime=round($totalTime/100);
369 $ilDB->queryF(
'UPDATE sahs_user SET sco_total_time_sec=%s, status=%s, percentage_completed=%s WHERE obj_id = %s AND user_id = %s',
370 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
373 self::ensureObjectDataCacheExistence();
374 global $ilObjDataCache;
377 if ($new_global_status != null) {
378 include_once(
"./Services/Tracking/classes/class.ilObjUserTracking.php");
379 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
385 if ($time_from_lms==
false) {
386 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php");
400 $ilLog->write(
"SCORM2004 writeGObjective");
402 $returnAr=
array(null,null,null);
408 $rows_to_insert = Array();
410 foreach($g_data as $key => $value)
412 $ilLog->write(
"SCORM2004 writeGObjective -key: ".$key);
416 foreach($value as $skey => $svalue)
418 $ilLog->write(
"SCORM2004 writeGObjective -skey: ".$skey);
420 if($g_data->$key->$skey->$user->$package)
422 $o_value = $g_data->$key->$skey->$user->$package;
429 $o_value = $g_data->$key->$skey->$user->{
"null"};
435 $objective_id = $skey;
443 $completed = $g_data->$key->$skey->$user->{completed};
444 $measure = $g_data->$key->$skey->$user->{measure};
445 $satisfied = $g_data->$key->$skey->$user->{satisfied};
447 $returnAr=
array($completed, $satisfied, $measure);
449 $obj =
'-course_overall_status-';
453 SELECT user_id FROM cmi_gobjective 454 WHERE objective_id =%s 457 array(
'text',
'integer',
'integer'),
458 array($obj, $dbuser, $pkg_id)
464 INSERT INTO cmi_gobjective 465 (user_id, status, scope_id, measure, satisfied, objective_id) 466 VALUES (%s, %s, %s, %s, %s, %s)',
467 array(
'integer',
'text',
'integer',
'text',
'text',
'text'),
468 array($dbuser, $completed, $pkg_id, $measure, $satisfied, $obj)
470 $ilLog->write(
"SCORM2004 cmi_gobjective Insert status=".$completed.
" scope_id=".$pkg_id.
" measure=".$measure.
" satisfied=".$satisfied.
" objective_id=".$obj);
475 UPDATE cmi_gobjective 479 WHERE objective_id = %s 482 array(
'text',
'text',
'text',
'text',
'integer',
'integer'),
483 array($completed, $measure, $satisfied, $obj, $dbuser, $pkg_id)
485 $ilLog->write(
"SCORM2004 cmi_gobjective Update status=".$completed.
" scope_id=".$pkg_id.
" measure=".$measure.
" satisfied=".$satisfied.
" objective_id=".$obj);
490 if($rows_to_insert[$objective_id] == NULL)
492 $rows_to_insert[$objective_id] = Array();
494 $rows_to_insert[$objective_id][$key] = $toset;
501 $res =
$ilDB->queryF(
"SELECT global_to_system 508 $scope_id = (
$ilDB->fetchObject(
$res)->global_to_system) ? 0 : $package;
511 $existing_key_template =
"";
512 foreach(array_keys($rows_to_insert) as $obj_id)
514 $existing_key_template .=
"'{$obj_id}',";
518 $existing_key_template = substr($existing_key_template, 0, strlen($existing_key_template) - 1);
519 $existing_keys = Array();
521 if($existing_key_template !=
"")
524 $res =
$ilDB->queryF(
"SELECT objective_id 528 AND objective_id IN ($existing_key_template)",
529 array(
'integer',
'integer'),
530 array($dbuser, $scope_id)
535 $existing_keys[] =
$row[
'objective_id'];
539 foreach($rows_to_insert as $obj_id => $vals)
541 if(in_array($obj_id, $existing_keys))
543 $ilDB->manipulateF(
"UPDATE cmi_gobjective 549 completion_status=%s, 551 WHERE objective_id = %s 555 array(
'text',
'text',
'text',
'text',
'text',
'text',
556 'text',
'text',
'integer',
'integer'),
558 array($vals[
'satisfied'], $vals[
"measure"], $vals[
"score_raw"],
559 $vals[
"score_min"], $vals[
"score_max"],
560 $vals[
"completion_status"], $vals[
"progress_measure"],
561 $obj_id, $dbuser, $scope_id)
565 $ilDB->manipulateF(
"INSERT INTO cmi_gobjective 566 (user_id, satisfied, measure, scope_id, status, objective_id, 567 score_raw, score_min, score_max, progress_measure, completion_status) 568 VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
571 array(
'integer',
'text',
'text',
'integer',
'text',
'text',
572 'text',
'text',
'text',
'text',
'text'),
574 array($dbuser, $vals[
'satisfied'], $vals[
'measure'],
575 $scope_id, NULL, $obj_id, $vals[
'score_raw'],
576 $vals[
'score_min'], $vals[
'score_max'],
577 $vals[
'progress_measure'], $vals[
'completion_status'])
590 protected static function ensureObjectDataCacheExistence()
595 global $ilObjDataCache;
602 require_once
'./Services/Object/classes/class.ilObjectDataCache.php';
603 $ilObjDataCache =
new ilObjectDataCache();
604 $GLOBALS[
'ilObjDataCache'] = $ilObjDataCache;
static syncGlobalStatus($userId, $packageId, $data, $new_global_status, $time_from_lms)
static checkIfAllowed($packageId, $userId, $hash)
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Add rich text string
The name of the decorator.
static setGlobalObjectives($userId, $packageId, $data)
static scormPlayerUnload($userId=null, $packageId, $time_from_lms)
Class ilSCORM2004StoreData.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static persistCMIData($userId=null, $packageId, $defaultLessonMode, $comments, $interactions, $objectives, $time_from_lms, $data=null)
Add a drawing to the header
Create styles array
The data for the language used.
static writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false)
Write status for user and object.
static setCMIData($userId, $packageId, $data, $getComments, $getInteractions, $getObjectives)
static _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id, $time_from_lms=null)
Synch read event table.
static writeGObjective($g_data, $user, $package)