18 $ilDB = $DIC->database();
20 $data = json_decode(is_string(
$data) ?
$data : file_get_contents(
'php://input'));
24 if ($userId == null) {
25 $userId=(int)
$data->p;
29 if (
$data->last !=
"") {
30 $last_visited =
$data->last;
33 $total_time_sec = null;
34 if (
$data->total_time_sec !=
"") {
35 $total_time_sec =
$data->total_time_sec;
38 SET total_time_sec = %s, last_visited = %s, hash_end =%s, last_access = %s 39 WHERE obj_id = %s AND user_id = %s',
40 array(
'integer',
'text',
'timestamp',
'timestamp',
'integer',
'integer'),
43 if ($time_from_lms==
true) {
44 self::ensureObjectDataCacheExistence();
47 $ilObjDataCache = $DIC[
"ilObjDataCache"];
49 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php");
56 SET last_visited = %s, hash_end =%s, last_access = %s 57 WHERE obj_id = %s AND user_id = %s',
58 array(
'text',
'timestamp',
'timestamp',
'integer',
'integer'),
63 header(
'Content-Type: text/plain; charset=UTF-8');
68 public static function persistCMIData($userId=null,
$packageId, $defaultLessonMode, $comments, $interactions, $objectives, $time_from_lms,
$data = null)
74 if ($defaultLessonMode ==
"browse") {
78 $jsMode = strpos(
$_SERVER[
'HTTP_ACCEPT'],
'text/javascript')!==
false;
80 $data = json_decode(is_string(
$data) ?
$data : file_get_contents(
'php://input'));
81 $ilLog->write(
"dataTo_setCMIData: " . file_get_contents(
'php://input'));
85 if ($userId == null) {
86 $userId=(int)
$data->p;
102 $new_global_status =
$data->now_global_status;
103 $return[
"new_global_status"] = $new_global_status;
107 $ilLog->write(
"SCORM: return of persistCMIData: " . json_encode($return));
109 header(
'Content-Type: text/javascript; charset=UTF-8');
110 print(json_encode($return));
112 header(
'Content-Type: text/html; charset=UTF-8');
113 print(var_export($return,
true));
121 $ilDB = $DIC->database();
123 'select hash from sahs_user where obj_id=%s AND user_id=%s AND hash_end>%s',
124 array(
'integer',
'integer',
'timestamp'),
128 if ($rowtmp[
'hash']==$hash) {
139 $ilDB = $DIC->database();
148 $i_check=
$data->i_check;
150 $b_node_update=
false;
152 $a_map_cmi_interaction_id=
array();
154 $tables =
array(
'node',
'comment',
'interaction',
'objective',
'correct_response');
156 foreach ($tables as
$table) {
157 if (!is_array(
$data->$table)) {
161 $ilLog->write(
"SCORM: setCMIData, table -" . $table .
"-");
165 $ilLog->write(
"Checking table: " . $table);
171 'SELECT cmi_node_id FROM cmi_node WHERE cp_node_id = %s and user_id = %s',
172 array(
'integer',
'integer'),
173 array($row[19],$userId)
176 $cmi_node_id=$rowtmp[
'cmi_node_id'];
177 if ($cmi_node_id!=null) {
180 $cmi_node_id =
$ilDB->nextId(
'cmi_node');
181 $b_node_update=
false;
183 $ilLog->write(
"setCMIdata with cmi_node_id = " . $cmi_node_id);
185 'accesscount' =>
array(
'integer', $row[0]),
186 'accessduration' =>
array(
'text', $row[1]),
187 'accessed' =>
array(
'text', $row[2]),
188 'activityabsduration' =>
array(
'text', $row[3]),
189 'activityattemptcount' =>
array(
'integer', $row[4]),
190 'activityexpduration' =>
array(
'text', $row[5]),
191 'activityprogstatus' =>
array(
'integer', $row[6]),
192 'attemptabsduration' =>
array(
'text', $row[7]),
193 'attemptcomplamount' =>
array(
'float', $row[8]),
194 'attemptcomplstatus' =>
array(
'integer', $row[9]),
195 'attemptexpduration' =>
array(
'text', $row[10]),
196 'attemptprogstatus' =>
array(
'integer', $row[11]),
197 'audio_captioning' =>
array(
'integer', $row[12]),
198 'audio_level' =>
array(
'float', $row[13]),
199 'availablechildren' =>
array(
'text', $row[14]),
200 'cmi_node_id' =>
array(
'integer', $cmi_node_id),
201 'completion' =>
array(
'float', $row[16]),
202 'completion_status' =>
array(
'text', $row[17]),
203 'completion_threshold' =>
array(
'text', $row[18]),
204 'cp_node_id' =>
array(
'integer', $row[19]),
205 'created' =>
array(
'text', $row[20]),
206 'credit' =>
array(
'text', $row[21]),
207 'delivery_speed' =>
array(
'float', $row[22]),
208 'c_entry' =>
array(
'text', $row[23]),
209 'c_exit' =>
array(
'text', $row[24]),
210 'c_language' =>
array(
'text', $row[25]),
211 'launch_data' =>
array(
'clob', $row[26]),
212 'learner_name' =>
array(
'text', $row[27]),
213 'location' =>
array(
'text', $row[28]),
214 'c_max' =>
array(
'float', $row[29]),
215 'c_min' =>
array(
'float', $row[30]),
216 'c_mode' =>
array(
'text', $row[31]),
217 'modified' =>
array(
'text', $row[32]),
218 'progress_measure' =>
array(
'float', $row[33]),
219 'c_raw' =>
array(
'float', $row[34]),
220 'scaled' =>
array(
'float', $row[35]),
221 'scaled_passing_score' =>
array(
'float', $row[36]),
222 'session_time' =>
array(
'text', $row[37]),
223 'success_status' =>
array(
'text', $row[38]),
224 'suspend_data' =>
array(
'clob', $row[39]),
225 'total_time' =>
array(
'text', $row[40]),
226 'user_id' =>
array(
'integer', $userId),
227 'c_timestamp' =>
array(
'timestamp',
date(
'Y-m-d H:i:s')),
228 'additional_tables' =>
array(
'integer', $i_check)
231 if ($b_node_update==
false) {
232 $ilDB->insert(
'cmi_node', $a_data);
233 $ilLog->write(
"inserted");
235 $ilDB->update(
'cmi_node', $a_data,
array(
'cmi_node_id' =>
array(
'integer', $cmi_node_id)));
239 if ($b_node_update==
true) {
244 $q =
'DELETE FROM cmi_comment WHERE cmi_node_id = %s';
250 if ($getInteractions) {
251 $q =
'DELETE FROM cmi_correct_response 252 WHERE cmi_interaction_id IN ( 253 SELECT cmi_interaction.cmi_interaction_id FROM cmi_interaction WHERE cmi_interaction.cmi_node_id = %s)';
259 if ($getInteractions) {
260 $q =
'DELETE FROM cmi_interaction WHERE cmi_node_id = %s';
266 if ($getObjectives) {
267 $q =
'DELETE FROM cmi_objective WHERE cmi_node_id = %s';
278 $row[0] =
$ilDB->nextId(
'cmi_comment');
281 'cmi_comment_id' =>
array(
'integer', $row[0]),
282 'cmi_node_id' =>
array(
'integer', $cmi_node_id),
283 'c_comment' =>
array(
'clob', $row[2]),
284 'c_timestamp' =>
array(
'text', $row[3]),
285 'location' =>
array(
'text', $row[4]),
286 'sourceislms' =>
array(
'integer', $row[5])
291 $cmi_interaction_id =
$ilDB->nextId(
'cmi_interaction');
292 $a_map_cmi_interaction_id[]=
array($row[0],$cmi_interaction_id);
294 'cmi_interaction_id' =>
array(
'integer', $cmi_interaction_id),
295 'cmi_node_id' =>
array(
'integer', $cmi_node_id),
296 'description' =>
array(
'clob', $row[2]),
297 'id' =>
array(
'text', $row[3]),
298 'latency' =>
array(
'text', $row[4]),
299 'learner_response' =>
array(
'clob', $row[5]),
300 'result' =>
array(
'text', $row[6]),
301 'c_timestamp' =>
array(
'text', $row[7]),
302 'c_type' =>
array(
'text', $row[8]),
303 'weighting' =>
array(
'float', $row[9])
308 $row[2] =
$ilDB->nextId(
'cmi_objective');
309 $cmi_interaction_id = null;
310 if ($row[0] != null) {
311 for (
$i=0;
$i<count($a_map_cmi_interaction_id);
$i++) {
312 if ($row[0] == $a_map_cmi_interaction_id[
$i][0]) {
313 $cmi_interaction_id=$a_map_cmi_interaction_id[
$i][1];
318 'cmi_interaction_id' =>
array(
'integer', $cmi_interaction_id),
319 'cmi_node_id' =>
array(
'integer', $cmi_node_id),
320 'cmi_objective_id' =>
array(
'integer', $row[2]),
321 'completion_status' =>
array(
'text', $row[3]),
322 'description' =>
array(
'clob', $row[4]),
323 'id' =>
array(
'text', $row[5]),
324 'c_max' =>
array(
'float', $row[6]),
325 'c_min' =>
array(
'float', $row[7]),
326 'c_raw' =>
array(
'float', $row[8]),
327 'scaled' =>
array(
'float', $row[9]),
328 'progress_measure' =>
array(
'float', $row[10]),
329 'success_status' =>
array(
'text', $row[11]),
330 'scope' =>
array(
'text', $row[12])
334 case 'correct_response':
335 $cmi_interaction_id = null;
336 if ($row[1] !== null) {
337 for (
$i=0;
$i<count($a_map_cmi_interaction_id);
$i++) {
338 if ($row[1] == $a_map_cmi_interaction_id[
$i][0]) {
339 $cmi_interaction_id=$a_map_cmi_interaction_id[
$i][1];
342 $row[0] =
$ilDB->nextId(
'cmi_correct_response');
344 'cmi_correct_resp_id' =>
array(
'integer', $row[0]),
345 'cmi_interaction_id' =>
array(
'integer', $cmi_interaction_id),
346 'pattern' =>
array(
'text', $row[2])
387 $changed_seq_utilities=
$data->changed_seq_utilities;
388 $ilLog->write(
"SCORM2004 adl_seq_utilities changed: " . $changed_seq_utilities);
389 if ($changed_seq_utilities == 1) {
398 $ilDB = $DIC->database();
400 $saved_global_status=
$data->saved_global_status;
401 $ilLog->write(
"saved_global_status=" . $saved_global_status);
405 $totalTime=(int)
$data->totalTimeCentisec;
406 $totalTime=round($totalTime/100);
408 'UPDATE sahs_user SET sco_total_time_sec=%s, status=%s, percentage_completed=%s WHERE obj_id = %s AND user_id = %s',
409 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
413 self::ensureObjectDataCacheExistence();
416 $ilObjDataCache = $DIC[
"ilObjDataCache"];
419 if ($new_global_status != null) {
420 include_once(
"./Services/Tracking/classes/class.ilObjUserTracking.php");
421 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
427 if ($time_from_lms==
false) {
428 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php");
443 $ilDB = $DIC->database();
445 $ilLog->write(
"SCORM2004 writeGObjective");
447 $returnAr=
array(null,null,null);
450 if ($g_data == null) {
454 $rows_to_insert =
array();
456 foreach ($g_data as
$key => $value) {
457 $ilLog->write(
"SCORM2004 writeGObjective -key: " .
$key);
461 foreach ($value as $skey => $svalue) {
462 $ilLog->write(
"SCORM2004 writeGObjective -skey: " . $skey);
464 if ($g_data->$key->$skey->$user->$package) {
465 $o_value = $g_data->$key->$skey->$user->$package;
469 $o_value = $g_data->$key->$skey->$user->{
"null"};
475 $objective_id = $skey;
479 if (
$key ==
"status") {
482 $completed = $g_data->$key->$skey->$user->{completed};
483 $measure = $g_data->$key->$skey->$user->{measure};
484 $satisfied = $g_data->$key->$skey->$user->{satisfied};
486 $returnAr=
array($completed, $satisfied, $measure);
488 $obj =
'-course_overall_status-';
493 SELECT user_id FROM cmi_gobjective 494 WHERE objective_id =%s 497 array(
'text',
'integer',
'integer'),
498 array($obj, $dbuser, $pkg_id)
504 INSERT INTO cmi_gobjective 505 (user_id, status, scope_id, measure, satisfied, objective_id) 506 VALUES (%s, %s, %s, %s, %s, %s)',
507 array(
'integer',
'text',
'integer',
'text',
'text',
'text'),
508 array($dbuser, $completed, $pkg_id, $measure, $satisfied, $obj)
510 $ilLog->write(
"SCORM2004 cmi_gobjective Insert status=" . $completed .
" scope_id=" . $pkg_id .
" measure=" . $measure .
" satisfied=" . $satisfied .
" objective_id=" . $obj);
514 UPDATE cmi_gobjective 518 WHERE objective_id = %s 521 array(
'text',
'text',
'text',
'text',
'integer',
'integer'),
522 array($completed, $measure, $satisfied, $obj, $dbuser, $pkg_id)
524 $ilLog->write(
"SCORM2004 cmi_gobjective Update status=" . $completed .
" scope_id=" . $pkg_id .
" measure=" . $measure .
" satisfied=" . $satisfied .
" objective_id=" . $obj);
528 if ($rows_to_insert[$objective_id] == null) {
529 $rows_to_insert[$objective_id] =
array();
531 $rows_to_insert[$objective_id][
$key] = $toset;
538 "SELECT global_to_system 545 $scope_id = (
$ilDB->fetchObject(
$res)->global_to_system) ? 0 : $package;
548 $existing_key_template =
"";
549 foreach (array_keys($rows_to_insert) as $obj_id) {
550 $existing_key_template .=
"'{$obj_id}',";
553 $existing_key_template = substr($existing_key_template, 0, strlen($existing_key_template) - 1);
554 $existing_keys =
array();
556 if ($existing_key_template !=
"") {
563 AND objective_id IN ($existing_key_template)",
564 array(
'integer',
'integer'),
565 array($dbuser, $scope_id)
569 $existing_keys[] =
$row[
'objective_id'];
573 foreach ($rows_to_insert as $obj_id => $vals) {
574 if (in_array($obj_id, $existing_keys)) {
576 "UPDATE cmi_gobjective 582 completion_status=%s, 584 WHERE objective_id = %s 587 array(
'text',
'text',
'text',
'text',
'text',
'text',
588 'text',
'text',
'integer',
'integer'),
589 array($vals[
'satisfied'], $vals[
"measure"], $vals[
"score_raw"],
590 $vals[
"score_min"], $vals[
"score_max"],
591 $vals[
"completion_status"], $vals[
"progress_measure"],
592 $obj_id, $dbuser, $scope_id)
596 "INSERT INTO cmi_gobjective 597 (user_id, satisfied, measure, scope_id, status, objective_id, 598 score_raw, score_min, score_max, progress_measure, completion_status) 599 VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
600 array(
'integer',
'text',
'text',
'integer',
'text',
'text',
601 'text',
'text',
'text',
'text',
'text'),
602 array($dbuser, $vals[
'satisfied'], $vals[
'measure'],
603 $scope_id, null, $obj_id, $vals[
'score_raw'],
604 $vals[
'score_min'], $vals[
'score_max'],
605 $vals[
'progress_measure'], $vals[
'completion_status'])
618 protected static function ensureObjectDataCacheExistence()
625 $ilObjDataCache = $DIC[
"ilObjDataCache"];
631 require_once
'./Services/Object/classes/class.ilObjectDataCache.php';
632 $ilObjDataCache =
new ilObjectDataCache();
633 $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.
static setGlobalObjectives($userId, $packageId, $data)
static scormPlayerUnload($userId=null, $packageId, $time_from_lms)
Class ilSCORM2004StoreData.
foreach($_POST as $key=> $value) $res
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)
if(empty($password)) $table
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)