Moodle Plugins directory: Question Web Service Import | Moodle.org
Question Web Service Import
The Questions Web Service Importer is a specialized local plugin designed to bridge the gap between external systems and the Moodle Question Bank. It exposes a custom Web Service API that enables the programmatic import of Moodle XML question files directly into specific courses.
Why use this plugin? By default, Moodle allows teachers to import questions manually via the user interface. However, institutions often have legacy systems, third-party question authoring tools, or migration scripts that generate questions in bulk. This plugin allows you to automate that pipeline, pushing thousands of questions into Moodle courses without a single manual click.
How it works The process is streamlined for automation:
Upload: Your external application uploads a standard Moodle XML file to the Moodle "Draft" file area via the Core Files API.
Import: Your application calls the exposed function local_questions_importer_ws_import_xml, providing the target courseid and the draftitemid of the uploaded file.
Process: The plugin parses the XML, creates all necessary categories (respecting hierarchy), and saves the questions into the course context.
Key Features
Fully Automated: No manual intervention required for question bank population.
Recursive Category Creation: Automatically builds the category tree structure defined in your XML file (e.g., Top/Year 1/Math/Algebra).
Standard Compliance: Built on top of Moodle's native XML import format (qformat_xml) and Question Bank API, ensuring compatibility with all standard question types.
Secure & Traceable: Operations are performed under a specific capability local/questions_importer_ws:import, ensuring only authorized service users can push content.
Usage Scenario
Ideal for universities migration projects where a Python/PHP script reads from a legacy database, generates Moodle XML, and pushes it directly to new course shells on the production server.
Requirements
- Moodle 4.5 or later.
- Web Services enabled on your site.
- A service user with the local/questions_importer_ws:import capability.
Comments