When Tim first returned to the UK from his time at Moodle HQ, the first thing he did1 was to invite me to come to The Great British Beer Festival with him. Apparently i’d taunted him with reports of Real Ale whilst he was in Perth. Well.. it’s time for Tim to get his own back!
After seven years working at LUNS and nine years living in Lancaster, I’ve decided to have a change of scenery and i’m going to be leaving many great friends and colleagues behind to move to Moodle HQ in Perth, Australia. Needless to say, this was not an easy decision to make. (Although the weather like Lancaster demonstrated today could convince me otherwise!)
My involvement with Moodle started with LUNS and it has been a great journey. We were newcomers to the Moodle community with a small project to move a few keen high-schools onto supported hosting platform in 2005. My first post to moodle.org was asking the theme forums for advice on how to do multiple themes on a single codebase and the first patch I remember getting accepted was to help us solve that problem six months later: MDL-6784.2 Today LUNS is one of the largest non-HQ code contributors to recent Moodle releases and have provided hundreds of thousands of people with access to Moodle through our various clients – primary school students3, university lecturers4, high school teachers, company employees and charity workers. I’ve thoroughly enjoyed that journey and the great people who have made it what it is.
I’m really looking forward to working for Moodle HQ! Despite being so close to Moodle as a developer, I continue to be amazed and motivated by how many people I can touch by working on Moodle. Friends from my days at school and university use Moodle as part of their job on a daily basis, my youngest sister is currently studying and supported with Moodle (unfortunately only at stage 1 of Martin’s pedagogical stages) and I meet more and more moodlers ever day! I’m hoping that my time working as external developer working on the other side of the world to Perth will be a great new perspective to add to the team.
I’ll be working for LUNS for a while yet, but it feels like a good opporunity to thank everyone i’ve worked with over the years at LUNS, clients and community members who accepted my patches. I’m touched by the kind post about my leaving. I expect to continue working with you if more indirectly at Moodle HQ.
Earlier today I came across an interesting project which provides a ‘proxy interface’ to Siri on the iPhone 4S allowing custom plugins to be created to respond to requests from Siri.
Eager to try this I hacked together a Moodle plugin for the siri proxy which would do lookups to the Moodle tracker. So, welcome Siri – the newest aid to the Moodle 2.2 QA testing effort
(The plugin I wrote is available on github. It is my first ruby script and its not particularly elegant as it was just for fun )
This weekend I attended the phpnw11 conference in Manchester, a good conference with a lot of interesting talks which i’d highly recommend to any php programmer.
Not entirely accidentally, I went to a number of talks focused on testing and continuous integration and came home with quite a lots of bits and pieces I wanted to play with. Sebastian Marek gave an excellent talk on Software Metrics (slides available) as the first track talk of the day. Obviously I can’t summarise his talk, but he introduced us to the concept of the cyclomatic complexity, NPATH, C.R.A.P. as well as WTFs/min as well as tools which can be used to measure them and other assessments of code quality. Sebastian made the point quite strongly that you can’t just use these metrics on their own, but that they could be good indicators combined with analysis of the code.
This got me wondering if the modern parts of Moodle would be analysed more favourably that older parts of Moodle which developers tend to long to refactor away?
Testing 1.9 vs 2.2
So I conducted a test using php mess detector and its code size rules on the question engine in Moodle 1.9 and compared that with master (which includes the rewritten question engine that Tim spent a good portion of the last year working on1 ).
Well, not quite – in order to get those results I had to remove all the unit tests, which weren’t present in Moodle 1.9 and also tend to be ‘long, dumb’ methods2 which trigger just this sort of metric and made the result larger. I don’t really know the code well enough but there may be other factors such as question/ including more code…
The results matched Sebastians point that these metrics can’t be used on their own, but some of the metrics which can be generated might be very interesting datapoints to look at with time. Sonar was a tool demonstrated which could be used in combination with a continuous integration system and tools which generate these metrics to evaluate and report over time – some of which looks really cool and I hope to play with soon.
and I hope he doesn’t mind me using as an example! [↩]
Incidentally Laura Beth Denker also did a great talk at phpnw11 emphasising how you should write good test code avoiding things like conditionals- slides available [↩]
At LUNS, we designed, built and supported what I still believe to be one of the largest multi-moodle installations in the world. The installation ran from a single codebase and comes with many tough challenges, scaling supporting and upgrading 1000 Moodle installations and 270,000 users can be quite difficult! (I think I have guestimated doing about 8000 Moodle upgrades in my time so far ).
But the question I most frequently get asked is how we achieved a 1000 Moodle install on a single codebase without modifying core Moodle code. This is the simplest part of the operation really and very straight forward to setup. I’ve promised a few people i’d blog about it so:
Configure your webserver to server all hosts from a single codebase directory
Create a config.php file which includes the individual site config depending on the host which is being served. e.g.
Populate individual Moodle config files with site specific config as you would any other Moodle site
Thats it!
Moodle HQ are currently working on a new core Multitenancy feature, which might provide a different approach for some institutions (although i’m still not entirely clear on its use case over an approach like this).
Apologies – the last entry in this blog was regarding the Moodle Developers Hackfest in the Czech Republic, nearly two years ago!
It was a great occasion, we had some big arguments on git, Moodle 2.0 wasn’t released and we didn’t manage to go skiing!
Since then:
Moodle 2.0 has been released (and 2.1)
git has been introduced into Moodle Development workflow
i’ve been skiing (not sure about the Australians..).
we drank the entire czech mint/lime provision in mojitos
Sadly since then i’ve also spent far less time doing Moodle bug fixing than before – instead i’ve been doing a lot of Moodle advocacy to various organisations.
I’ve been missing the bug fixing and decided to start to scheduling myself time to ensure at least one bug fix a week (at the minimum). Fixing bugs and pleasing Moodlers is addictive – so I hope this spirals into many more Wish me luck with keeping the doctor away!
Its less than a week till 16 of us (moodle developers) meet up in the Czech Republic for the first Moodle Hackfest!
I’m really excited, the opportunity to to hack and plan together is a unique opportunity and something we tend to miss at moots as we chat to fellow Moodlers and find out what our users are interested in, drink Mojitos and don’t get so much coding done!
In any case i’m very interested to hear what you love and hate about Moodle at the moment so the developer community can come up with ways to resolve your problems. If you hate moodle, please tell me why, how can we improve it?
ps. please keep your fingers crossed, I’ve spent months negotiating a new house which I am hoping to own the day I fly to prague!
Its not difficult for me to realise that Moodle is a popular global project – I work alongside the evidence every day; reading Moodle.org, fearing the volume of bugs which come into the tracker and in CLEO, we recently surpassed 200,000 Moodle users. Buts its actually the small events in life which help me quantify this.
When i’m fortunate enough to go to Moodlemoots the international community of Moodlers is very evident and the passion is incredible.
Often, i meet teachers at completely non-moodle related social events and discover they use Moodle.
While i’m cycling to work and pass children walking to school, I stop and realise these children are likely to be using Moodle now or some time in their future (such is the dominance of Moodle in our region).
This week I discovered my old Sixth Form College is starting to use Moodle. During my time at the college I got a passion for computer programming and also benefited enormously from my first exposure to online learning. I don’t teach people (at least in the formal sense) and so this exposure certainly helps me understand the Moodle philosophy more than I would’ve been able to without.
One of the greatest things about working on this open source project is that my contributions hopefully go some way to benefiting all these users: The moodlers I meet at moots, the teacher I met one time at a party, the schoolchildren passing me on the way to work and the college which gave me many of the fundamentals which have helped me contribute to the project.
Having ended up with a spare iPhone from a recent upgrade I decided to try jail-breaking the old one and see what software was out there away from the restrictions of the app store. I discovered that lighttpd, php and sqlite were all available from the software repositories for download – these three combined are enough to run a Moodle server. So out the window went cleaning my flat and sensible tasks – I had to make my phone into a Moodle server!
Getting the software for moodle installed and configured was relatively painless, the ‘cydia’ software installer appears to use dpkg under the hood, so I installed openssh server and apt through the gui installer and then sshed onto the phone to do the work with a full size keyboard and the moodle server was up and running quite quickly. (More details for configuration below).
Sqlite is a really interesting technology which seems to be making its way into a lot of software and I was quite interested to see Moodle support for lightweight testing sorts of applications and it has made its way into Moodle thanks to the great work of Andrei Bautu in his GSOC project last year. It only exists in the highly unstable Moodle 2.0 development branch so I needed to install this on my iPhone. Development is moving incredibly fast in the Moodle 2.0 branch so I was not at all suprised to see that the sqlite driver was not working. It took a bit of time to find out what the major issue with the driver as it was a silent error. But I eventually found and fixed the major issue.
Sadly, despite successfully installing and passing most of the database unit tests on my development machine with sqlite, some database queries were continuing to cause the iPhone server issues. I spent some bit of time improving the sqlite driver to show more debugging information and get to the bottom of the issue.
After a lot of debugging and irritation, it seems that the sqlite library version (3.3.7) linked to from php has a bug/incompatibility which means it does not like queries like:
SELECT student.id FROM mdl_user student JOIN (SELECT ra.userid FROM mdl_role_assignments ra) roles ON student.id = roles.userid
It’ll report: SQLSTATE[HY000]: General error: 1 no such column: roles.userid
Where as it will work fine with something like:
SELECT student.id FROM mdl_user student JOIN (SELECT userid FROM mdl_role_assignments ra) roles ON student.id = roles.userid
(That was a simple example to try and find the problem – the SQL we have in moodle is a lot more complex that that).
To confuse matters, the sqlite command line tool I was using to test on the phone itself was a newer version (3.6.12), which works absolutely fine with both queries. The same was true on my development machine, which meant that I could install with sqlite succesfully everywhere but the iPhone itself. I assume the php version has been linked to the iPhone OS version – but I am too lazy to check/do something about it!
While I don’t yet have a working moodle server install running on the phone itself, the exercise in improving the sqlite driver has been really useful. I’ve updated the driver in CVS, on recent sqlite versions it is only currently failing 9 of 1298 tests. (CEIL and SUBSTR being the major issues – but they are only used for stats and the admin healthcheck) so its really looking like a really useful option for those situations where a full-grown database server is overkill.
I’ve put a video of the (disapointing) install on youtube and you can find details of the various bits of configuration below.
Configuration Details
I love apt
apt-get install lighttpd php sqlite3 git
I’ve never configured lighttpd before, but a quick search for configuring with php and I made a very simple config with /etc/lighttpd/lighttpd.conf and /etc/lighttpd/mod_fastcgi.conf
JB-Phone:~ root# cat /etc/lighttpd/lighttpd.conf
include "mod_fastcgi.conf"
server.document-root = "/htdocs/moodle"
server.port = 80
server.tag ="lighttpd"
server.errorlog = "/htdocs/log/error.log"
accesslog.filename = "/htdocs/log/access.log"
server.modules = (
"mod_access",
"mod_accesslog",
"mod_fastcgi",
"mod_rewrite",
"mod_auth",
"mod_fastcgi"
)
index-file.names = ( “index.html”, “index.php” )
# cat /etc/lighttpd/mod_fastcgi.conf
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket"
)
)
)
And started the webserver manually with:
lighttpd -f /etc/lighttpd/lighttpd.conf
I created the /htdocs/ directories – and git cloned moodle into /htdocs/moodle and created the moodle config file as mentioned in the sqlite moodle docs:
$CFG->prefix = 'mdl_'; // prefix to use for all table namesV
$CFG->dbtype = 'sqlite3';
$CFG->dblibrary = 'pdo';
$CFG->dbhost = 'localhost';// leave dbhost to localhost (or blank) to store the database file in Moodle data directory
Oh and I was also naughty and made the ‘zip’ php extension an optional item (as it wasn’t in the packed php version):
At a moodle developer meeting recently, some developers were asking if a mentoring scheme could be started up for new developers who wish to get into moodle development. Unfortunately, there just aren’t enough hands on deck with time to manage to do the mentoring for something like this, despite the obvious long term benefits.
I suspect we will always be on an uphill battle to improve our documentation and resources (like many things in life, documentation isn’t very exciting or give instant payoffs to our users), but there are some resources which should be very useful to new developers: dev.moodle.org, Moodle Docs and of course the forums of moodle.org.
When I think back to how I have learnt about various aspects of moodle development i’ve not really used many of those resources very much, instead i’ve been lead by the constructivist approach! My journey into moodle development started in MDL-6784, this was my second bug report, first patch and first accepted patch into moodle! Since this first patch i’ve reported/fixed/watched/contributed to many many moodle bugs and I think this is my secret to moodle development!
Of course this is really no secret at all, the code and bugs are open for everyone to see. But I believe that spending time finding, reproducing and resolving bug reports gives new developers an invaluable insight into various aspects – which libraries do what, what are the caeats of x, how to fix y and where to go looking for future bugs! By watching bug reports, seeing comments, reviewing patches and fixes commited slowly your knowledge of moodle wil become massive, despite a lack of dedicated mentor!
I do have a few general tips for moodle debugging which I i’d like to share (and apologise as they feel ‘obvious’ to me)!
You’ve set debugging to DEBUG_DEVELOPER, right?!
print_object() is basically print_r with whitespace and I use it at least 1000 times a day[1]. Its not just for objects Print statement debugging might not be sexy but its essential and useful
debugging() prints a stack trace – why wouldn’t you use it!
grep backwards for lang strings! (grep ‘my error message’, find the lang string name (myerrormessage) and then grep for that)
I die() lots.
We have CVS history and bug numbers for a reason! Look at CVS history of a file and bug numbers/linked issues!
Keeping up to speed with CVS history is a really useful exercise, if time consuming
I often wonder if I would still be in moodleland if my first patch was not reviewed as speedily as it was, I think probably not. In which case how do we ensure potential contributors such as myself don’t get lost in our workloads and we encourage new contributors!? Its interesting to consider.
If you are a new contributor please don’t be put off by lack of review, pester us and ensure your work is reviewed because moodle is really great place to work! You could look at some other bugs while you are waiting
I’m really privileged to be a mentor for Google Summer of Code with Moodle again this year! If you’ve not heard of google summer of code before the basic premise is that google fund university students to work on open source software over the duration of their summer break. The idea is to get more contributors into open source software and moodle is a proud participant to this great scheme. The great slogan is ‘flip bytes not burgers!’
Penny and I are really excited to be mentoring Christopher Waclawik in his project to make XML administrative settings for moodle. We’re just coming to the end of the community bonding period, developing the specification for the project and moving towards the start of coding, but of course we still need absolute community involvement!
Moodlers, imagine the prospect of installing moodle, choosing your local language and default settings which fit best with how you would like your moodle to be setup. This is one of the great aims of the project!
The advantages of these defaults have perhaps best shown themselves to me in the lively discussions which took place recently about grades over 100%. This concept of grades over 100% doesn’t seem to have spread much further than the in the USA, many outside the USA can’t understand the concept and indeed the original release Moodle 1.9 didn’t support this concept at all. Functionality has now been implemented in moodle to allow this – but it is not default. This choice makes sense to many but those who feel like this functionality is essential – like many localised settings in moodle its impossible to get the perfect defaults for all scenarios – this is really where I see these defaults fitting in.
In my own day job we are frequently overriding moodle defaults to fit more with our localised environment (UK schools) so I realy can envisage the advantages of these for institutions rolling out moodle. But what perhaps I think is the most exciting element of this project is that it doesn’t have to be exclusive, we could all create ‘dans awesome moodle settings’ moodle settings, share them amongst oursleves and satisfy our local preferences or legsilsative obligations. This power of templates might help to combat the misconception that moodle doesn’t fit ‘x senario’.
Please contribute your thoughts to Chris’ project specificaton, point out areas we’ve forgoten and other improvements we’ve missed! This is the great thing about open source, we’re hoping for you all to become involved and become invaluable resource to us all!