コード例 #1
0
        $courses_dir = $sys_course_path.$courses_dir_list[$lp_course_code[$my_content_id]];
        //$scorm_lp_paths[$my_content_id]['path'] = str_replace(' ', '\\ ', $scorm_lp_paths[$my_content_id]['path']);
        $sco_path_temp = ($scorm_lp_paths[$my_content_id]['path'] == '/') ? '' : $scorm_lp_paths[$my_content_id]['path'];
        $scorm_lp_paths[$my_content_id]['ims'] = $courses_dir.'/scorm'.$sco_path_temp.'/imsmanifest.xml';

        // Generate an imsmanifest object to get more info about the learnpath from the file
        $oScorm = new scorm();
        // Check whether imsmanifest.xml exists at this location. If not, ignore the imsmanifest.
        // That should have been done before already, now.
        if (!is_file($scorm_lp_paths[$my_content_id]['ims'])) {
            if ($loglevel > 1) { Log::notice("!!! imsmanifest file not found at ".$scorm_lp_paths[$my_content_id]['ims'].' for old lp '.$my_content_id.' and new '.$lp_ids[$my_content_id]); }
            $manifest = false;
        } else {
            //echo "Parsing ".$scorm_lp_paths[$my_content_id]['ims']."<br />\n";
            // Parse manifest file
            $manifest = $oScorm->parse_manifest($scorm_lp_paths[$my_content_id]['ims']);
            // The title is already escaped in the method
            //$my_lp_title = api_convert_encoding($oScorm->get_title(),'ISO-8859-1',$oScorm->manifest_encoding);
            $my_lp_title = api_convert_encoding($oScorm->get_title(), 'ISO-8859-1', 'UTF-8');  // TODO: This "magic" conversion to be checked.
            if (!empty($my_lp_title)) {
                $my_new_lp = $db_name.$new_lp;
                $my_sql = "UPDATE $my_new_lp " .
                        "SET name = '$my_lp_title', " .
                        "default_encoding = '".strtoupper($oScorm->manifest_encoding)."' " .
                        "WHERE id = ".$lp_ids[$my_content_id];
                if ($loglevel > 1) { Log::notice("Updating title and encoding: ".$my_sql); }
                $my_res = Database::query($my_sql);
            }
        }

        /*
コード例 #2
0
ファイル: lp_upload.php プロジェクト: jloguercio/chamilo-lms
 $new_dir = api_replace_dangerous_char(trim($file_base_name));
 $result = learnpath::verify_document_size($s);
 if ($result == true) {
     throw new \Exception(get_lang('UplFileTooBig'));
 }
 $type = learnpath::get_package_type($s, basename($s));
 switch ($type) {
     case 'scorm':
         require_once 'scorm.class.php';
         $oScorm = new scorm();
         $manifest = $oScorm->import_local_package($s, $current_dir);
         if ($manifest === false) {
             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':
コード例 #3
0
ファイル: lp.php プロジェクト: daffef/chamilo-lms
/**
 * @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';
    }
}