Programming new modules ..

Programming new modules ..

by Chris de Kok -
Number of replies: 4
Hi,

We are working on a new module. We have installed a new module and made soms input fields. But everytime we decide to remove an activity of the module.
Moodle sais:

' The required instance of this module didn't exist. Module deleted. '

Perhaps one of you can enlighten us with his/her knowledge?
It can also be helpfull is there were some kind of scheme that shows the structure of the code. Because its a lot of work to find all that stuff out yourself. Eg. Where soms variables come from? And wich pages get included where?

Thanks-a-lot,

Chris & Wim


Average of ratings: -
In reply to Chris de Kok

Re: Programming new modules ..

by Jan Dierckx -


Reading your posts in the dutch forum, I guess you have find out about the basic functions in Moodle, right? Like someone else suggested there: it is very difficult to find out what is wrong with your code if you don't include more information e.g. is the instance of your new module written to the database? Any notices or errors showing up... Can you access view.php manually etc...
If you want to find out where variables are declared, which functions are referenced in which (included) files, etc... you can use this tool. If you use the  vim editor, you can even jump from function to function while editing. (But vim has a very steep learning curve, so you might only try this when you really want to get familiar with this great Dutch invention.)
The solution module is an ideal module to start with because it is pretty straightforward, just like the newmodule template mentioned earlier.
In reply to Jan Dierckx

Re: Programming new modules ..

by Chris de Kok -
It seems the formulation of my last question was inadequate. But for the record. I know about the Core Api and I use it all the time.

I have installed a new activity module: 'Testmodule' and i am trying fill it up with fields, areas and more.. When i add a new Testmodule to a course. Moodle opens mod.html and asks for a name in a form. The next step is view.php. After this you can see on the calendar (eg. week 10 February - 16 February ) that there is an activity planned. A Testmodule. When you click on the 'X' to remove that activity Moodle says: 'The required instance of this module didn't exist. Module deleted.'

And yes, there are some things like the activityname written to the database. I can do all this without errors or notifications. Except for the one i mentioned. Perhaps i have to call a function myself like  .. add_new_instance(); so Moodle does create an instance?

Thanks for your reaction,

Chris
In reply to Chris de Kok

Re: Programming new modules ..

by Jan Dierckx -
Yes, you have to write xxx_add_instance (and xxx_update_instance and xxx_delete_instance and xxx_user_complete and the likes) yourself!
You can find some examples by browsing the cross referenced moodle code.
Good luck.