Learnpath: Convert first param of learnpath::getLpFromSession() from string course code to int course ID - refs BT#19044

pull/4017/head
Yannick Warnier 4 years ago
parent 9bbe86a252
commit 2e364b8bf5
  1. 14
      public/main/lp/ScormApi.php
  2. 12
      public/main/lp/learnpath.class.php
  3. 2
      public/main/lp/learnpathItem.class.php
  4. 2
      public/main/lp/lp_ajax_initialize.php
  5. 4
      public/main/lp/lp_ajax_save_item.php
  6. 2
      public/main/lp/lp_ajax_save_objectives.php
  7. 2
      public/main/lp/lp_ajax_switch_item_toc.php

@ -56,12 +56,8 @@ class ScormApi
) { ) {
$debug = 0; $debug = 0;
$return = null; $return = null;
$courseCode = api_get_course_id(); if (empty($courseId)) {
if (!empty($courseId)) { $courseId = api_get_course_int_id();
$courseInfo = api_get_course_info_by_id($courseId);
if ($courseInfo) {
$courseCode = $courseInfo['code'];
}
} }
if ($debug > 0) { if ($debug > 0) {
@ -72,10 +68,10 @@ class ScormApi
error_log("SCORE: $score - max:$max - min: $min - status:$status"); error_log("SCORE: $score - max:$max - min: $min - status:$status");
error_log("TIME: $time - suspend: $suspend - location: $location - core_exit: $core_exit"); error_log("TIME: $time - suspend: $suspend - location: $location - core_exit: $core_exit");
error_log("finish: $lmsFinish - navigatesAway: $userNavigatesAway"); error_log("finish: $lmsFinish - navigatesAway: $userNavigatesAway");
error_log("courseCode: $courseCode"); error_log("courseId: $courseId");
} }
$myLP = learnpath::getLpFromSession($courseCode, $lp_id, $user_id); $myLP = learnpath::getLpFromSession($courseId, $lp_id, $user_id);
if (!is_a($myLP, 'learnpath')) { if (!is_a($myLP, 'learnpath')) {
if ($debug) { if ($debug) {
@ -606,7 +602,7 @@ class ScormApi
* -'last' * -'last'
* - a real item ID * - a real item ID
*/ */
$mylp = learnpath::getLpFromSession(api_get_course_id(), $lpId, $user_id); $mylp = learnpath::getLpFromSession(api_get_course_int_id(), $lpId, $user_id);
$new_item_id = 0; $new_item_id = 0;
switch ($next_item) { switch ($next_item) {
case 'next': case 'next':

@ -7234,13 +7234,13 @@ class learnpath
} }
/** /**
* @param string $courseCode * @param int $courseId
* @param int $lpId * @param int $lpId
* @param int $user_id * @param int $user_id
* *
* @return learnpath * @return learnpath
*/ */
public static function getLpFromSession($courseCode, $lpId, $user_id) public static function getLpFromSession(int $courseId, int $lpId, int $user_id)
{ {
$debug = 0; $debug = 0;
$learnPath = null; $learnPath = null;
@ -7262,11 +7262,11 @@ class learnpath
} }
if (!is_object($learnPath)) { if (!is_object($learnPath)) {
$learnPath = new learnpath($lp, api_get_course_info($courseCode), $user_id); $learnPath = new learnpath($lp, api_get_course_info_by_id($courseId), $user_id);
if ($debug) { if ($debug) {
error_log('------getLpFromSession------'); error_log('------getLpFromSession------');
error_log('getLpFromSession: create new learnpath'); error_log('getLpFromSession: create new learnpath');
error_log("create new LP with $courseCode - $lpId - $user_id"); error_log("create new LP with $courseId - $lpId - $user_id");
error_log("lp_view_session_id: ".$learnPath->lp_view_session_id); error_log("lp_view_session_id: ".$learnPath->lp_view_session_id);
error_log("api_get_sessionid: ".api_get_session_id()); error_log("api_get_sessionid: ".api_get_session_id());
} }

@ -1749,7 +1749,7 @@ class learnpathItem
} else { } else {
// Calulate minimum and accumulated time // Calulate minimum and accumulated time
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$myLP = learnpath::getLpFromSession(api_get_course_id(), $this->lp_id, $user_id); $myLP = learnpath::getLpFromSession(api_get_course_int_id(), $this->lp_id, $user_id);
$timeLp = $myLP->getAccumulateWorkTime(); $timeLp = $myLP->getAccumulateWorkTime();
$timeTotalCourse = $myLP->getAccumulateWorkTimeTotalCourse(); $timeTotalCourse = $myLP->getAccumulateWorkTimeTotalCourse();
/* /*

@ -40,7 +40,7 @@ function initializeItem($lpId, $user_id, $view_id, $next_item, $startTime = 0)
* -'last' * -'last'
* - a real item ID * - a real item ID
*/ */
$mylp = learnpath::getLpFromSession(api_get_course_id(), $lpId, $user_id); $mylp = learnpath::getLpFromSession(api_get_course_int_id(), $lpId, $user_id);
$mylp->set_current_item($next_item); $mylp->set_current_item($next_item);
if ($debug) { if ($debug) {
error_log('In initialize_item() - new item is '.$next_item); error_log('In initialize_item() - new item is '.$next_item);

@ -41,8 +41,8 @@ echo ScormApi::saveItem(
(!empty($_REQUEST['loc']) ? $_REQUEST['loc'] : null), (!empty($_REQUEST['loc']) ? $_REQUEST['loc'] : null),
$interactions, $interactions,
(!empty($_REQUEST['core_exit']) ? $_REQUEST['core_exit'] : ''), (!empty($_REQUEST['core_exit']) ? $_REQUEST['core_exit'] : ''),
(!empty($_REQUEST['session_id']) ? $_REQUEST['session_id'] : ''), (!empty($_REQUEST['session_id']) ? (int) $_REQUEST['session_id'] : null),
(!empty($_REQUEST['course_id']) ? $_REQUEST['course_id'] : ''), (!empty($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : null),
(empty($_REQUEST['finish']) ? 0 : 1), (empty($_REQUEST['finish']) ? 0 : 1),
(empty($_REQUEST['userNavigatesAway']) ? 0 : 1), (empty($_REQUEST['userNavigatesAway']) ? 0 : 1),
(empty($_REQUEST['statusSignalReceived']) ? 0 : 1), (empty($_REQUEST['statusSignalReceived']) ? 0 : 1),

@ -29,7 +29,7 @@ function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = [])
if ($debug > 0) { if ($debug > 0) {
error_log('In xajax_save_objectives('.$lp_id.','.$user_id.','.$view_id.','.$item_id.',"'.(count($objectives) > 0 ? count($objectives) : '').'")', 0); error_log('In xajax_save_objectives('.$lp_id.','.$user_id.','.$view_id.','.$item_id.',"'.(count($objectives) > 0 ? count($objectives) : '').'")', 0);
} }
$mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id); $mylp = learnpath::getLpFromSession(api_get_course_int_id(), $lp_id, $user_id);
$mylpi = &$mylp->items[$item_id]; $mylpi = &$mylp->items[$item_id];
if (is_array($objectives) && count($objectives) > 0) { if (is_array($objectives) && count($objectives) > 0) {
foreach ($objectives as $index => $objective) { foreach ($objectives as $index => $objective) {

@ -33,7 +33,7 @@ function switch_item_toc($lpId, $userId, $viewId, $currentItem, $nextItem)
if ($debug > 0) { if ($debug > 0) {
error_log('In switch_item_toc('.$lpId.','.$userId.','.$viewId.','.$currentItem.','.$nextItem.')', 0); error_log('In switch_item_toc('.$lpId.','.$userId.','.$viewId.','.$currentItem.','.$nextItem.')', 0);
} }
$myLP = learnpath::getLpFromSession(api_get_course_id(), $lpId, $userId); $myLP = learnpath::getLpFromSession(api_get_course_int_id(), $lpId, $userId);
$newItemId = 0; $newItemId = 0;
$oldItemId = 0; $oldItemId = 0;
switch ($nextItem) { switch ($nextItem) {

Loading…
Cancel
Save