diff --git a/main/newscorm/scorm.class.php b/main/newscorm/scorm.class.php index 04ac514de0..59b0d2dd29 100755 --- a/main/newscorm/scorm.class.php +++ b/main/newscorm/scorm.class.php @@ -273,7 +273,7 @@ class scorm extends learnpath * * @return bool Returns -1 on error */ - public function import_manifest($courseCode, $userMaxScore = 1, $sessionId = 0) + public function import_manifest($courseCode, $userMaxScore = 1, $sessionId = 0, $userId = 0) { if ($this->debug > 0) { error_log('New LP - Entered import_manifest('.$courseCode.')', 0); @@ -281,6 +281,12 @@ class scorm extends learnpath $courseInfo = api_get_course_info($courseCode); $courseId = $courseInfo['real_id']; + if (empty($userId)) { + $userId = api_get_user_id(); + } else { + $userId = intval($userId); + } + // Get table names. $new_lp = Database::get_course_table(TABLE_LP_MAIN); $new_lp_item = Database::get_course_table(TABLE_LP_ITEM); @@ -322,7 +328,7 @@ class scorm extends learnpath TOOL_LEARNPATH, $this->lp_id, 'LearnpathAdded', - api_get_user_id() + $userId ); api_item_property_update( @@ -330,7 +336,7 @@ class scorm extends learnpath TOOL_LEARNPATH, $this->lp_id, 'visible', - api_get_user_id() + $userId ); } diff --git a/main/webservices/lp.php b/main/webservices/lp.php index 146fe3f1dd..806e1186aa 100644 --- a/main/webservices/lp.php +++ b/main/webservices/lp.php @@ -174,6 +174,7 @@ function WSImportLP($params) $fileData = base64_decode($params['file_data']); $uniqueFile = uniqid(); + $userId = 1; // admin $filePath = api_get_path(SYS_ARCHIVE_PATH) . $uniqueFile; file_put_contents($filePath, $fileData); @@ -198,12 +199,15 @@ function WSImportLP($params) $oScorm->import_manifest( $courseInfo['code'], $maxScore, - $sessionId + $sessionId, + $userId ); $oScorm->set_name($lpName); $oScorm->set_proximity($proximity, $courseId); $oScorm->set_maker($maker, $courseId); //$oScorm->set_jslib('scorm_api.php'); + + if ($debug) error_log('scorm was added'); return 1; } else { if ($debug) error_log('manifest data empty');