ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSCORM2004StoreData Class Reference

Class ilSCORM2004StoreData. More...

+ Collaboration diagram for ilSCORM2004StoreData:

Static Public Member Functions

static scormPlayerUnload (int $packageId, int $refId, bool $time_from_lms, ?int $userId=null)
 
static checkIfAllowed (int $packageId, int $userId, int $hash)
 
static persistCMIData (int $packageId, int $refId, string $defaultLessonMode, bool $comments, bool $interactions, bool $objectives, bool $time_from_lms, ?string $data=null, ?int $userId=null)
 
static setCMIData (int $userId, int $packageId, object $data, bool $getComments, bool $getInteractions, bool $getObjectives)
 
static writeGObjective (int $user, int $package, ?array $g_data)
 
static syncGlobalStatus (int $userId, int $packageId, int $refId, object $data, int $new_global_status, bool $time_from_lms)
 

Static Protected Member Functions

static setGlobalObjectives (int $userId, int $packageId, object $data)
 

Detailed Description

Member Function Documentation

◆ checkIfAllowed()

static ilSCORM2004StoreData::checkIfAllowed ( int  $packageId,
int  $userId,
int  $hash 
)
static

Definition at line 91 of file class.ilSCORM2004StoreData.php.

91 : void
92 {
93 global $DIC;
94
95 $ilDB = $DIC->database();
96 $res = $ilDB->queryF(
97 'select hash from sahs_user where obj_id=%s AND user_id=%s AND hash_end>%s',
98 array('integer', 'integer', 'timestamp'),
99 array($packageId, $userId, date('Y-m-d H:i:s'))
100 );
101 $rowtmp = $ilDB->fetchAssoc($res);
102 if ($rowtmp && (int) $rowtmp['hash'] == $hash) {
103 return;
104 }
105
106 die("not allowed");
107 }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26
$packageId
Definition: storeScorm.php:24

References $DIC, $ilDB, $packageId, and $res.

◆ persistCMIData()

static ilSCORM2004StoreData::persistCMIData ( int  $packageId,
int  $refId,
string  $defaultLessonMode,
bool  $comments,
bool  $interactions,
bool  $objectives,
bool  $time_from_lms,
?string  $data = null,
?int  $userId = null 
)
static

Definition at line 125 of file class.ilSCORM2004StoreData.php.

135 : void {
136 global $DIC;
137
138 $ilLog = ilLoggerFactory::getLogger('sc13');
139
140 if ($defaultLessonMode === "browse") {
141 return;
142 }
143
144 $jsMode = strpos($_SERVER['HTTP_ACCEPT'], 'text/javascript') !== false;//ToDo: Avoid $_SERVER
145
146 $data = json_decode(is_string($data) ? $data : file_get_contents('php://input'));
147 $ilLog->debug("dataTo_setCMIData: " . file_get_contents('php://input'));
148 if (!$data) {
149 return;
150 }
151 if ($userId == null) {
152 $userId = (int) $data->p;
153 self::checkIfAllowed($packageId, $userId, $data->hash);
154 // header('Access-Control-Allow-Origin: http://localhost:50012');//just for tests - not for release UK
155 }
157 $userId,
159 $data,
160 $comments,
163 );
164
165 //$new_global_status=ilSCORM2004StoreData::setGlobalObjectivesAndGetGlobalStatus($userId, $packageId, $data);
167 $new_global_status = $data->now_global_status;
168 $return["new_global_status"] = $new_global_status;
169
170 // mantis #30293
171 $score_scaled = $data->node[0][35];
172 if ($score_scaled != null) {
174 ilLTIAppEventListener::handleOutcomeWithoutLP($packageId, $userId, $score_scaled * 100);
175 }
176 }
177
179
180 $ilLog->debug("SCORM: return of persistCMIData: " . json_encode($return));
181 if ($jsMode) {
182 header('Content-Type: text/javascript; charset=UTF-8');
183 print(json_encode($return));
184 } else {
185 header('Content-Type: text/html; charset=UTF-8');
186 print(var_export($return, true));
187 }
188 }
static handleOutcomeWithoutLP(int $a_obj_id, int $a_usr_id, ?float $a_percentage)
static getLogger(string $a_component_id)
Get component logger.
static syncGlobalStatus(int $userId, int $packageId, int $refId, object $data, int $new_global_status, bool $time_from_lms)
static setCMIData(int $userId, int $packageId, object $data, bool $getComments, bool $getInteractions, bool $getObjectives)
static setGlobalObjectives(int $userId, int $packageId, object $data)
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$interactions
$time_from_lms
$comments
$objectives
if($DIC->http() ->wrapper() ->query() ->has('do')) $defaultLessonMode
$refId
Definition: xapitoken.php:58

Referenced by ilSCORM13PlayerGUI\executeCommand().

+ Here is the caller graph for this function:

◆ scormPlayerUnload()

static ilSCORM2004StoreData::scormPlayerUnload ( int  $packageId,
int  $refId,
bool  $time_from_lms,
?int  $userId = null 
)
static

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

28 : void
29 {
30 global $DIC;
31
32 $ilDB = $DIC->database();
33
34 // $data = json_decode(is_string($data) ? $data : file_get_contents('php://input'));
35 $data = json_decode(file_get_contents('php://input'));
36 if (!$data) {
37 return;
38 }
39 if ($userId == null) {
40 $userId = (int) $data->p;
41 self::checkIfAllowed($packageId, $userId, $data->hash);
42 }
43 $last_visited = null;
44 if ($data->last != "") {
45 $last_visited = $data->last;
46 }
47 $endDate = date(
48 'Y-m-d H:i:s',
49 mktime(
50 (int) date('H'),
51 (int) date('i') + 5,
52 (int) date('s'),
53 (int) date('m'),
54 (int) date('d'),
55 (int) date('Y')
56 )
57 );
58 $total_time_sec = null;
59 if ($data->total_time_sec != "") {
60 $total_time_sec = $data->total_time_sec;
61 $ilDB->manipulateF(
62 'UPDATE sahs_user
63 SET total_time_sec = %s, last_visited = %s, hash_end =%s, last_access = %s
64 WHERE obj_id = %s AND user_id = %s',
65 array('integer', 'text', 'timestamp', 'timestamp', 'integer', 'integer'),
66 array($total_time_sec, $last_visited, $endDate, date('Y-m-d H:i:s'), $packageId, $userId)
67 );
68 if ($time_from_lms == true) {
69 self::ensureObjectDataCacheExistence();
70 global $DIC;
71
72 $ilObjDataCache = $DIC["ilObjDataCache"];
73 // sync access number and time in read event table
75 //end sync access number and time in read event table
76 }
77 } else {
78 $ilDB->manipulateF(
79 'UPDATE sahs_user
80 SET last_visited = %s, hash_end =%s, last_access = %s
81 WHERE obj_id = %s AND user_id = %s',
82 array('text', 'timestamp', 'timestamp', 'integer', 'integer'),
83 array($last_visited, $endDate, date('Y-m-d H:i:s'), $packageId, $userId)
84 );
85 }
86
87 header('Content-Type: text/plain; charset=UTF-8');
88 print("");
89 }
static _syncReadEvent(int $a_obj_id, int $a_user_id, string $a_type, int $a_ref_id, ?bool $time_from_lms=null)
Synch read event table.

References $data, $DIC, $ilDB, $packageId, $refId, $time_from_lms, ilSCORM2004Tracking\_syncReadEvent(), ILIAS\UI\examples\Symbol\Glyph\Header\header(), and ILIAS\Repository\int().

Referenced by ilSCORM13PlayerGUI\executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCMIData()

static ilSCORM2004StoreData::setCMIData ( int  $userId,
int  $packageId,
object  $data,
bool  $getComments,
bool  $getInteractions,
bool  $getObjectives 
)
static
Returns
mixed[]

Definition at line 193 of file class.ilSCORM2004StoreData.php.

200 : array {
201 global $DIC;
202
203 $ilDB = $DIC->database();
204 $ilLog = ilLoggerFactory::getLogger('sc13');
205
206 $result = array();
207
208 if (!$data) {
209 return $result;
210 }
211
212 $i_check = $data->i_check;
213 $i_set = $data->i_set;
214 $b_node_update = false;
215 $cmi_node_id = null;
216 $a_map_cmi_interaction_id = array();
217
218 $tables = array('node', 'comment', 'interaction', 'objective', 'correct_response');
219
220 foreach ($tables as $table) {
221 if (!is_array($data->$table)) {
222 continue;
223 }
224
225 $ilLog->debug("SCORM: setCMIData, table -" . $table . "-");
226
227 // now iterate through data rows from input
228 foreach ($data->$table as &$row) {
229 $ilLog->debug("Checking table: " . $table);
230
231 switch ($table) {
232 case 'node': //is always first and has only 1 row
233
234 $res = $ilDB->queryF(
235 'SELECT cmi_node_id FROM cmi_node WHERE cp_node_id = %s and user_id = %s',
236 array('integer', 'integer'),
237 array($row[19], $userId)
238 );
239 $rowtmp = $ilDB->fetchAssoc($res);
240
241 if ($rowtmp != null) {
242 $cmi_node_id = $rowtmp['cmi_node_id'];
243 $b_node_update = true;
244 } else {
245 $cmi_node_id = $ilDB->nextId('cmi_node');
246 $b_node_update = false;
247 }
248 $ilLog->debug("setCMIdata with cmi_node_id = " . $cmi_node_id);
249 $a_data = array(
250 'accesscount' => array('integer', $row[0]),
251 'accessduration' => array('text', $row[1]),
252 'accessed' => array('text', $row[2]),
253 'activityabsduration' => array('text', $row[3]),
254 'activityattemptcount' => array('integer', $row[4]),
255 'activityexpduration' => array('text', $row[5]),
256 'activityprogstatus' => array('integer', $row[6]),
257 'attemptabsduration' => array('text', $row[7]),
258 'attemptcomplamount' => array('float', $row[8]),
259 'attemptcomplstatus' => array('integer', $row[9]),
260 'attemptexpduration' => array('text', $row[10]),
261 'attemptprogstatus' => array('integer', $row[11]),
262 'audio_captioning' => array('integer', $row[12]),
263 'audio_level' => array('float', $row[13]),
264 'availablechildren' => array('text', $row[14]),
265 'cmi_node_id' => array('integer', $cmi_node_id),
266 'completion' => array('float', $row[16]),
267 'completion_status' => array('text', $row[17]),
268 'completion_threshold' => array('text', $row[18]),
269 'cp_node_id' => array('integer', $row[19]),
270 'created' => array('text', $row[20]),
271 'credit' => array('text', $row[21]),
272 'delivery_speed' => array('float', $row[22]),
273 'c_entry' => array('text', $row[23]),
274 'c_exit' => array('text', $row[24]),
275 'c_language' => array('text', $row[25]),
276 'launch_data' => array('clob', $row[26]),
277 'learner_name' => array('text', $row[27]),
278 'location' => array('text', $row[28]),
279 'c_max' => array('float', $row[29]),
280 'c_min' => array('float', $row[30]),
281 'c_mode' => array('text', $row[31]),
282 'modified' => array('text', $row[32]),
283 'progress_measure' => array('float', $row[33]),
284 'c_raw' => array('float', $row[34]),
285 'scaled' => array('float', $row[35]),
286 'scaled_passing_score' => array('float', $row[36]),
287 'session_time' => array('text', $row[37]),
288 'success_status' => array('text', $row[38]),
289 'suspend_data' => array('clob', $row[39]),
290 'total_time' => array('text', $row[40]),
291 'user_id' => array('integer', $userId),
292 'c_timestamp' => array('timestamp', date('Y-m-d H:i:s')),
293 'additional_tables' => array('integer', $i_check)
294 );
295
296 if ($b_node_update == false) {
297 $ilDB->insert('cmi_node', $a_data);
298 $ilLog->debug("inserted");
299 } else {
300 $ilDB->update('cmi_node', $a_data, array('cmi_node_id' => array('integer', $cmi_node_id)));
301 $ilLog->debug("updated");
302 }
303
304 if ($b_node_update == true) {
305 //remove
306 if ($i_set > 7) {
307 $i_set -= 8;
308 if ($getComments) {
309 $q = 'DELETE FROM cmi_comment WHERE cmi_node_id = %s';
310 $ilDB->manipulateF($q, array('integer'), array($cmi_node_id));
311 }
312 }
313 if ($i_set > 3) {
314 $i_set -= 4;
315 if ($getInteractions) {
316 $q = '
317 DELETE cmir
318 FROM cmi_correct_response cmir
319 INNER JOIN cmi_interaction cmii ON cmii.cmi_interaction_id = cmir.cmi_interaction_id
320 WHERE cmii.cmi_node_id = %s
321 ';
322 $ilDB->manipulateF($q, array('integer'), array($cmi_node_id));
323 }
324 }
325 if ($i_set > 1) {
326 $i_set -= 2;
327 if ($getInteractions) {
328 $q = 'DELETE FROM cmi_interaction WHERE cmi_node_id = %s';
329 $ilDB->manipulateF($q, array('integer'), array($cmi_node_id));
330 }
331 }
332 if ($i_set > 0) {
333 $i_set = 0;
334 if ($getObjectives) {
335 $q = 'DELETE FROM cmi_objective WHERE cmi_node_id = %s';
336 $ilDB->manipulateF($q, array('integer'), array($cmi_node_id));
337 }
338 }
339 //end remove
340 }
341 //to send to client
342 $result[(string) $row[19]] = $cmi_node_id;
343 break;
344
345 case 'comment':
346 $row[0] = $ilDB->nextId('cmi_comment');
347
348 $ilDB->insert('cmi_comment', array(
349 'cmi_comment_id' => array('integer', $row[0]),
350 'cmi_node_id' => array('integer', $cmi_node_id),
351 'c_comment' => array('clob', $row[2]),
352 'c_timestamp' => array('text', $row[3]),
353 'location' => array('text', $row[4]),
354 'sourceislms' => array('integer', $row[5])
355 ));
356 break;
357
358 case 'interaction':
359 $cmi_interaction_id = $ilDB->nextId('cmi_interaction');
360 $a_map_cmi_interaction_id[] = array($row[0], $cmi_interaction_id);
361 $ilDB->insert('cmi_interaction', array(
362 'cmi_interaction_id' => array('integer', $cmi_interaction_id),
363 'cmi_node_id' => array('integer', $cmi_node_id),
364 'description' => array('clob', $row[2]),
365 'id' => array('text', $row[3]),
366 'latency' => array('text', $row[4]),
367 'learner_response' => array('clob', $row[5]),
368 'result' => array('text', $row[6]),
369 'c_timestamp' => array('text', $row[7]),
370 'c_type' => array('text', $row[8]),
371 'weighting' => array('float', $row[9])
372 ));
373 break;
374
375 case 'objective':
376 $row[2] = $ilDB->nextId('cmi_objective');
377 $cmi_interaction_id = null;
378 if ($row[0] != null) {
379 foreach ($a_map_cmi_interaction_id as $i => $value) {
380 if ($row[0] == $value[0]) {
381 $cmi_interaction_id = $value[1];
382 }
383 }
384 }
385 $ilDB->insert('cmi_objective', array(
386 'cmi_interaction_id' => array('integer', $cmi_interaction_id),
387 'cmi_node_id' => array('integer', $cmi_node_id),
388 'cmi_objective_id' => array('integer', $row[2]),
389 'completion_status' => array('text', $row[3]),
390 'description' => array('clob', $row[4]),
391 'id' => array('text', $row[5]),
392 'c_max' => array('float', $row[6]),
393 'c_min' => array('float', $row[7]),
394 'c_raw' => array('float', $row[8]),
395 'scaled' => array('float', $row[9]),
396 'progress_measure' => array('float', $row[10]),
397 'success_status' => array('text', $row[11]),
398 'scope' => array('text', $row[12])
399 ));
400 break;
401
402 case 'correct_response':
403 $cmi_interaction_id = null;
404 if ($row[1] !== null) {
405 foreach ($a_map_cmi_interaction_id as $i => $value) {
406 if ($row[1] == $value[0]) {
407 $cmi_interaction_id = $value[1];
408 }
409 }
410 $row[0] = $ilDB->nextId('cmi_correct_response');
411 $ilDB->insert('cmi_correct_response', array(
412 'cmi_correct_resp_id' => array('integer', $row[0]),
413 'cmi_interaction_id' => array('integer', $cmi_interaction_id),
414 'pattern' => array('text', $row[2])
415 ));
416 }
417 break;
418 }
419 }
420 }
421 return $result;
422 }
$q
Definition: shib_logout.php:23

◆ setGlobalObjectives()

static ilSCORM2004StoreData::setGlobalObjectives ( int  $userId,
int  $packageId,
object  $data 
)
staticprotected

Definition at line 424 of file class.ilSCORM2004StoreData.php.

424 : void
425 {
426 $ilLog = ilLoggerFactory::getLogger('sc13');
427 $changed_seq_utilities = $data->changed_seq_utilities;
428 $ilLog->debug("SCORM2004 adl_seq_utilities changed: " . $changed_seq_utilities);
429 if ($changed_seq_utilities == 1) {
430 $returnAr = ilSCORM2004StoreData::writeGObjective($userId, $packageId, (array) $data->adl_seq_utilities);
431 }
432 }
static writeGObjective(int $user, int $package, ?array $g_data)

References $data, $packageId, ilLoggerFactory\getLogger(), and writeGObjective().

+ Here is the call graph for this function:

◆ syncGlobalStatus()

static ilSCORM2004StoreData::syncGlobalStatus ( int  $userId,
int  $packageId,
int  $refId,
object  $data,
int  $new_global_status,
bool  $time_from_lms 
)
static

Definition at line 661 of file class.ilSCORM2004StoreData.php.

661 : void
662 {
663 global $DIC;
664 $ilDB = $DIC->database();
665 $ilLog = $DIC["ilLog"];
666 $saved_global_status = $data->saved_global_status;
667 $ilLog->write("saved_global_status=" . $saved_global_status);
668
669 //update percentage_completed, sco_total_time_sec,status in sahs_user
670 $totalTime = (int) $data->totalTimeCentisec;
671 $totalTime = round($totalTime / 100);
672 $ilDB->queryF(
673 'UPDATE sahs_user SET sco_total_time_sec=%s, status=%s, percentage_completed=%s WHERE obj_id = %s AND user_id = %s',
674 array('integer', 'integer', 'integer', 'integer', 'integer'),
675 array($totalTime, $new_global_status, $data->percentageCompleted, $packageId, $userId)
676 );
677
678 self::ensureObjectDataCacheExistence();
679
680 $ilObjDataCache = $DIC["ilObjDataCache"];
681
682 // update learning progress
683 if ($new_global_status != null) {//could only happen when synchronising from SCORM Offline Player
685
686 // here put code for soap to MaxCMS e.g. when if($saved_global_status != $new_global_status)
687 }
688 // sync access number and time in read event table
689 if ($time_from_lms == false) {
691 }
692 //end sync access number and time in read event table
693 }
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)

References $data, $DIC, $ilDB, $packageId, $refId, $time_from_lms, ilSCORM2004Tracking\_syncReadEvent(), ilLPStatusWrapper\_updateStatus(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ writeGObjective()

static ilSCORM2004StoreData::writeGObjective ( int  $user,
int  $package,
?array  $g_data 
)
static
Returns
mixed[]|null[]

Definition at line 440 of file class.ilSCORM2004StoreData.php.

440 : array
441 {
442 global $DIC;
443 $ilDB = $DIC->database();
444 $ilLog = ilLoggerFactory::getLogger('sc13');
445 $ilLog->debug("SCORM2004 writeGObjective");
446
447 $returnAr = array(null, null, null);
448
449 //iterate over assoziative array
450 if ($g_data == null) {
451 return $returnAr;
452 }
453
454 $rows_to_insert = array();
455
456 foreach ($g_data as $key => $value) {
457 $ilLog->debug("SCORM2004 writeGObjective -key: " . $key);
458 //objective
459 //learner = ilias learner id
460 //scope = null / course
461 foreach ($value as $skey => $svalue) {
462 $ilLog->debug("SCORM2004 writeGObjective -skey: " . $skey);
463 //we always have objective and learner id
464 // var_dump($svalue->$user->{"null"});
465 // die();
466 // if ($g_data->$key->$skey->$user->$package) { //check
467 // $o_value = $g_data->$key->$skey->$user->$package;
468 // $scope = $package;
469 // } else { //UK: is this okay? can $scope=0 and $user->{"null"}; when is $scope used?
470 // //scope 0
471 // $o_value = $g_data->$key->$skey->$user->{"null"};
472 // //has to be converted to NULL in JS Later
473 // $scope = 0;
474 // }
475 if (isset($svalue->$user->$package)) {
476 $o_value = $svalue->$user->$package;
477 $scope = $package;
478 } else { //UK: is this okay? can $scope=0 and $user->{"null"}; when is $scope used?
479 //scope 0
480 $o_value = null;
481 //has to be converted to NULL in JS Later
482 $scope = 0;
483 }
484
485 //insert into database
486 $objective_id = $skey;
487 $toset = $o_value;
488 $dbuser = $user;
489 if ($key === "status") {
490 //special handling for status
491 // $completed = $g_data->$key->$skey->$user->{"completed"};
492 // $measure = $g_data->$key->$skey->$user->{"measure"};
493 // $satisfied = $g_data->$key->$skey->$user->{"satisfied"};
494 $completed = $svalue->$user->{"completed"};
495 $measure = $svalue->$user->{"measure"};
496 $satisfied = $svalue->$user->{"satisfied"};
497
498 $returnAr = array($completed, $satisfied, $measure);
499
500 $obj = '-course_overall_status-';
501 $pkg_id = $package;
502
503 $res = $ilDB->queryF(
504 '
505 SELECT user_id FROM cmi_gobjective
506 WHERE objective_id =%s
507 AND user_id = %s
508 AND scope_id = %s',
509 array('text', 'integer', 'integer'),
510 array($obj, $dbuser, $pkg_id)
511 );
512 $ilLog->debug("SCORM2004 Count is: " . $ilDB->numRows($res));
513 if (!$ilDB->numRows($res)) {
514 $ilDB->manipulateF(
515 '
516 INSERT INTO cmi_gobjective
517 (user_id, status, scope_id, measure, satisfied, objective_id)
518 VALUES (%s, %s, %s, %s, %s, %s)',
519 array('integer', 'text', 'integer', 'text', 'text', 'text'),
520 array($dbuser, $completed, $pkg_id, $measure, $satisfied, $obj)
521 );
522 $ilLog->debug("SCORM2004 cmi_gobjective Insert status=" . $completed . " scope_id=" . $pkg_id . " measure=" . $measure . " satisfied=" . $satisfied . " objective_id=" . $obj);
523 } else {
524 $ilDB->manipulateF(
525 '
526 UPDATE cmi_gobjective
527 SET status = %s,
528 measure = %s,
529 satisfied = %s
530 WHERE objective_id = %s
531 AND user_id = %s
532 AND scope_id = %s',
533 array('text', 'text', 'text', 'text', 'integer', 'integer'),
534 array($completed, $measure, $satisfied, $obj, $dbuser, $pkg_id)
535 );
536 // $ilLog->debug("SCORM2004 cmi_gobjective Update status=" . $completed . " scope_id=" . $pkg_id . " measure=" . $measure . " satisfied=" . $satisfied . " objective_id=" . $obj);
537 }
538 } else { //add it to the rows_to_insert
539 //create the row if this is the first time it has been found
540 if ($rows_to_insert[$objective_id] == null) {
541 $rows_to_insert[$objective_id] = array();
542 }
543 $rows_to_insert[$objective_id][$key] = $toset;
544 }
545 }
546 }
547
548 //Get the scope for all the global objectives!!!
549 $res = $ilDB->queryF(
550 "SELECT global_to_system FROM cp_package WHERE obj_id = %s",
551 array('text'),
552 array($package)
553 );
554
555 $scope_id = ($ilDB->fetchObject($res)->global_to_system) ? 0 : $package;
556
557 //build up the set to look for in the query
558 $existing_key_template = "";
559 foreach (array_keys($rows_to_insert) as $obj_id) {
560 $existing_key_template .= "'{$obj_id}',";
561 }
562 //remove trailing ','
563 $existing_key_template = substr($existing_key_template, 0, -1);
564 $existing_keys = array();
565
566 if ($existing_key_template != "") {
567 //Get the ones that need to be updated in a single query
568 $res = $ilDB->queryF(
569 "SELECT objective_id
570 FROM cmi_gobjective
571 WHERE user_id = %s
572 AND scope_id = %s
573 AND objective_id IN ($existing_key_template)",
574 array('integer', 'integer'),
575 array($dbuser, $scope_id)
576 );
577
578 while ($row = $ilDB->fetchAssoc($res)) {
579 $existing_keys[] = $row['objective_id'];
580 }
581 }
582
583 foreach ($rows_to_insert as $obj_id => $vals) {
584 if (in_array($obj_id, $existing_keys)) {
585 $ilDB->manipulateF(
586 "UPDATE cmi_gobjective
587 SET satisfied=%s,
588 measure=%s,
589 score_raw=%s,
590 score_min=%s,
591 score_max=%s,
592 completion_status=%s,
593 progress_measure=%s
594 WHERE objective_id = %s
595 AND user_id = %s
596 AND scope_id = %s",
597 array('text',
598 'text',
599 'text',
600 'text',
601 'text',
602 'text',
603 'text',
604 'text',
605 'integer',
606 'integer'
607 ),
608 array($vals['satisfied'],
609 $vals["measure"],
610 $vals["score_raw"],
611 $vals["score_min"],
612 $vals["score_max"],
613 $vals["completion_status"],
614 $vals["progress_measure"],
615 $obj_id,
616 $dbuser,
617 $scope_id
618 )
619 );
620 } else {
621 $ilDB->manipulateF(
622 "INSERT INTO cmi_gobjective
623 (user_id, satisfied, measure, scope_id, status, objective_id,
624 score_raw, score_min, score_max, progress_measure, completion_status)
625 VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
626 array('integer',
627 'text',
628 'text',
629 'integer',
630 'text',
631 'text',
632 'text',
633 'text',
634 'text',
635 'text',
636 'text'
637 ),
638 array($dbuser,
639 $vals['satisfied'],
640 $vals['measure'],
641 $scope_id,
642 null,
643 $obj_id,
644 $vals['score_raw'],
645 $vals['score_min'],
646 $vals['score_max'],
647 $vals['progress_measure'],
648 $vals['completion_status']
649 )
650 );
651 }
652 }
653
654 // update learning progress here not necessary because integrated in setCMIdata
655 // check _updateStatus for cmi_gobjective
656 // ilLPStatusWrapper::_updateStatus($package, $user);
657
658 return $returnAr;
659 }
$scope
Definition: ltiregstart.php:51

References $DIC, $ilDB, $res, $scope, and ilLoggerFactory\getLogger().

Referenced by setGlobalObjectives().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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