如何使用 moodle 站点库添加更多 mnet 服务

How to add more mnet service using moodle site base

目前moodle支持4个mnet服务

1. Remote enrolment service 
2. Portfolio services 
3. SSO (Identity Provider)
4. SSO (Service Provider)

要添加更多 mnet 服务,我需要为 admin/mnet/service.php 手动添加代码,然后在 mnet/service 中添加新的代码(如现有服务 mnetservice_enrol)。

我打算添加新服务以从 mnet peer 检索课程详细信息。 get_remote_courses 方法是 return 只有课程概述,而不是课程细节。

我找不到关于这个是moodle官方网站的任何文件。有没有关于这个的教程?或者专家的一些建议?

只想post这里方法使用webservice而不是使用mnet获取课程内容。 Moodle 支持 core_course_get_contents 在网络服务中获取课程内容。

require_once('../../config.php');

$token = '5733b5401924f1e6dafefd326cafeaca';
$domainname = 'http://192.168.1.252';
$courseid = optional_param('remoteid', 0, PARAM_INT);

require_once($CFG->dirroot . '/lib/zend/Zend/Http/Client.php');

$functionname = 'core_course_get_contents';

$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname.'&moodlewsrestformat=json';

$client = new Zend_Http_Client($serverurl);
$client->setParameterPost('courseid', $courseid);
$response = $client->request(Zend_Http_Client::POST);

echo $response;

我们可以通过在 yourplugin/db 中添加 mnet.php 来添加更多 mnet 服务,格式为:

$publishes = array(
    'mnet_enrol' => array(
        'apiversion' => 1,
        'classname'  => 'enrol_mnet_mnetservice_enrol',
        'filename'   => 'enrol.php',
        'methods'    => array(
            'available_courses',
            'user_enrolments',
            'enrol_user',
            'unenrol_user',
            'course_enrolments',
            'category_enrolments'
        ),
    ),
);
$subscribes = array(
    'mnet_enrol' => array(
        'available_courses' => 'enrol/mnet/enrol.php/available_courses',
        'user_enrolments'   => 'enrol/mnet/enrol.php/user_enrolments',
        'enrol_user'        => 'enrol/mnet/enrol.php/enrol_user',
        'unenrol_user'      => 'enrol/mnet/enrol.php/unenrol_user',
        'course_enrolments' => 'enrol/mnet/enrol.php/course_enrolments',
        'category_enrolments'=>'enrol/mnet/enrol.php/category_enrolments'
    ),
);

新的 mnet 服务功能存储在 mnet_remote_rpc table:

+---------------------+----------------------------------------------+
| functionname        | xmlrpcpath                                   |
+---------------------+----------------------------------------------+
| user_authorise      | auth/mnet/auth.php/user_authorise            |
| keepalive_server    | auth/mnet/auth.php/keepalive_server          |
| kill_children       | auth/mnet/auth.php/kill_children             |
| refresh_log         | auth/mnet/auth.php/refresh_log               |
| fetch_user_image    | auth/mnet/auth.php/fetch_user_image          |
| fetch_theme_info    | auth/mnet/auth.php/fetch_theme_info          |
| update_enrolments   | auth/mnet/auth.php/update_enrolments         |
| keepalive_client    | auth/mnet/auth.php/keepalive_client          |
| kill_child          | auth/mnet/auth.php/kill_child                |
| available_courses   | enrol/mnet/enrol.php/available_courses       |
| user_enrolments     | enrol/mnet/enrol.php/user_enrolments         |
| enrol_user          | enrol/mnet/enrol.php/enrol_user              |
| unenrol_user        | enrol/mnet/enrol.php/unenrol_user            |
| course_enrolments   | enrol/mnet/enrol.php/course_enrolments       |
| send_content_intent | portfolio/mahara/lib.php/send_content_intent |
| send_content_ready  | portfolio/mahara/lib.php/send_content_ready  |
| category_enrolments | enrol/mnet/enrol.php/category_enrolments     |
+---------------------+----------------------------------------------+

添加新的网络服务也是如此。要更新新服务,您需要在 version.php.

中增加版本