Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2363

Re: How to get course contents through to webservice ?

$
0
0
by Eseosa I.  

Hey Kathir, 


There is an exposed function to retrieve course related data 'core_course_get_contents.'


Modified from here: https://gist.github.com/jleyva/9687810


...

<?php

$token='<token_here>';


$domainname='<moodle domain url>';


$courseid=<course id>;



// REST RETURNED VALUES FORMAT
$restformat='json'; //Also possible in Moodle 2.2 and later: 'json'
//Setting it to 'json' will fail all calls on earlier Moodle version
$restformat= ($restformat=='json')?'&moodlewsrestformat='.$restformat:'';
/// REST CALL
header('Content-Type: text/plain');
require_once('./curl.php');
$curl=newcurl;
$functionname='core_course_get_contents';
$params=array(
'courseid'=>$courseid
);
$serverurl=$domainname.'/webservice/rest/server.php'.'?wstoken='.$studenttoken.'&wsfunction='.$functionname;
$resp=$curl->post($serverurl.$restformat, $params);
$resp=json_decode($resp); var_dump($resp); ...



Regards,

-E


Viewing all articles
Browse latest Browse all 2363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>