How to get scorm activity validation and show to enrolled users

161 views Asked by At

I am using api to upload scorm package to moodle. It is uploading the scorm but How can get scorm activity validation and show it to enrolled user. Here is the code,

<?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());
?>

I am using curl function from https://github.com/dongsheng/cURL. Any help, How can I do that. Actually I am new to moodle and scorm, I don't know where to start.

0

There are 0 answers