My first module

My first module

by Mallol Nolla Roig -
Number of replies: 11
hi there,
i'm finishing computer engineering at university, and i've got to do an "end of studies project". i'll base it on moodle, developing some modules.

i've never programmed in php, but done something in sql. my teacher told me to do little exercise: to develop a module so the students can upload files to the system.

i've been reading lots of articles around this web and learned so much. now i've downloaded the "newmodule" file, and installed on my moodle. now comes my problem: i don't know where to begin. after been reading lots of information i'm so lost!

can anybody help me please? i'm not asking for source code (that way I wouldn't learn). i'm asking for some guiding, or where to start from or something

i hope somebody can help me anyway, will receive any kind of help as a salvation.

i've been reading code from the modules that come with moodle and understood it so well, but i still don't know how to start my module.

thank you all
Average of ratings: -
In reply to Mallol Nolla Roig

Re: My first module

by Jan Dierckx -
Best way to start, I think, would be to change the file view.php inside your module and make it display something, even if it is only "Hello, world".
Then check if it is possible to add instances of your new module to a course.
If you got this module running, experiment with some of the functions in moodle's library. Try reading something from a database table, using get_records() and displaying it.
A quick way to browse all of moodle's code and see how variables / functions are connected is this crossreference.
If you want a clean, easily inderstood, but usable module, I suggest looking at Eduardo Monteiro's Solution module
It checks if a student is not a guest and then displays a resource (as such I really think it belongs inside the resource module)
The code is very readable and uses a lot of Moodles functions.
   
In reply to Mallol Nolla Roig

Re: My first module

by Teemu Sumi -
Mr. Janne Mikkonen made a module called Userdir.

http://moodle.org/mod/forum/discuss.php?d=14437

There is a problem with backup feature. Maybe you can continue Janne's work. Janne told me that most likely he hasn't got time for this.


Cheers,
Teemu
In reply to Teemu Sumi

Re: My first module

by Teemu Sumi -
Forget what I just said. Janne just finished the job.


Teemu
In reply to Teemu Sumi

Re: My first module

by Janne Mikkonen -
Please do continue this one if you wish to. There are lot's of things you could do with it.

- Grading
- Allow teacher uploading
- States (for commenting, final)
- etc...

In reply to Teemu Sumi

Re: My first module

by Mallol Nolla Roig -
thank you for your help!

i've visited the link you put in your answer, but the link to the module doesn't work (it seems it is being upgraded and the version is not available). i've entered to http://moodle.opitaan.fi and tried to get it from there. but there is a little problem... i don't understand suomi ;)

i also entered to http://edu.jaiko.fi/edu but it's a development web and it is in no longer use.

could you help me with this?? can you send me the link to a recent version? i think this is gonna be much helpful for me.

thank you again for your support!!


In reply to Mallol Nolla Roig

Re: My first module

by Teemu Sumi -
Here is the module.

You can't find that module from http://moodle.opitaan.fi

Janne has probably changed his test site, if you can't find http://edu.jaiko.fi/edu


Teemu
In reply to Teemu Sumi

Re: My first module

by Mallol Nolla Roig -
Hi again!!
i've been a few days disconnected of reality having holidays abroad, so i stopped my first module activity.
back again at work i've started to do some little test just like adding a print("This is my first module"); in the view.php file. I also created a table in the mysql.sql and added aexecute_sql function in the mysql.php. Then I updated the module in the server.But when I want to test it, how do i have to do it?
neither if i login as administrator nor as a student i don't see anything! how can i see the text i added to the view.php?
Another problem i have is that i check in the phpmyadmin site if the tables i wanted to create are there, but they haven't been created. what am i doing wrong?

Thank you very much for your pacience

Mallol


In reply to Mallol Nolla Roig

Re: My first module

by Timothy Takemoto -
Dear Mallo,

Shouldn't that be echo"This is my first module";?
You could also try copying the bits of the view.php from another module.

Tim
In reply to Timothy Takemoto

Re: My first module

by Mallol Nolla Roig -
Hi there,

i think i will have to start from the beginning of the beginning. i've deleted all my sql lines on mysql.sql, and also in mysql.php. Beginning from the newmodule template, i've created a new module. But when I try to create a new instance, moodle gives me an error: Cannot create a new instance of MyFirstModule.

Why does it happens? I've replaced the code of view.php for the view.php of the label module and it still happens the same. What are the minimum requirements to create a new instance of a module?

Is there any thread on the forum for a complete beginner? I've been searching for a long time, but i didn't find anything. I'm starting to exasperate... sad

if you know any developer manual for dummies, or any document to start from, i'd be much grateful to you.

Thank you again for your support


In reply to Mallol Nolla Roig

Re: My first module

by Timothy Takemoto -

Dear Mallol,

How about editing Teemu Sumi's module above or one of the add-on modules available from the download page? Or changing one of the modules in your test installation?

I am not a developer, and I have not see a manual but on the forums, in the past, embrionic developers have recommended gaining a strong familiarity with the central function  (or is that object?) libraries such as in lib/weblib.php and lib/moodlelib.php, reading them on the train etc.

Tim

In reply to Teemu Sumi

Re: My first module

by Mallol Nolla Roig -
hello again,

i've started from zero, trying to get all the concepts of moodle developing and have again some problems.

first of all i want to do a module which lets students upload files. i create a new table in the mysql.sql file. then, when the admin or student adds a new activity with this module, it asks in which folder the students must send the files to.
when i enter the text for the folder and clic ok, there is an error that says:
No action was specfied

can you help me solving it please?

thanks a lot

Mallol