Featured plugin October 2014: Realtime Quiz

Featured plugin October 2014: Realtime Quiz

by David Mudrák -
Number of replies: 0
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

There is one thing I love on Moodle. It is the bottom-up way it was designed and implemented to meet teachers' needs. For teachers, by teachers. There are many systems in educational technology sphere that simply take existing functionality and push it (with more or less force) into the school environment. Moodle tries to provide teachers with well aimed tools for particular pedagogical scenarios.

The best plugins I've seen have this in common: they do one thing, they do it well, and the demand for that thing comes from real teachers' daily experience. The plugin I discovered just recently falls into this category. It is the Realtime Quiz activity module.

The following video gives an overview of the plugin's main features. It has been shot with older version but the concept is still the same.

We asked the plugin author, Davo Smith for a short interview. Read on and find out how the Realtime Quiz plugin started, how actual experience with Moodle as a teacher helps the development, or how releasing plugins and providing support for the community for free can eventually change one's career.

Interview with the maintainer

Hi Davo. Can you shortly tell us something about yourself and your background?

Picture of Davo Smith I live in Sheffield, with my wife, Sarah, and my two children. I have worked as a Senior Developer at UK Moodle Partner, Synergy Learning for the last 3 years. Before that, I spent 8 years as an IT teacher, and before that I was a developer on Superman: Shadow of Apokolips for PS2/Gamecube.

When I’m not busy developing Moodle plugins, my family are active members of our local church, I’m also involved in the Friends group for our nearest park, an annual Sheffield community arts festival (Peace in the Park) and the Sheffield Green Party.

How did you get into Moodle and Moodle development?

The sixth-form college where I taught for most of my time as a teacher used Moodle for their VLE. I was interested in the interaction you can get from the hand-held quiz clickers, but didn’t want the disruption of handing them out in an IT classroom, so I developed the Realtime Quiz plugin to work in a similar way within Moodle, but without the physical devices. I then developed the PDF annotation plugin, as students struggled to read my handwritten feedback on their assignments and the Checklist plugin, as they kept missing out important parts of those assignments. Drag and drop upload was developed, mostly, just to see if it could be done.

After releasing these plugins for free, I started to pick up a bit of freelance work (initially making additions to my own plugins). This then became a full-time job offer from Synergy Learning, which is where I am working now.

Does your previous teaching experience affect your work as a developer today?

Obviously, my own plugins would never have been developed if I was not using Moodle on a daily basis to support my classroom teaching. Whilst I am no longer a teacher, I hope I still have some good insight into what it is like to use Moodle for course delivery and this should have an impact when I’m thinking about how best to structure screen layouts and forms. It has certainly left me with a good understanding of the features available within Moodle core and the different ways they can be used (even if my teaching experience was with Moodle 1.9 only).

We know you are very active and supportive member of moodle.org community forums. What does providing support on forums give back to you personally?

I get a lot of enjoyment out of being able to help other people on the forums. I also find that reading posts and answering questions on there often leads me to discover new areas of Moodle, whether in the front end or inside the code. This is especially true when other Moodle developers (Tim, Andrew and Petr, to name a few) jump in to point out better solutions than the ones I’ve proposed.

What software and IDE do you use when developing for Moodle and how does your typical screen look like?

My main desktop runs Debian + KDE, with Apache as my local webserver and a MySQL database. I’ve been using PHPStorm as my main IDE for the last couple of years and would now feel very lost without many of its features (before then it was Emacs). Other indispensable tools are Chrome (with the built-in developer tools), git + gitk, meld for comparing changes and Spotify (on my Windows laptop) to keep me sane. On the rare occasions when I need to edit images or icons, GIMP or Inkscape come into play.

Typical desktop of Davo Smith

What is your common plugin development workflow and how do you organise the code in terms of branching, tags etc?

These days most of my plugin development is done for specific clients - typically there is a git repo with a copy of Moodle in it and any plugins for that client are developed in that repo. Where possible, these plugins are developed on a separate feature branch and then merged into the ‘master’ branch for internal testing, across to an ‘rc’ branch for customer approval then into the ‘release’ branch for deployment. For any that are subsequently released to the public, a separate github repo is created, containing just the latest code for the plugin itself, without the rest of the Moodle code.

For my own plugins, I tend to just work in the master branch, as much as possible. Within reason, I tend to keep the master branch compatible with all Moodle versions supported by that plugin (with a few extra ‘if’ statements to handle differences such logging/events and context objects). Whilst I appreciate the ‘cleanness’ of having stable branches for different Moodle versions of plugins, I find the simplicity of being able to apply a fix to just a single branch makes it easier for me to maintain my plugins in the limited spare time I have available.

I’m getting to love Behat tests more and more and, once I have a chance to write them for all my own plugins, I am sure they will save me a lot of time when checking them against each new Moodle release.

Do you have some particular plans for further development of the Realtime Quiz export plugin? Or do you consider it feature full now?

I’ve recently done a little bit of a tidy up on the plugin, adding some Behat tests and allowing a teacher to reconnect to the quiz if they’ve navigated away from it (which was essential to allow the Behat tests to work). I’ve also just had some fixes through from the developers over at Lancaster University. There have been a number of requests to add features such as updating the gradebook and working with the Moodle question engine; these are things that I would love to see in there at some point in the future.

As with all code that you look back on after a few years, there is always bits you’d love to rip out and rewrite, but overall I’m pretty happy about how it works now. Having Behat tests in place should also make it safer to rewrite some of the backend code, as well as quicker to test the plugin against new Moodle releases.

Thanks a lot Davo. And good luck with all your future contributions.

How it works

Realtime interactivity between two (or more) browser sessions is not natural part of the HTTP world. There are multiple mechanisms of how the feature can be achieved, typically relying on an mediating server and some kind of push technology or a polling technique. As admins of many Moodle sites do not have access to the web server configuration to perform required tuning, certain methods like long-polling do not suit Moodle well.

The Realtime Quiz uses technique called periodic refresh, also known as AJAX polling. The view.php file executes Javascript code that then periodically requests data from the quizdata.php script via XMLHttpRequest. There is an in-built support for prolonging the requests interval automatically in case of issues with the network (and recovering back once the server responses in reasonably short time again).

The module is using plain Javascript to implement this behaviour. Written years ago, it survived the Age of Frameworks until todays when vanilla JS approach becomes popular again. This may make it an interesting contribution to the ongoing discussion on future of Javascript in Moodle (to be precise, there is a small YUI-dependent function used for a visual effect in the question editor but most of the JS code does not rely on a framework).

Conclusion and suggestions

The Realtime Quiz code is well structured and easy to follow and study. It has clear design of database tables and capabilities. Some parts of the activity module interface (such as realtimequiz_user_outline() or realtimequiz_print_recent_activity() callbacks) are not implemented yet with a @todo note left in the code. Backup and restore are supported for both 1.9 and 2.x versions (on-the-fly conversion of 1.9 backups into 2.x during the restore is not implemented). The coding guidelines are generally followed, although internal functions do not have phpDocs documentation. The realtimequiz_pluginfile() function should probably do a bit more access checking, including the capability checks.

The module made very good impression on me, from both user and developer perspective. I am happy to give it our Featured plugin award, and to wish Davo good luck with further development of it.

Average of ratings: Useful (6)