Google Docs to Forms - Formswrite.com logo
BlogPricing

Convert Google Docs to Moodle Quizzes Programmatically with the Formswrite API

Formswrite Team

February 15, 2026

Convert Google Docs to Moodle Quizzes Programmatically with the Formswrite API

Convert Google Docs to Moodle Quizzes Programmatically with the Formswrite API

Creating quizzes in Moodle is slow. You have to manually enter each question, configure answer choices, set point values, and assign feedback — one question at a time. If you already have your quiz content in a Google Doc, why not automate the whole process?
The Formswrite API lets you convert any Google Doc into a Moodle XML file with a single API call. The AI reads your document, extracts questions and answers, and generates a ready-to-import Moodle quiz file.

How It Works

  1. Write your quiz in a Google Doc (multiple choice, true/false, short answer, etc.)
  2. Call the API with your document ID and format: "moodle"
  3. Download the Moodle XML file from the response URL
  4. Import into Moodle via Site Administration → Question Bank → Import
That's it. No manual data entry. No copy-paste errors.

Quick Start

cURL

bashcurl -X POST https://api.formswrite.com/api/v1/convert \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "documentId": "YOUR_GOOGLE_DOC_ID",
    "format": "moodle",
    "documentName": "Biology Midterm Exam"
  }'

Response

json{
  "success": true,
  "exportId": "export-uuid-here",
  "downloadUrl": "https://api.formswrite.com/api/forms/exports/export-uuid-here",
  "fileName": "Biology Midterm Exam-moodle.xml",
  "format": "moodle",
  "expiresAt": "2026-03-17T00:00:00.000Z"
}
Download the file from downloadUrl and import it into Moodle. The XML file is valid Moodle XML with all question types, answer options, correct answers, and point values included.

Python Example

pythonimport requests

API_TOKEN = "your_api_token_here"

# Convert Google Doc to Moodle XML
response = requests.post(
    "https://api.formswrite.com/api/v1/convert",
    headers={
        "Authorization": f"Bearer {API_TOKEN}",
        "Content-Type": "application/json"
    },
    json={
        "documentId": "1abc123xyz",
        "format": "moodle",
        "documentName": "Chapter 5 Quiz"
    }
)

result = response.json()

if result["success"]:
    # Download the Moodle XML file
    xml_response = requests.get(result["downloadUrl"])
    with open(result["fileName"], "wb") as f:
        f.write(xml_response.content)
    print(f"Moodle XML saved: {result['fileName']}")

Node.js Example

javascriptconst fs = require('fs');

async function convertToMoodle(docId, name) {
  const response = await fetch('https://api.formswrite.com/api/v1/convert', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.FORMSWRITE_API_TOKEN}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      documentId: docId,
      format: 'moodle',
      documentName: name
    })
  });

  const result = await response.json();

  if (result.success) {
    // Download the Moodle XML
    const xmlResponse = await fetch(result.downloadUrl);
    const buffer = await xmlResponse.arrayBuffer();
    fs.writeFileSync(result.fileName, Buffer.from(buffer));
    console.log(`Saved: ${result.fileName}`);
  }
}

convertToMoodle('1abc123xyz', 'Biology Quiz');

Supported Moodle Formats

The Formswrite API supports multiple Moodle-compatible output formats:
FormatAPI ValueFile TypeBest For
Moodle XMLmoodle.xmlStandard Moodle quiz import
GIFTgift.txtLightweight text-based format
Aikenaiken.txtSimple multiple-choice only
Clozecloze.txtFill-in-the-blank questions
H5Ph5p.zipInteractive content
QTI 2.1qti_21.zipIMS standard (cross-platform)
Just change the format parameter to switch between them.

Supported Question Types

The AI automatically detects these question types from your Google Doc:
  • Multiple Choice — single correct answer
  • Multiple Select (Checkboxes) — multiple correct answers
  • True/False — binary choice
  • Short Answer — text input
  • Essay / Paragraph — long-form response
  • Matching — pair items together
  • Fill in the Blank (Cloze) — embedded answers
  • Numerical — number-based answers
Correct answers, point values, and feedback are all extracted automatically when present in your document.

Batch Conversion

Need to convert multiple Google Docs to Moodle quizzes? Loop through your documents:
pythondocuments = [
    {"id": "doc_id_1", "name": "Quiz 1 - Cell Biology"},
    {"id": "doc_id_2", "name": "Quiz 2 - Genetics"},
    {"id": "doc_id_3", "name": "Quiz 3 - Evolution"},
]

for doc in documents:
    response = requests.post(
        "https://api.formswrite.com/api/v1/convert",
        headers={
            "Authorization": f"Bearer {API_TOKEN}",
            "Content-Type": "application/json"
        },
        json={
            "documentId": doc["id"],
            "format": "moodle",
            "documentName": doc["name"]
        }
    )
    result = response.json()
    if result["success"]:
        xml = requests.get(result["downloadUrl"])
        with open(result["fileName"], "wb") as f:
            f.write(xml.content)
        print(f"Converted: {doc['name']}")

Use Cases

  • Universities automating end-of-semester exam creation from faculty Google Docs
  • Corporate training teams converting onboarding documents to Moodle assessments
  • K-12 schools batch-importing weekly quizzes from teacher-created documents
  • EdTech platforms integrating Moodle quiz generation into their product
  • LMS administrators building automated content pipelines

FAQ

Can I import the generated XML directly into Moodle?

Yes. The generated file follows the standard Moodle XML format. Go to Site Administration → Question Bank → Import → Moodle XML format, and upload the file.

Does it preserve images from my Google Doc?

Yes. Images embedded in your Google Doc are extracted and included in the Moodle XML as base64-encoded data or external URLs.

Can I convert to other LMS formats with the same API?

Absolutely. Change format to canvas, blackboard, brightspace, schoology, or sakai to generate files for other learning management systems.

What if my document is very large?

Use async: true in your request body. The API will return a jobId immediately, and you can poll /api/v1/convert/status/:jobId for the result.

Do I need a Moodle plugin to use this?

No. The Formswrite API is a standalone service. You generate the Moodle XML file via the API and import it through Moodle's built-in import feature.

Get Started

Stop manually entering quiz questions into Moodle. Sign up for Formswrite and start converting your Google Docs to Moodle quizzes programmatically.

Share this post with your network


Formswrite - Google Docs to Forms Converter

Create forms in seconds, not hours

Convert Google Docs to Forms with one click

Save hours on quiz creation every month.

No more manual form creation. No more formatting hassles.

We care about your data in our privacy policy

© 2026 Formswrite. All Rights Reserved.