Upgrading to Moodle 2.0

Over the week-end, I thought it was time to see how my Moodle block handled the upgrade to 2.0. I did a brand new install of Moodle 1.9-latest, restored my old SQL dev backup, anxiously proceeded to start the upgrade and... ta-dah! Short answer: it doesn't work. Here are my notes on a couple of issues I encountered during the upgrade, so I don't waste time when I try again after updating the plug-in.

Upgrading: "Error: database connection failed"

I use PostgreSQL and after uploading the 2.0 code the site would only display "Error: database connection failed". I'm not sure what's the best way to move past this, but here what worked for me. The configuration string for Postgres dabatases always looked strange in config.php, something like this:

$CFG->dbhost    = 'user=\'mydbuser\' password=\'mydbpass\' dbname=\'moodle\'';

I changed it to this:

$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'mydbuser';
$CFG->dbpass    = 'mydbpass';

and happily, I was able to move on. Unfortunately I had forgotten to turn off debugging (activated from the SQL backup), and there may have been some CSS/theme trickery to set up before upgrading so... the upgrade screens were quite bare and sad looking.

Plugin "block/dvreport" is defective or outdated, can not continue, sorry.

The upgrade is quite a depressing process. Whenever it encounters a module that won't work with 2.0, it just shows this message about "defective" and "outdated" and won't move forward until the 'defective' module is removed. I just rm -rf'ed them since this is a dev system, but this was a fresh install, and besides DVReport these used to be standard modules. The migration path for people who actually used them must be painful.

No CSS, text-only homepage

After the upgrade, search for "Theme selector" and select a theme.

Next?

Well, there is some documentation on migrating code to work with Moodle 2.0 so I'll start there. It's a stub though, and looks fairly incomplete. Reminds me of the initial work on DVReport: Moodle 1.7 came out when I was starting out and contributors had to figure out all the novelties like the new Role system before they were documented. I can do this again, just need to make the time!

Leave a comment

First publication!

I'm back from a short holiday (therefore of course sick, but it was relaxing up to that point!). I found out last week-end that the paper I wrote with my FYP supervisor, based on my final year project and dissertation in UL, has been published! The article abstract is available on the Inderscience website: "Seeing is believing: using Data Visualisation for formative feedback in computer supported online learning collaboration". I'm quite proud! The article talks about using data visualisation to help provide useful formative feedback in the context of the DVReport Moodle plug-in I wrote (and that I should really resume refactoring, some time...)

Leave a comment | 4 so far

Moodle deprecation warnings -> navigation bar build_navigation()

Over the week-end I rediscovered Moodle's DEVELOPER debug setting which surfaced many unpleasant warnings. The first kind was removed by following proper programming practices (ahem), the second kind involved a couple of deprecation warnings that reminded me that Moodle is slowly and surely making its way toward 2.0. I filed a bug about this against DVReport, I should be looking into that one over the summer (Moodle 2.0 release date is July 20th! It's so strange to see an actual date, after years of reading about the preparations. Sounds awesome :))

The old navigation bar, pre-1.9.8 I assume though I'm not sure when it was deprecated, used to look like this:

$navigation = '<a href="$url">$block_name</a> -> $action_name';

The "->" would indicate a separation between 2 links, and automatically generate a nice triangle picture in the breadcrumb.

DVReport screenshot of the navigation bar

With the new navigation style, you get to split up the different sections into different arrays. It might seem more cumbersome but I think in the end it's neater, because you get to make a distinction between every element of the navigation, as opposed to one long messy string where you can easily miss the arrows when reading. The visual output is the same.

$navigation = build_navigation(array(
        array('name' => $block_name,
            'link' => $url,
            'type' => 'title'),
        array('name' => $action_name,
            'link' => '',
            'type' => 'title')
        )
    );

The only meh thing about this is that "type" isn't really documented. The phpdoc comment reads "this really needs to be documented better" and lists a few values. As usual, there isn't one that quite fits what DVReport does, because DVReport is a block, not an activity or course module. So I picked 'title', which seems innocent enough -- we'll see what future updates to the core navigation bar code make out of that!

Leave a comment

Synchronous Hackathon

I attended for a couple of hours the Synchronous Hackathon in Tog today. I had vague plans on making progress with the Moodle plug-in, probably related to the unit testing / refactoring of the data crunching methods... Didn't happen, but I did find a new bug, which I managed to fix 10 minutes before my battery went down. Wince-worthy, a couple of global variables (ouch) not being cleared properly in various places, but still -- progress! I'm happy with the day, it was good fun. Now, to see if I can hook Geany saving function to a shell script I have to execute manually each time...

Leave a comment

Back to Moodle The joys of digging up old projects

I've ended up a bit discouraged about my Sugar involvement (there's probably a blog post about lessons learnt in there, after I finish processing events in a useful way) so I decided it'd be best to step back for a while and digest things in the background before trying again. In the meantime I thought it'd be cool to remove the dust from my old, old, old Moodle plug-in back from college.

Various things learnt, re-learnt and discovered over the past couple of days:

  • Remembered my old tip of appending a version number to the Moodle folders in /var/www/ and /var/wwwdata/ so I can install multiple versions of Moodle in parallel without having to remember which version is in "moodle"
  • Could not install nor find a threaded mod_php5 Apache module in my Debian repos, had to remove apache and install apache2 prefork instead. To be investigated still, I want to understand why the repos are set up this way.
  • Learnt to check http.conf for port conflicts before installing a new module. Django and mod_wsgi trying to read my PHP files on port 80 did not work well.
  • After updating the mod_wsgi port in httpd.conf, without having to add or configure anything the php files were running with no issues -- surprising and cool!
  • New Moodle point version, woohoo! Go 1.9.8, as smooth to install as usual.
  • Happy surprise: my plugin, DVReport, installed and worked properly! Guess there was no major architectural change between 1.9 and 1.9.8... ;)
  • Nasty surprise: visualisations (the core of the plugin) were not working
  • Realisation #1: using double-quotes (") to delimit text in not proper SQL. This is pretty sad considering how much effort and agony I spent worrying about creating database neutral queries at the time.
  • Realisation #2: MySQL is way too kind with horrible, broken, standardless SQL. I must have been tight on a deadline (or on crack) when I wrote one particularly crazy GROUP BY statement. I'm guessing MySQL just ignored the bits that didn't make sense, but since working on this plugin last I've fallen in love with PostgreSQL, who isn't so kind (sloppy?) in parsing queries. I'll keep using Postgres as my main backend (<3), but will be testing with MySQL as well for this plugin considering I'm apparently unable to write db neutral SQL the first time around :)

The project had remained untouched since October 2008, according to GitHub. Since then GitHub has acquired an issue tracker (major YAY!) and a download tab so I cleaned up the wiki (who'd been upgraded and wasn't parsing all the old syntax anymore either) and set those up. Now the only horrible thing that's left, is all that dreadful code... ;)

Leave a comment