Moodle通过Api

时间:2016-11-15 09:14:34

标签: moodle moodle-api moodle-mobile

我正在尝试收集与Moodle课程相关的所有信息(课程+课程)使用Moodle Api我获得了课程信息,但只获得了一些基本信息,我想要课程详情和课程(根据课程创建)

    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}]}

我想在课程中创建课程详细信息。如何通过Api获取信息。感谢

1 个答案:

答案 0 :(得分:4)

使用功能

  

&#34; core_course_get_contents&#34;

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

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
               }
              );

由于