Monday, August 20, 2012

Export Questions from the Moodle 1.9 Question Bank into Ms Word

Moodle2Word is a great Moodle plugin by Eoin Campbell. With it, you can import Ms Word tables as Moodle quiz questions. You can also export Moodle quizzes from the Question Bank into Ms Word format. Eoin has a fantastic website resource that, thanks to his hard work, gives you tons of tools to do import and export of Moodle <--> Ms Word quiz questions. He's written the plugin for versions 1.9 and 2.x for Moodle. All you need is to login as Guest.

At the end this post, you will be able to export Moodle question bank questions into this Ms Word format:

Like what you see? Read on!

I came across this plugin recently when I had a need to convert my Moodle quizzes into Ms Word format. Alas! I discovered too late that in Moodle 1.9, one cannot simply convert a quiz into Ms Word format. However, if you have systematically built up a proper question bank with categories, then you are in for a treat. How many of us have the foresight and patience to build a proper question bank? Most, if not all, of my quizzes were built by importing an XML or a GIFT format file that contained quiz questions.

The method of creating a Moodle quiz without using Moodle's default quiz editor is a topic for another day. In this post, I will show you how to can export questions from the question bank into a neatly formatted Ms Word file. For that plugin to work, you need to have XSL and XSLT support for your server. For instructions on how to install the plugin, surf here and login using the Guest account.

So you need to edit your php.ini and also setup XSL and XSLT support from your CPanel.

Traverse to Site Administration > Server > PHP Info to view your PHP configuration. If it is setup correctly, then you should be able to see this:

Once your SLT and XSLT is setup, follow the instructions found in the link given. I've reproduced it as a png image below:

In Moodle 1.9, to export questions from the question bank, you have to go to your course and click on quizzes. Then click the Export tab and tick the wordtable file format. After that, choose the category of questions (you did earlier setup your categories inside your question bank right?) and click the "Export questions to file" button. See the image below.

The questions will be exported, and you will see the below screen data.

Clicking on the download link will open an Ms Word file with the default format shown below:

The output Ms Word file is verbose and full of table details - which are very useful and needed. They allow you to directly import the data within the tables, back into a Moodle quiz.

I have managed to modify (hack) the mqxml2word.xsl  file so that the output Ms Word file is less verbose and simplified like this (see below) in Ms Word:

When you do a Print Preview, it looks even cleaner:

However, this format does not show the correct answer. You can reveal the correct answers by editing the xsl file. Just uncomment line 406 which reads as:

<td style="width: 1.0cm"><p class="QFGrade"><xsl:value-of select="@fraction"/></p></td>

The result is an Ms Word file that shows the correct answers. You can print it and keep it as a type of marking scheme (we teachers need these kinda stuff, right?).

What are the advantages of this hack? Well, the hacked mqxml2word.xsl file created a Ms Word file that:
  1. is simplified with less clutter
  2. has questions that are sequentially numbered
  3. is almost ready for printing as a question paper. You can easily edit it in Ms Word to produce a proper question paper.
  4. can also show, for teachers and instructors' eyes only, the correct answer by uncommenting a section of code inside the mqxml2word.xsl file.
What's the disadvantage of this hack? Well the output Ms Word file cannot be imported into Moodle using Eoin's plugin for obvious reasons - I've changed the format here and there. However, if all you wanted was a nice, clean and less cluttered Ms Word output, you've got it.

Download the standard Moodle2Word plugin
Download the Moodle2Word
Standard Plugin for Moodle 1.9

Download the hacked (simplified) Moodle2Word plugin

You can download (Right-click and "Save link as" on Mozilla FireFox) my hacked mqxml2word.xls file for Moodle 1.9 from >>here<<. Just backup your original mqxml2word.xsl file. Then rename the downloaded mqxml2word_simplified.xsl file to mqxml2word.xsl

Summary: I've only covered a tiny aspect of Eoin Campbell's amazing plugin - the export to Ms Word feature. What I did was to tweak and hack the code inside the mqxml2word.xsl file so that I could have a cleaner, more usable Ms Word file for my environment.
Happy Moodling
Frankie Kam

If you like this post or site
a small donation would be nice but would last only a day,
otherwise leaving a comment (or a compliment) below will last me a month!

Ratings and Recommendations by outbrain