2

我正在尝试收集与 Moodle 课程(课程 + 课程)相关的所有信息

    Eg :  var domainname = 'http://<server URL>/moodle'; 
var token = 'df337369637c692303d903f8cacf1eb0'; 
var functionname = 'core_course_get_courses'; 
var serverurl = domainname + '/webservice/rest/server.php' ; 
var data = {
            wstoken: token,
            wsfunction: functionname,
            moodlewsrestformat: 'json'              
                } var response = $.ajax(
               {   type: 'GET',
                   data: data,
                   url: serverurl
               }
              );

输出看起来像

{"id":2,"shortname":"IV Support Queries","categoryid":1,"categorysortorder":10001,"fullname":"IV Support Queries","displayname":"IV Support Queries","idnumber":"","summary":"<p>IV Support Queries Desc<br \/><\/p>","summaryformat":1,"format":"topics","showgrades":1,"newsitems":5,"startdate":1479168000,"numsections":5,"maxbytes":0,"showreports":0,"visible":1,"hiddensections":1,"groupmode":0,"groupmodeforce":0,"defaultgroupingid":0,"timecreated":1479127227,"timemodified":1479198758,"enablecompletion":0,"completionnotify":0,"lang":"","forcetheme":"","courseformatoptions":[{"name":"numsections","value":5},{"name":"hiddensections","value":1},{"name":"coursedisplay","value":1}]}

我想要在 course 下创建的课程详细信息。如何通过 Api 获取信息。谢谢

4

1 回答 1

8

使用功能

“core_course_get_contents”

获取与课程相关的所有信息。

var domainname = 'http://<server URL>/moodle'; 
var token = 'df337369637c692303d903f8cacf1eb0'; 
var functionname = 'core_course_get_contents'; 
var serverurl = domainname + '/webservice/rest/server.php' ; 
var data = {
            wstoken: token,
            wsfunction: functionname,
            moodlewsrestformat: 'json' ,
            courseid: 2 //Retrieve results based on course Id 2            
           } 
var response = $.ajax(
               {   type: 'GET',
                   data: data,
                   url: serverurl
               }
              );

谢谢

于 2016-11-17T08:38:56.397 回答