如何获得scorm活动验证并向注册用户显示

时间:2016-12-23 05:19:36

标签: php curl moodle scorm moodle-api

我正在使用api将scorm包上传到moodle。它正在上传scorm但是如何获得scorm活动验证并将其显示给注册用户。这是代码,

<?php

require_once('./curl.php');

$token = 'be0752276987d97c02e52b55f4314a5d';
$domainname = 'http://10.20.30.23:8080/fqu/lms'; //http://www.yourmoodle.com
$restformat = 'json';
$GLOBALS['serverurl'] = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token .(($restformat == 'json')?'&moodlewsrestformat=' . $restformat:'');

function file_upload()
{
//$imagepath = 'http://10.20.30.30/PHP-REST/uploads/address.txt';
$functionname = 'core_files_upload';
$fileinfo = new stdClass();
$fileinfo->contextid = 9;//9;
$fileinfo->component = 'user';//'user';
$fileinfo->filearea = 'draft';//'private';
$fileinfo->itemid = 621029058;
$fileinfo->filepath = '/';

$fileinfo->filename = 'SCO_Test_file.zip';
$fileinfo->filecontent = base64_encode('SCO_Test_file content');

print_r(count((array)$fileinfo));

//$resp = runCurl_for_URI($fileinfo, $functionname);
$resp = runCurl($fileinfo, $functionname);
return $resp;
}


function runCurl($params, $functionname){
$serverurl = $GLOBALS['serverurl'] . '&wsfunction='.$functionname;
//return $serverurl;
header('Content-Type: text/plain');

$curl = new curl;
$resp = $curl->post($serverurl, $params);
//$resp = $curl->post('http://10.20.30.23:8080/fqu/lms/webservice/rest/server.php?wstoken=be0752276987d97c02e52b55f4314a5d&wsfunction=core_files_upload&moodlewsrestformat=json&contextid=9&component=user&filearea=draft&itemid=5478924&filepath=/&filename=address.txt&filecontent=address%20text%20file%20content');
$response = json_decode($resp);

return $response;
if($response->errorcode){
    return 0;
} else {
    return $response[0]->id;
}
}

function runCurl_for_URI($uri_params, $functionname){
$serverurl = $GLOBALS['serverurl'] . '&wsfunction='.$functionname;

$queryString = "";
foreach ((array)$uri_params as $key => $value){
    $queryString .= '&'.$key.'='.$value;
}

header('Content-Type: text/plain');

$curl = new curl;

$resp = $curl->post($serverurl . $queryString);
$response = json_decode($resp);

return $response;
if($response->errorcode){
    return 0;
} else {
    return $response[0]->id;
}
}

print_r(file_upload());
?>

我正在使用https://github.com/dongsheng/cURL的curl函数。任何帮助,我该怎么做。其实我是moodle和scorm的新手,我不知道从哪里开始。

0 个答案:

没有答案