NOTE: This post first appeared in eLearning World last year: https://www.elearningworld.org/. Since then Simple Lesson has been published in the Moodle Plugins database:
Moodle plugins directory: Simple lesson
Moodle Bites for Developers Level 1 starts February 1st 2019.
As a user, teacher and lecturer of programming languages from FORTRAN IV to Java I’ve long been interested in the topic of Moodle programming, but every time I have started I’ve hit some kind of wall:
- Lack of (or outdated) documentation
- Lack of detailed PHP knowledge
- Lack of help and support
- Difficulty in understanding the source code
Then in frustration I’ve given up.
This last year I published my first Moodle plugin to the
database and I’m deep into my second.
I’m still not a fully-fledged developer but I do understand a lot more
than before. So much so that I’m helping
to facilitate a MoodleBites course in the subject.
One of the things needed to bring about this change was
motivation. I’d been working with people
who were developing Moodle courses making extensive use of the Lesson Activity
in Moodle. It’s not a bad activity but
it does suffer one serious shortcoming – you cannot use questions from the
question bank in a lesson.
I began to Google around and pretty soon discovered that
this had occurred to people before and they had not been able to solve it yet,
mostly through lack of time. Being in my
late 60’s time is not as much of a luxury as it used to be for me.
Stuart at HRDNZ knew that I was interested and offered me a
place on Justin Hunt’s MoodleBites for Developers Level 1 course. Justin is “the POODLL guy” – the smart
Moodle Developer of that Swiss-army knife of Moodle improvements, especially
good for language learning.
Although the course covers much of the basics of Moodle
programming (by no means all) it also teaches the value of persistence – or
should I say without persistence you will find it hard to complete. This is not the nature of the course material
or the skill of the facilitator, rather it is the nature of the challenge.
Persistence for me was, when faced with a challenge, not
going first to the forums and getting the answer but working back and finding
out where I had strayed from the path.
Experienced Moodle Developers have all sorts of tools at their
disposal. All I had was echo and
var_dump. Echo allows you to print
things at your console (you can also log messages to your error log). Var_dump
allows you to see the “guts” of an object and work out what you should be doing
Armed with these simple tools I would go back over my code
and figure it out for myself, resulting in those wonderful “ah hah”
moments. When you have those, by the
way, don’t forget top put them in your Evernote or whatever you use for a log.
I’ve sometimes puzzled for days over some piece of code and
this has led to a broader and deeper understanding of Moodle structure and
coding norms. Even some of the
documentation at Moodle org started to make sense.
There is, of course, an endless amount of knowledge already
pretty skilled to find the missing piece you are looking for.
Obvious sites are:
- The Moodle General Developer forum
- Stack Overflow
- The Developer documentation
Less obvious routes include looking at GitHub for Moodle HQ
and other developer’s accounts and studying the code of any plugin somewhat
similar to the one you are trying to build.
The Moodle database will also help you understand what
variables/properties belong to which classes/objects and gain a deeper
understanding of what your code is actually producing. I have found this especially useful when
trying to understand how my plugins store media files.
For a really quick but excellent overview of Moodle architecture,
you can read Tim Hunt’s excellent guide.
As many people will tell you, learning by doing Moodle
development is better and more effective than learning by reading about Moodle
Development. In fact Moodle is built on
the philosophy of social constructionism.
If you see an error message as an example of feedback on
your learning, a challenge to be googled, rather than as an obstacle to your
progress you will learn more effectively.
We’ve already mentioned personal traits such as persistence
to which we can add optimism and a sense of humour. However, you will also need:
- A sound knowledge of programming (preferably in
PHP, preferably Object Orientated)
- A good understanding of SQL and relational
- A good understanding of html and css.
It’s true that if you are not familiar with all of the above
technologies you can learn as you go. A
good source of basic knowledge is at the W3Schools website
which may help if you have some gaps.