Hi I created a web service doing the following :
1. Externallib in mod/questionnaire
has :
<?php
require_once("$CFG->libdir/externallib.php");
class moodle_questionnaire_external extends external_api {
public static function get_questinnaires_parameters() {
return new external_function_parameters (
array(
'courseid'=> new external_value(PARAM_INT, 'id of the course')
)
);
}
public static function get_questionnaires_returns () {
return new external_multiple_structure (
new external_single_structure ( //This is used to represent a single activity.
array(
'id'=> new external_value(PARAM_INT,'The id of the activity'),
'name' => new external_value(PARAM_TEXT,'The name of the activity')
)
)
);
}
public static function get_questionnaires($courseid)
{
global $CFG, $DB;
$params = self::validate_parameters(self::get_questionnaire_parameters(),
array('courseid' => $courseid)
);
$sql = 'select id,name from '. $CFG->prefix.'questionnaire where course='.$courseid;
$rets = array();
$qs= $DB->get_records_sql($sql);
foreach($qs as $q)
{
$ret= array();
$ret["id"]= $q->id;
$ret["name"]=$q->name;
$rets[] = ret;
}
return $rets;
}
}
?>
added
to lib/db/services.php in
'moodle_course_get_questionnaires' => array(
'classname' => 'moodle_questionnaire_external',
'methodname' => 'get_questionnaires',
'classpath' => 'mod/questionnaire/externallib.php',
'description' => 'Return questionnaire details',
'type' => 'read',
'enabled'=>1,
),
but when i try accessing the service
$function='moodle_course_get_questionnaires';
//$params= array('courseid'=>$courseid);;
$params= $courseid;
$response =$testclient->simpletest($serverurl, $function, $params);
i get the error "Can not find data record in database table external_functions"
What steps am i missing out. any help will be greatly appreciated