How To / General

Adding new functions

More
8 years 7 months ago - 8 years 7 months ago #1 by tzeus
Adding new functions was created by tzeus
Hello,
First of all thanks for creating this set of plugins, they're really good.
Second, I am not sure if I am posting in the right subforum, but I couldn't see 3rd party plugins on category

I am trying to complete a certain task, which would extend moodle/joomla functionality.
It's a project for school that I am working on and I must finish it quickly, because the deadline is closing in.
I have little experience with joomla/moodle, and php, I mainly program in java.
I am trying to create a plugin that will allow me to search for moodle modules(scorm, assignment, etc) based on a search criteria(difficulty, resource type, category).
In order to do so I created a new table in moodle db, which has the required fields. I am now stuck at writing the php code, and I would really appreciate some pointers.
So far I have noticed that Joomla makes a remote call to moodle, and all the magic happens inside moodle.
The functions are defined in services.php(method name, file location, etc). This also needs to be reflected in the db
In externallib.php things become very hazy for me. I understand that I have to create 3 functions:
fuunction myFunc() - Here I see that sometimes the implementation if written in this file, and other times it is written in auth.php. Why is that, and how do I decide on what to use?
function myFunc_parameters() - This is self explanatory
function myFun_returns() - I don't understand what external_multiple_structure and external_single_structure are, and how do I decide which one to use.

At the moment this things are blocking me, and I cannot move forward with the development, can you throw some guidelines?

At the end of the assignment, once it's graded, I can pass it over to you, do what you want with it. I am thinking that it would be useful as a moodle addition(have resources like this filtered through information like category, difficulty, grade level or file type), and as a part of joomdle components.

Thank you
Last edit: 8 years 7 months ago by tzeus.

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago #2 by Antonio Durán
Replied by Antonio Durán on topic Adding new functions
Hi.

You can check this to learn more about web services in Moodle:
docs.moodle.org/dev/Adding_a_web_service_to_a_plugin

In your case, it would be better to create a new plugin of type local, and have the new web services there.

As you say, Moodle is quite strict on how web services are defined/used, so you will need to carefully study documentation in order to learn how to do it correctly. I am sorry, but I cannot really give you any shortcuts, as this is a complex topic.

As for your questions:
- It does not matter where you have this code. In a small, local plugin, it can all go in externallib file.
- external_multiple_structure and external_single_structure are just an array of objetcs, or just one objet in single:
docs.moodle.org/dev/External_services_description

Good luck with your project!

Please Log in or Create an account to join the conversation.