Self-test questions in Moodle

In an earlier post I outlined plans for migration of MedLearn to Moodle. The technical work is now done except for editor plugins. The migration is well underway.

The tricky bit was getting the self test questions to work. The purpose of self test questions is to enliven content and enhance learning. They are not intended to be an assessment, although it may be useful to record the answers.

The Quiz activity provides the best range of question types but it also forces questions into an assessment with a very specific workflow (start attempt; answer questions; finish; submit; review). We wanted a much looser workflow which did not present questions as a quiz. The answer (suggested by Tim Hunt) was to embed a preview question in an iFrame. We chose the Book module for the content into which the questions were embedded.

Students log in to our VLE (Sakai). They then launch an LTI tool which automatically provisions them in Moodle. They are assigned an adapted set of permissions to avoid the issues highlighted by Tim Hunt in this post. The LTI provider plugin does all the provisioning, including the assignment of the role with the permissions.

Questions are inserted into the book content using Generico filter and Atto plugin. I’ve defined a template which just takes the question number and applies the correct iFrame. A Javascript frame resize script triggers on load (and on change) so that the question appears seamlessly in the content. The plugin also has an Atto editor plugin to simplify editing.

I have modified the preview PHP so that the title and config have been stripped off, leaving just bare question with answer box and ‘check’ button. The preview PHP still accepts the querystring configuration so I passed &correctness=0&marks=0&markdp=0&feedback=1&generalfeedback=1&rightanswer=1&history=0 to it in the Generico template.

The script tag to load the JavaScript resize code is in AdditionalHTML config.

We’ve also made the content more mobile friendly using Bas Brand’s Bootstrap  3 theme and more semantically relevant HTML5 tags such as <figure>, <cite>, <dfn> and <dl>. We are about to start authoring Atto plugins to support these tags. JQuery is used to for image swaps, replacing the mouseovers and flash which aren’t mobile friendly.

The only missing feature which would be really nice to have is a way of browsing the questions from the question bank for insertion. It’s currently a little clunky to find the question ID for use in the Generico Atto plugin.

My thanks go to Tim Hunt, Juan Leyva (LTI Provider) and Justin Hunt (Generico) for making the tools which underpin this integration.

Migrating MedLearn to Moodle

Medical Sciences Division hosts its teaching material in a system called MedLearn. The pages are mixed with 2D and 3D images, video, interactive content and self test questions.

For 10 years we’ve used Magnolia CMS. It was a good, simple system. In the last 4 years they’ve released 5.x.x which requires significant effort to migrate. We tried to find an upgrade path but couldn’t without spending more than our budget. Staying on the 4.x.x branch was fine until a recent Java security changed stopped us from publishing new pages. We have decided to migrate.

There are plenty of CMS and VLEs to choose from but they need to be maintainable and free. We chose Moodle because it’s free, extensible and fits with our technology strategy. We were particularly happy with the variety of questions available through the Question Bank.

Moodle doesn’t really support our mix of teaching materials with self test question. The Book module provides a good structure for the teaching material; the Quiz Activity provides assessment. We wanted to mix these together. Lesson tool was discounted because the questions are too restrictive, the authoring is confusing and the questions are on separate pages

We think that we’ve found the solution with the Generico filter plugin and its accompanying Atto plugin. The filter will write in an iFrame showing a preview of the question. In due course we may change it to call Javascript which writes preview content into the page. All that’s missing is a method of browsing the Question Bank.

Moodle evaluation and testing using Vagrant

I wanted a Moodle environment for testing the latest STACK question code. The solution is to use a Vagrant box.

Vagrant allows for provisioning by a number of methods. I found a shell script developed by DigitalSparky which was ready to use. I added a build script for Maxima (to ensure it has the correct version) and made STACK part of the Moodle install.

I’ve forked the repository to my Github account. I hope that you find it useful.

To build this you will need:

The adapted script uses Ubuntu 14.04 LTS Trusty. The Moodle build is cloned from Github and will default to the latest version. The script can be changed to force an earlier version if needed. You can also look in the Hashicorp directory for other pre-built Vagrant boxes.

To complete the Install (assuming that your host system is Ubuntu):

  • install VirtualBox, Vagrant and git
    sudo apt-get install virtualbox vagrant git
  • clone the Vagrant script
    git clone https://github.com/whanrott/moodle-vagrant
  • change to the script’s directory
    cd moodle-vagrant/
  • start the Vagrant box and run the build script
    vagrant up
  • edit your hosts file to enable the URL http://moodle.local/ on your local machine. Add this line
    192.168.33.10   moodle.local

    • As an alternative you can install the Vagrant hostmanager Plug-In. Either approach will require administrator permissions to modify the Hosts file.
  • open http://moodle.local/ and complete the install. You will need to look at the notifications to install the plugins.

That should be all that’s needed for a Moodle development box.

Moodle, STACK and Maxima: Custom Data Sets

Maxima is extended through packages. The Moodle STACK plug has statistical support packages loaded by default. These are Stats, Descriptive and Distrib. We preload these packages using the optimisation steps.

We can load your data sets as part of the optimisation process. These will then be available as a matrix variable which you can use in questions. Manipulation of matrices isn’t as nice in Maxima as it is in the R environment, but it has a good range of functions.

Moodle, STACK and Maxima: Random Variables

The rand() function is STACK’s implementation of Maxima’s random() function.  Random variables are zero-numbered. You may need to use simplification to reduce the output to a single value.

x:rand(5);            /* pick a random number between 0 and 4 */
y:ev(rand(5)+1,simp); /* pick a random number between 1 and 5 */

NB: if the simplification is off then the result of y would be 4+1

The rand() function in STACK also picks from a list:

x:rand([a,b,c,d]);                   /* pick a random item from a list. 
                                        This list shows lower case letters */
y:ev((rand(5)+1)*rand([1,-1]),simp); /* pick a random positive or negative
                                        number between 1 and 5 */

You can apply this behaviour of the rand() function to any list object. For example

w:makelist(x,x,1,10);          /* make a list of integers between 1 and 10 */
x:makelist(2^x,x,1,8);         /* make a list of powers of 2 from 2^1 to 2^8 */
y:primes(2,30);                /* use the primes() function to generate a
                                  prime number between 2 and 30. */
z:map(fib,makelist(x,x,1,10)); /* use the map() and fib() functions to make a 
                                  list of the first 10 Fibonacci numbers */

NB: not all Maxima functions are allowed in STACK, but they can be enabled by MSD LT team if needed.

Moodle, STACK and Maxima: Simplification

Maxima will automatically simplify expressions when simplification is switched on.

Switch simplification off so that you can pre-calculate the question and any workings. Declare this option in the Question variables:

simp:false;

Simplification can be switched on an off in expressions:

(%i1) simp:false;
(%o1) false
(%i2) ev(2*x);
       2
(%o2) x  x
(%i3) ev(2*x,simp:true);
       3
(%o3) x

NB: the lines %i are input lines. Those with %o are output from maxima

Maxima cannot display intermediate steps for worked answers. It can be made to calculate those steps, if you’re willing to write them. This is much easier when simplification is switched off.

Moodle, STACK and Maxima: Getting Started

The STACK plugin for Moodle brings the Maxima to Moodle. Maxima is a Computer Algebra System which will calculate question variables and test student answers.

This is a first blog post in a set which will give tips for anyone wanting to start writing questions using STACK. There is also an Authoring Quick Start guide included in the documentation.

1. Write all your calculations into the Question variables field

It’s easiest to do all your calculations in one place and then includes these in the model answer and answer test fields. For worked answers, calculate intermediate results.

NB: all statements are terminated with a semi-colon; comments are shown by /* some text */

simp:false;        /* turn simplification off */
x:2;               /* define x variable */
y:3;               /* define y variable */
Ques:x*y;          /* product of x and y with simplification off */
Ans:ev(Ques,simp); /* product of x and y evaluated with simplification on */

You can now put Ans into the model answer field, and test against Ans in the potential response tree.

Documentation for Moodle STACK and Maxima

I found that authoring questions in STACK requires a relatively steep learning curve. The main reason is that STACK exposes the Maxima Computer Algebra System, and its command set which is ‘ALGOL-like‘. This is was very unfamiliar on first look but has elements which I recognised, having programmed in the R statistical language.

The following documentation sources have been invaluable in writing effective STACK questions:

  1. Plug-in overview on Moodle.org
  2. Documentation which installs with the Moodle Plug-in. This will be installed on any system running STACK. It’s easiest to view on GitHub.
  3. Documentation for Maxima on its’ SourceForge home site
  4. Maxima syntax documentation summary. Some of the guide is for interactive mode, but it shows how to craft expressions for your model answer and and potential response tree.
  5. Moodle’s LaTeX summary. Note that the \[ … \] markers are preferred to the $$ … $$ markers in STACK questions.

I also found it useful to install wxMaxima to use on my Ubuntu Linux box.

Moodle STACK installation on Ubuntu LTS

We’re investigating algebraic maths questions in Moodle at the moment. One of the question type plugins is STACK.

I tried to install the STACK question type plug in but it wasn’t working. The error was “CAS failed to return any data”.

The CAS is a Computer Algebraic System. In this case it is Maxima. Our server is Ubuntu. The latest Long Term Support version available is 14.04 Trusty. The default Maxima package for Trusty is Maxima 5.32. The minimum requirement is 5.25.1 but it wasn’t working for me. I decided to upgrade after a test on my local system.

I looked for a Launchpad repository which I could use for a prebuilt package to upgrade with. There are RPM files on the sourceforge homepage (for Red Hat) but no debs for Ubuntu.

The only option was to build the package from source.

Steps:

  1. install Ubuntu package dependencies: automake; clisp; gnuplot; texi2html and texinfo. The latter two are for the help files.
  2. remove currently installed version of maxima
  3. open the installation instructions for building from source
  4. clone using git command in their repository or download from source. Remember that the latest version supported by the Moodle plugin is 5.36.0
  5. go to the healthcheck <moodle_home>question/type/stack/healthcheck.php
  6. purge cache and check that all the tests complete successfully

Our implementation of the STACK question type now accepts the simple test question shown in the authoring guide.