How to get course contents through to webservice ?

How to get course contents through to webservice ?

by Kathir Rajaraman -
Number of replies: 1
Dear all,

How to get course contents through to webservice ? I am bignner of the webservice. 

My doubt is when i updated the course get course contents and i send to android . How ? Its possible ?

Can you explain step by step ?  Please provide sample codes also 


Thanks

Kathir



Average of ratings: -
In reply to Kathir Rajaraman

Re: How to get course contents through to webservice ?

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 = new curl;
$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

Average of ratings: Useful (1)