Trabla: Moodle & php: add cohort web-service functions from moodle 2.6 to 2.3
Solving:
1. Update file ../moodle-2.3/moodle/lib/db/services.php - add definition of cohort services
// Cohort related functions.
'core_cohort_create_cohorts' => array(
'classname' => 'core_cohort_external',
'methodname' => 'create_cohorts',
'classpath' => 'cohort/externallib.php',
'description' => 'Creates new cohorts.',
'type' => 'write',
'capabilities'=> 'moodle/cohort:manage',
),
'core_cohort_delete_cohorts' => array(
'classname' => 'core_cohort_external',
'methodname' => 'delete_cohorts',
'classpath' => 'cohort/externallib.php',
'description' => 'Deletes all specified cohorts.',
'type' => 'delete',
'capabilities'=> 'moodle/cohort:manage',
),
'core_cohort_get_cohorts' => array(
'classname' => 'core_cohort_external',
'methodname' => 'get_cohorts',
'classpath' => 'cohort/externallib.php',
'description' => 'Returns cohort details.',
'type' => 'read',
'capabilities'=> 'moodle/cohort:view',
),
'core_cohort_update_cohorts' => array(
'classname' => 'core_cohort_external',
'methodname' => 'update_cohorts',
'classpath' => 'cohort/externallib.php',
'description' => 'Updates existing cohorts.',
'type' => 'write',
'capabilities'=> 'moodle/cohort:manage',
),
2. Copy file ../moodle-2.6/moodle/cohort/externallib.php
to ../moodle-2.3/moodle/cohort/
3. Insert new web-service functions definition into moodle-2.3 database table mdl_external_functions
# Creates new cohorts.
INSERT INTO mdl_external_functions(name, classname, methodname, classpath, component, capabilities)
VALUES ('core_cohort_create_cohorts', 'core_cohort_external', 'create_cohorts', 'cohort/externallib.php', 'moodle', 'moodle/cohort:manage' );
# Deletes all specified cohorts.
INSERT INTO mdl_external_functions(name, classname, methodname, classpath, component, capabilities)
VALUES
('core_cohort_delete_cohorts', 'core_cohort_external',
'delete_cohorts', 'cohort/externallib.php', 'moodle',
'moodle/cohort:manage' );
# Returns cohort details.
INSERT INTO mdl_external_functions(name, classname, methodname, classpath, component, capabilities)
VALUES
('core_cohort_get_cohorts', 'core_cohort_external',
'get_cohorts', 'cohort/externallib.php', 'moodle',
'moodle/cohort:view' );
# Updates existing cohorts.
INSERT INTO mdl_external_functions(name, classname, methodname, classpath, component, capabilities)
VALUES
('core_cohort_update_cohorts', 'core_cohort_external',
'update_cohorts', 'cohort/externallib.php', 'moodle',
'moodle/cohort:manage' );
# Adds cohort members.
INSERT INTO mdl_external_functions(name, classname, methodname, classpath, component, capabilities)
VALUES
('core_cohort_add_cohort_members', 'core_cohort_external',
'add_cohort_members', 'cohort/externallib.php', 'moodle',
'moodle/cohort:assign' );
# Deletes cohort members.
INSERT INTO mdl_external_functions(name, classname, methodname, classpath, component, capabilities)
VALUES
('core_cohort_delete_cohort_members', 'core_cohort_external',
'delete_cohort_members', 'cohort/externallib.php', 'moodle',
'moodle/cohort:assign' );
# Returns cohort members.
INSERT INTO mdl_external_functions(name, classname, methodname, classpath, component, capabilities)
VALUES
('core_cohort_get_cohort_members', 'core_cohort_external',
'get_cohort_members', 'cohort/externallib.php', 'moodle',
'moodle/cohort:view' );
No comments:
Post a Comment