throw new \Exception('Error import local package'); } if (!empty($manifest)) { $oScorm->parse_manifest($manifest); $oScorm->import_manifest(api_get_course_id(), $_REQUEST['use_max_score']); } $proximity = ''; if (!empty($_REQUEST['content_proximity'])) { $proximity = Database::escape_string($_REQUEST['content_proximity']); } $maker = ''; if (!empty($_REQUEST['content_maker'])) { $maker = Database::escape_string($_REQUEST['content_maker']); } $oScorm->set_proximity($proximity); $oScorm->set_maker($maker); $oScorm->set_jslib('scorm_api.php'); break; case 'aicc': require_once 'aicc.class.php'; $oAICC = new aicc(); $config_dir = $oAICC->import_local_package($s, $current_dir); if (!empty($config_dir)) { $oAICC->parse_config_files($config_dir); $oAICC->import_aicc(api_get_course_id()); } $proximity = ''; if (!empty($_REQUEST['content_proximity'])) { $proximity = Database::escape_string($_REQUEST['content_proximity']); } $maker = '';
/** * @param array $params * @return int|string */ function WSImportLP($params) { global $debug; if (!WSHelperVerifyKey($params)) { return return_error(WS_ERROR_SECRET_KEY); } if ($debug) { error_log('WSImportLP'); } $courseIdName = $params['course_id_name']; $courseIdValue = $params['course_id_value']; $sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null; $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null; $lpName = $params['lp_name']; $courseInfo = CourseManager::getCourseInfoFromOriginalId($courseIdValue, $courseIdName); $courseId = $courseInfo['real_id']; if (empty($courseInfo)) { if ($debug) { error_log('Course not found'); } return 'Course not found'; } $sessionId = 0; if (!empty($sessionIdName) && !empty($sessionIdValue)) { $sessionId = SessionManager::get_session_id_from_original_id($sessionIdValue, $sessionIdName); if (empty($sessionId)) { if ($debug) { error_log('Session not found'); } return 'Session not found'; } } $proximity = 'local'; $maker = 'Scorm'; $maxScore = ''; //$_REQUEST['use_max_score'] $oScorm = new scorm($courseInfo['code']); $fileData = base64_decode($params['file_data']); $uniqueFile = uniqid(); $userId = 1; // admin $filePath = api_get_path(SYS_ARCHIVE_PATH) . $uniqueFile; file_put_contents($filePath, $fileData); $fileName = $params['filename']; $fileInfo = array('tmp_name' => $filePath, 'name' => $fileName); $manifest = $oScorm->import_package($fileInfo, '', $courseInfo); if (!$manifest) { if ($debug) { error_log('manifest.xml file not found'); } //if api_set_failure return 'manifest.xml file not found'; } $manifestData = $oScorm->parse_manifest($manifest); if (!empty($manifestData)) { $oScorm->import_manifest($courseInfo['code'], $maxScore, $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'); } return 'manifest data empty'; } }