Microsoft Word File Import/Export (Question Format)

Question formats ::: qformat_wordtable
Maintained by Eoin Campbell
Import questions (including images and equations) from structured tables in a Word file (.docx format) into a course question bank, and also export questions to a Word file, allowing for round-trip editing.
Latest release:
4376 sites
1k downloads
183 fans
Current versions available: 6

This plugin allows quiz questions to be imported from a Word file into Moodle. You can quickly write lots of questions in structured Word tables far more easily than in Moodle directly. The plugin also imports tables, images, and equations (when created using the Microsoft Office Equation Editor, not MathType/Wiris or the old Equation 3.0 editor). Equations are converted into MathML on import and displayed using the MathJax filter. You can also export questions from the Moodle question bank into structured tables in Word. 

The table structure for each question supports all the question components (stem, answer options, option-specific and general feedback, hints, tags and question meta-data such as penalties, grades and other options). All the main question types except Numerical and Calculated questions are fully supported. Numerical and Calculated questions are exported, but cannot be imported.

The Cloze question syntax is particularly useful, as it does not require any knowledge of the arcane Moodle syntax; instead, use bold for drop-down menu items, and italic for fill-in text fields. See attached screenshot for an example.

Language support

Exported questions are labelled in the language of the current Moodle user interface, and the spell-check language is also set to the correct language. Similarly, questions can be imported in the same language, not just English. Both left-to-right and right-to-left languages (such as Arabic and Hebrew) are supported.

Equation support (import only)

Equations written using the Microsoft Equation Editor in Word can be imported into Moodle as MathML. This MathML is rendered within Moodle using the MathJax filter. Note that MathML equations in questions are not exported in a usable way.

Supporting Word templates

Word templates to go with the plugin can be downloaded from the demonstration website www.Moodle2Word.net, and are available for Word 2007 and 2010 (Windows), and Word 2011 (MacOSX).

Installation

The plugin can be installed by a Moodle Administrator using the standard Moodle plugin installation process.

Pre-requisites

  • Check that your Moodle installation supports XSLT, and ideally HTMLTidy too. Log in as Administrator, go to Site Administration -> Server -> PHP info, and view the PHP configuration. Look for the package details for 'xsl'. If they are not present, then you will need to re-configure PHP and re-start the server.
  • To enable XSLT and HTMLTidy on a Windows Moodle server, open your PHP configuration file (e.g. d:\winmoodle2\server\php\php.ini on Windows) and uncomment the lines containing "extension=php_xsl.dll". and "extension=php_tidy.dll" by removing the semi-colon before them, if present.
  • On Linux platforms, you may need to create a symbolic link from the file , /etc/php5/apache2/mods-available/xsl.ini to , or /etc/php5/apache2/conf.d/20-xsl.ini. Change directory to /etc/php5/apache2/conf.d/, and use the command 'sudo ln -s ../../mods-available/xsl.ini 20-xsl.ini'. Alternatively, create a file /etc/php5/apache2/conf.d/xsl.ini containing the line
    extension=xsl.so
      

Configuration instructions

  1. Go to any course question bank that contains at least 1 question, and choose the Export option.
  2. The File format list should contain the new option 'Microsoft Word table format'. Select this item, and choose any question category containing some questions.
  3. You will be prompted to save or open a Word file. Save it. By default it should have a .doc suffix. If no suffix is provided, you must add it in yourself to ensure Word recognises the file format.
  4. If you see the error message "You need the XSLT library installed in PHP to save this Word file" (xsltunavailable in non-English installations), then your Moodle installation is not configured to support exporting to Word format, and you will need to update it. See this forum thread.
  5. To import questions from a Word file, open the file you just exported, and save it to Word 2010 (.docx) format. Then go to the Question Import form, and you should see a new item in the File format list, 'Microsoft Word table format'. Select this item, choose the Word file you saved, and import it.
  6. If all goes well, your questions in the file should be imported into your course. If not, send me an email at help@moodle2word.net and I will try to help you out. 

Limitations

  • The number of questions you can import in a single Word file is limited by the amount of memory allocated for processes on your Moodle server, but should be at least 1,000 questions or more.
  • When you export questions they are saved in an intermediate Word-compatible format in a file with a .doc suffix. You must then save the file to the standard Word format (with a .docx suffix). 

Using a Word template to create and edit questions

To edit existing questions using Word, first export them into Word. If you want to create new questions, you should install a custom Word template on your PC to assist you. You can download this template from the test website www.Moodle2Word.net. This template contains commands to create new questions by means of inserting a specific structured table for each type.

Screenshots

Screenshot #0

Contributors

Eoin Campbell (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Eoin Campbell
    Fri, 26 Apr 2019, 9:35 PM
    No there isn't. The question ID number is assigned sequentially by the MySQL database when a new question is created. It would be nice to set an ID number so that questions could be overwritten, but that isn't possible. The same issue arises regardless of which import format you use - you cannot overwrite existing questions. The only alternative is that you can set an identifier in the question Name field (using the Word Heading 2 style), but this is not going to be unique.
  • Tariq Sadeck
    Mon, 29 Apr 2019, 4:58 PM
    Hi Eoin

    Thanks. I should've been more specific but I'm not talking about the MySQL "id" column.

    I'm talking about the "idnumber" MySQL column/fields in this pic: https://ibb.co/rM70jG2

    The "idnumber" field is part of the new features in Moodle 3.6 which will allow us to now have unique ID numbers for the questions and categories: https://ibb.co/xqrfP9T

    Regards
    Tariq

  • Eoin Campbell
    Mon, 29 Apr 2019, 5:21 PM
    News to me, as I’m still on 3.5. I’ll take a look
  • Tariq Sadeck
    Mon, 29 Apr 2019, 5:26 PM
    Thanks Eoin. Yeah thought as much when I realized its a new feature. Hope to hear from you soon if this is a possibility in future.
  • James Mackay
    Thu, 30 May 2019, 2:22 PM
    Hi Eoin,

    We had an issue come up recently when trying to import a document with questions. We imported some questions, but it just stopped at one and gave the error "error writing to database"

    All our other imports have worked fine, but this document in particular seemed to cause us grief. We inspected the questions surrounding the error, but we couldn't find any reason for the ambiguous error occurring.

    Any ideas why this would happen?

    Cheers
    James
  • Eoin Campbell
    Sat, 1 June 2019, 6:59 AM
    I believe the most likely reason is that there is a character in the Word file which is not a Unicode character and therefore isn't converted into UTF8 format, so when Moodle tries to write it to the underlying database, the database rejects it because the fields are configured to accept only UTF-8 encoded characters. This seems to happen with some ranges of mathematical characters in Word. Your image indicates that the questions are maths-oriented. You could use the Microsoft Office Equation Editor, as these equations are converted into MathML in Moodle, which can be displayed well in a browser if you configure the MathJax filter correctly.
    Go to Site administration > Plugins > Filters > MathJax, and the Additional equation delimiters field should contain "<math" to get the filter to recognise the equations.
  • James Mackay
    Tue, 4 June 2019, 8:00 AM
    Good to know - many thanks for your assistance with this Eoin. We will keep it in mind for next time we encounter that issue!
  • Lai Wei
    Thu, 20 June 2019, 5:09 PM
    I'm trying to export questions in this format and import it again somewhere else, and I got this error "The type of the file you selected (application/msword) does not match the type expected by this import format (application/vnd.openxmlformats-officedocument.wordprocessingml.document)." Looks like a bug to me. I'm on Moodle 3.6. Please take a look.
  • Eoin Campbell
    Thu, 20 June 2019, 11:15 PM
    The plugin exports files into a .doc file, but only imports files in .docx format. Silly but necessary. So after exporting questions to a Word file, you must then open it in Word and save it as a .docx file instead. Then you can import it to another server. However, if you just want to exchange questions between Moodle server, I strongly recommend that you export to Moodle Question XML format instead, as this is a more complete interchange format. For example, it supports Calculated and Numerical questions, which the Word plugin doesn't do.
  • Cameron Hallowell
    Mon, 1 July 2019, 6:40 PM
    Eoin, I am having issues trying to import or export Missing word style questions. Any thoughts
  • sachin sharma
    Wed, 24 July 2019, 6:35 PM
    Thanks for sharing this Valuable information with us, it is really helpful article!
  • Cameron Hallowell
    Mon, 19 Aug 2019, 9:46 AM
    Eoin, is there any way to change the default numbering from "A" to "0" for multiple choice questions?
  • Eoin Campbell
    Tue, 20 Aug 2019, 3:27 PM
    You can use the "Number the choices?" field in the table heading to define the numbering.
    A = uppercase alphabetic
    a = lowercase alphabetic
    i = lowercase Roman
    I (capital letter i) = uppercase Roman
    0 (zero) = Unnumbered
  • 松林 唐
    Wed, 21 Aug 2019, 12:13 AM
    Hi Eoin,
    I get errors when I import .docx questions. It seems like Jame said. "Error writing to database".
    This error comes after I upgrade moodle to 3.7 from 3.6. And I upgrade PHP from 7.0 to 7.2 .
    In PHP info of the sever , xsl is enable. Those .docx questions files which I imported into bank sveral weeks ago can't import again! I can't find wrong . So I 'm anxious. Can you help me ?
    songlin.
  • Eoin Campbell
    Wed, 21 Aug 2019, 11:41 PM
    This seems to be an error caused by modifying Moodle PHP code, not an import error
Please login to post comments