wsAvailable function

Re: wsAvailable function

by Dani Palou -
Number of replies: 7
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In reply to Dani Palou

Re: wsAvailable function

by Salim BOUDRAA -

thank you Dani, I found it.

I'm trying to integrate the plugin enrol/elediamultikeys mobile moodle, I made some changes already, but now when I made console.log (method.type) in the function getCourse(refresh) I get this error : 

POST https://khabech.com/webservice/rest/server.php?moodlewsrestformat=json net::ERR_TIMED_OUT

can someone explain to me the meaning of the error and how to fix it ?


thank you



In reply to Salim BOUDRAA

Re: wsAvailable function

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi,

it seems a WebService call is taking too long to respond, so it times out (the timeout is 30 seconds). You should check which WS call is being used (using the Network tab of the DevTools) and then investigate why is that call taking so much to respond.

In reply to Dani Palou

Re: wsAvailable function

by Salim BOUDRAA -


Ok, thank you I understood, I think my connection was weak at that moment, now I have a question, in the request function in the file sitesfactory.js, with this part of the code exactly: 

return $ mmWS.call (method, data, wsPreSets) .then (function (response) 

{                    

 if (preSets.saveToCache) { 

console.log ("!!!!!! site.infos.functions =======");

console.log (site.infos.functions); 

saveToCache (site, method, data, response, preSets);                     

}

}

 I would like to add a function in the variable sites.infos.functions how to do that ??


thank you

In reply to Salim BOUDRAA

Re: wsAvailable function

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi,

that's the list of WebServices available in your Moodle site. You should create a new WebService and include it in the Mobile service. In newer sites you can do that including this line in the declaration of the WebService:

        'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),

Cheers,

Dani

In reply to Dani Palou

Re: wsAvailable function

by Salim BOUDRAA -


thank you very much, that's exactly what I did, in the directory of the plugin, in the folder db, I created the file services that I pass you in attachment I was able to find the web service in Site Administration -> Plugins -> Web Services -> External Services as you can see in the attached image also, but the service does not load in the site.infos.functions.

have you any explanation? 

 thank's

Attachment img.PNG
In reply to Salim BOUDRAA

Re: wsAvailable function

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi,

are you using the local_mobile plugin? If you do then you need to add that WS to the local_mobile service too.

Please go to

Site administration > Plugins > Web services > External services

and click "Functions" in "Moodle mobile web service". Your WS should be listed in there.

Cheers,

Dani


In reply to Dani Palou

Re: wsAvailable function

by Salim BOUDRAA -

thank you very much, now I find my web service in site.infos.functions

now i would like to understand from where is the variable method of the following function:

angular.forEach(enrollmentMethods, function (method) {

if (selfEnrolWSAvailable && method.type === 'self') {

$Scope.selfEnrolInstances.push (method);

 } else if (guestWSAvailable && method.type === 'guest') {

isGuestEnabled = true;

});

which is in the file /www/core/components/courses/controllers/viewresults.js gets its values ​​as method.type ?

thank you