Import Moodle quiz questions from Excel or Google Sheets
Moodle imports questions from GIFT, Aiken and XML, formats few teachers write by hand. Our free qformat_spreadsheet imports multiple choice and true/false questions from a CSV.
Short answer: Moodle can import questions in formats such as GIFT, Aiken and Moodle XML, but most teachers write questions in a spreadsheet, and departments often share question lists as Excel files. Our free plugin, qformat_spreadsheet, adds “Spreadsheet (CSV)” to the question bank’s Import page: save the sheet as CSV and import it.
This is the seventh plugin in our series: one plugin for each Moodle plugin type, each one teaching DevLMS Studio, our AI plugin builder, how that type works.
The sheet
| type | question | A | B | C | D | correct | feedback |
|---|---|---|---|---|---|---|---|
| multichoice | What is 2 + 2? | 3 | 4 | 5 | B | Two pairs make four. | |
| multichoice | Pick the prime numbers | 2 | 4 | 5 | 9 | A,C | |
| truefalse | Moodle is written in PHP. | TRUE |
- Up to five answers (A to E). One correct letter makes a single answer question.
- Several letters (A,C) make a multiple answer question. Each right answer is worth an equal share, and each wrong one takes the same share off.
- Columns can be in any order. Optional columns:
feedback(general feedback) andname. - It reads files saved with commas, with semicolons (what Excel uses in much of Europe) or with tabs, and cells that contain line breaks.
- Save the sheet as CSV UTF-8 (in Excel: File > Save As > CSV UTF-8). Excel’s plain “CSV” uses an older encoding for accented and Arabic letters, and Moodle refuses those files.
- A row with a problem is skipped and named in the import report, for example “Row 3: a multiple choice question needs at least two answers”. The good rows are still imported.
It supports Moodle 4.5 LTS to 5.3 and is GPL. The code and an example file are on GitHub.
How a question format plugin works
From Moodle 5.3’s question import code and its Aiken and XML formats:
- A format is one class,
qformat_NAME, extendingqformat_default. It is not autoloaded, so it is loaded by path. readdata()reads the file, andreadquestions()turns it into question objects. The defaultreaddata()splits the file into lines, which breaks CSV cells with line breaks, so ours reads the whole file.- Each question object must carry the exact fields its question type expects. A true/false question needs
correctanswer,feedbacktrueandfeedbackfalse, and a multiple choice one needs arrays of answers, fractions and feedback. - Scores must be values Moodle offers in its own grade menus (100%, 50%, 33.33333%, 25%, 20% and so on), or the question will not save as expected.
We tested it with PHPUnit (semicolons, commas, multi-line cells, multiple answers, bad rows, escaping) and a Behat run that uploads the file on the real Import page and finds the questions in the bank.
What Studio learned
The question format guide is now in DevLMS Studio’s builder: the fields each question type needs, the fraction values, and the multi-line trap.
Need to import from a format your school already uses, like an exam system’s export? Describe it in DevLMS Studio and watch it built and tested in a real Moodle.
Need a Moodle plugin built or rescued?
Tell the scoping assistant what you need. You get a fixed price and a timeline in a few minutes, and an engineer reviews it within one business day.
Get a fixed quote