Moodle api列出所有队列
我希望得到所有的队列,我可以得到信息,如果我有身份证,但我想要所有的队列名称和身份证。如果有办法,请告诉我。提前谢谢Moodle api列出所有队列,api,rest,moodle,Api,Rest,Moodle,我希望得到所有的队列,我可以得到信息,如果我有身份证,但我想要所有的队列名称和身份证。如果有办法,请告诉我。提前谢谢 $functionname = 'core_cohort_get_cohorts'; $cohortIDS = array( '1' ); $data_string = http_build_query(array('cohortids' => $cohortIDS)); $utoken = 'mytoken'; $adduser = 'yoururl/webservi
$functionname = 'core_cohort_get_cohorts';
$cohortIDS = array( '1' );
$data_string = http_build_query(array('cohortids' => $cohortIDS));
$utoken = 'mytoken';
$adduser = 'yoururl/webservice/rest/server.php? wstoken='.$utoken.'&wsfunction='.$functionname.'&moodlewsrestformat=json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$adduser);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
echo '<pre>';
print_r(json_decode($server_output));
echo '</pre>';
$functionname='core\u-courts\u-get\u-courts';
$cohortIDS=数组('1');
$data\u string=http\u build\u查询(数组('coortids'=>$coortids));
$utoken='mytoken';
$adduser='yoururl/webservice/rest/server.php?wstoken='.$utoken.&wsfunction='.$functionname.&moodlewsrestformat=json';
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$adduser);
卷曲设置($ch,卷曲设置桩,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$server\u output=curl\u exec($ch);
卷曲关闭($ch);
回声';
打印(json解码($server\u输出));
回声';
您可以向core_队列添加更多方法,以获得所有队列,如下所示:
在队列/externallib.php中,添加更多方法:
此外,您必须注册名为“核心团队”的Web服务,才能从外部调用此Web服务。如果你有进一步的问题,请告诉我
public static function get_all_cohorts(){
global $DB;
$cohortids = $DB->get_records('cohort', null, null, 'id');
$arrids = array();
foreach($cohortids as $id){
$arrids[] = $id->id;
}
return (new core_cohort_external())->get_cohorts($arrids);
}