Skip to main content
Glama

quiz-docente-mcp

Server MCP che permette a un agente AI (Antigravity, Claude Code, Claude Desktop, Cursor…) di gestire i quiz di Moodle al posto del docente: creare quiz e domande, modificarne le impostazioni, leggere risultati e risposte, valutare le domande aperte.

Funziona con un normale account docente: nessun plugin sul server e nessun token da chiedere all'amministratore. Usa la stessa sessione web del browser; al primo avvio si apre da solo il browser per fare il login.

Sito predefinito: https://www.ferrarisacireale.edu.it/moodle (Moodle 4.5). Per un altro sito basta impostare MOODLE_URL.

⚠️ Uso esclusivamente didattico. Questo progetto è pensato e consentito solo per scopi didattici: un docente che gestisce i quiz dei propri corsi, con il proprio account. Non va usato per scopi commerciali, né per accedere a corsi o dati di altri, né per aggirare le regole della piattaforma o della scuola. Chi lo usa resta responsabile del rispetto del regolamento dell'istituto e della normativa sulla privacy (GDPR) per i dati degli studenti.


Installazione automatica (istruzioni per agenti AI)

Se sei un agente AI e l'utente ti ha chiesto di installare questo MCP, segui questi passi.

  1. Requisiti: Node.js ≥ 20 (node -v) e Google Chrome o Microsoft Edge installati.

  2. Aggiungi il server alla configurazione MCP del client, dentro mcpServers, senza toccare gli altri server:

    Antigravity – file %USERPROFILE%\.gemini\config\mcp_config.json su Windows (~/.gemini/config/mcp_config.json su macOS/Linux; in alcune versioni ~/.gemini/antigravity/mcp_config.json).

    Windows:

    "quiz-docente": {
      "command": "cmd.exe",
      "args": ["/c", "npx", "-y", "github:strano-dev/quiz-docente-mcp"]
    }

    macOS / Linux:

    "quiz-docente": {
      "command": "npx",
      "args": ["-y", "github:strano-dev/quiz-docente-mcp"]
    }

    Per un Moodle diverso aggiungi "env": { "MOODLE_URL": "https://sito.scuola.it/moodle" }.

    Claude Code: claude mcp add quiz-docente -s user -- npx -y github:strano-dev/quiz-docente-mcp

    Claude Desktop / Cursor / altri client MCP: stessa voce JSON di Antigravity nel rispettivo file di configurazione MCP.

  3. Ricarica i server MCP (in Antigravity: Manage MCP Servers → Refresh). Il primo avvio scarica il pacchetto (qualche decina di secondi).

  4. Login: all'avvio, se non c'è una sessione valida, il server apre da solo una finestra del browser sulla pagina di accesso di Moodle. Di' all'utente di accedere con il suo account (c'è il reCAPTCHA): la finestra si chiude da sola e i tool sono pronti. Verifica con il tool moodle_status.

Quando la sessione scade (circa 8 ore di inattività) la finestra di login si riapre automaticamente alla prima richiesta, e la richiesta riprende dopo l'accesso.


Related MCP server: Moodle Study MCP

Cosa si può fare

Area

Tool

Sessione

moodle_status, moodle_login (forza un nuovo accesso)

Corsi

moodle_list_courses, moodle_list_sections

Quiz – lettura

moodle_list_quizzes, moodle_get_quiz (domande, pagine, punteggi + impostazioni), moodle_get_quiz_settings

Quiz – modifica

moodle_create_quiz (nasce nascosto se non si chiede visible: true), moodle_update_quiz_settings (date, durata, tentativi, valutazione, navigazione, comportamento, password, opzioni di revisione, visibilità), moodle_add_questions_to_quiz, moodle_add_random_questions, moodle_remove_quiz_slots, moodle_set_slot_mark, moodle_move_quiz_slot, moodle_set_quiz_max_grade, moodle_repaginate_quiz

Banca domande

moodle_list_question_categories, moodle_create_question_category, moodle_list_questions, moodle_get_question (Moodle XML completo), moodle_export_questions (GIFT/XML), moodle_create_questions (da JSON: scelta multipla, vero/falso, risposta breve, numerica, aperta, corrispondenza, descrizione), moodle_import_questions (GIFT, Moodle XML, Aiken, Cloze: qualsiasi tipo), moodle_update_question

Risultati

moodle_get_quiz_grades, moodle_get_quiz_responses, moodle_get_attempt_review, moodle_grade_attempt_question (voto e commento manuale, es. domande aperte), moodle_get_quiz_statistics

Scelta di progetto: niente eliminazioni

Non esistono tool per eliminare quiz o domande: le eliminazioni le fa sempre il docente, a mano, da Moodle. moodle_remove_quiz_slots toglie una domanda da un quiz ma la lascia nella banca domande. Un quiz che ha già tentativi degli studenti non permette di aggiungere o togliere domande (vincolo di Moodle).

Identificativi

  • courseid: id del corso (course/view.php?id=…)

  • cmid: id del quiz come modulo del corso (mod/quiz/view.php?id=…)

  • slot_id: posizione di una domanda nel quiz, da moodle_get_quiz

  • category_id, question_id: dai tool della banca domande, che accettano courseid (banca del corso) oppure cmid (banca propria del quiz)


Configurazione

Variabile

Default

Significato

MOODLE_URL

https://www.ferrarisacireale.edu.it/moodle

URL del sito Moodle

MOODLE_AUTO_LOGIN

1

1 = apre il login all'avvio e quando la sessione scade; ondemand = solo quando serve a un tool; 0 = mai

MOODLE_READ_ONLY

–

1 = espone solo i tool di lettura

MOODLE_MCP_DIR

~/.moodle-mcp

dove vengono salvati sessione e profilo del browser di login

MOODLE_BROWSER_PATH

–

percorso di chrome.exe / msedge.exe se non vengono trovati

MOODLE_LOGIN_TIMEOUT_MS

300000

attesa massima per l'accesso

La sessione è salvata in ~/.moodle-mcp/session.json e contiene il cookie di accesso: non condividerla. Login manuale da terminale: npx -y -p github:strano-dev/quiz-docente-mcp quiz-docente-mcp-login.

Sviluppo

git clone https://github.com/strano-dev/quiz-docente-mcp
cd quiz-docente-mcp
npm install
npm test           # test unitari (Vitest)
npm run check      # typecheck + test con copertura + build: da eseguire prima di ogni commit
npm run build      # compila src/ in dist/ (dist/ è versionata: serve a npx per avviare senza build)
npm run login      # login manuale
npm start          # avvia il server MCP su stdio

Regola: si procede sempre in TDD

Ogni modifica al codice segue il ciclo Test-Driven Development, senza eccezioni:

  1. Red – scrivi prima un test in test/ che descrive il comportamento voluto e verifica che fallisca.

  2. Green – scrivi in src/ il codice minimo che lo fa passare.

  3. Refactor – migliora il codice tenendo tutti i test verdi.

Regole pratiche:

  • ogni bug si corregge partendo da un test che lo riproduce;

  • nessuna nuova funzione o nuovo tool MCP senza i relativi test;

  • i test unitari non chiamano mai il Moodle reale: test/helpers/fake-moodle.ts simula il sito intercettando fetch, test/helpers/moodle-html.ts genera pagine sintetiche con la stessa struttura di Moodle 4.5 (nessun dato reale), Playwright viene sostituito con un mock;

  • prima di ogni commit npm run check deve passare; le soglie minime di copertura (righe 90%, rami 80%) sono configurate in vitest.config.ts e fanno fallire la suite se non rispettate;

  • dopo aver modificato src/ ricompila (npm run build) e versiona anche dist/.

File di test

Cosa copre

test/client.test.ts

cookie, redirect, sessione scaduta, sesskey, chiamate AJAX, file di sessione, parseNum

test/forms.test.ts

lettura e invio dei form Moodle (checkbox avanzate, select, editor, date, durate, errori)

test/courses.test.ts

corsi e sezioni

test/quizzes.test.ts

struttura del quiz, impostazioni, creazione, slot, domande casuali, voto massimo, pagine

test/questions.test.ts

categorie, elenco/export, conversione JSON → Moodle XML, import con upload, modifica domande

test/reports.test.ts

voti, risposte, revisione tentativi, valutazione manuale, statistiche

test/auth.test.ts

finestra di login (Chrome/Edge), timeout, lock contro finestre multiple

test/server.test.ts

elenco tool, modalità sola lettura, errori, login automatico con nuovo tentativo, mappatura argomenti

test/login-runner.test.ts, test/config.test.ts

comando di login e variabili d'ambiente

Come funziona

Moodle non espone ai docenti API per creare quiz e domande, quindi il server usa gli stessi endpoint dell'interfaccia web, ricavati analizzando il traffico del browser:

Funzione

Endpoint Moodle

corsi, sezioni, quiz di un corso

AJAX core_course_get_enrolled_courses_by_timeline_classification, core_courseformat_get_state

struttura del quiz

mod/quiz/edit.php

punteggio, rimozione, spostamento delle domande nel quiz

mod/quiz/edit_rest.php

aggiunta domande, voto massimo, ripaginazione

POST mod/quiz/edit.php

domande casuali

AJAX mod_quiz_add_random_questions

impostazioni e creazione quiz

form course/modedit.php (letto, modificato, reinviato)

categorie

question/bank/managecategories/category.php, AJAX core_form_dynamic_form

elenco e lettura domande

question/edit.php, question/bank/exporttoxml/exportone.php, pluginfile.php/…/question/export/…

creazione / import domande

upload repository/repository_ajax.php + form question/bank/importquestions/import.php

modifica domanda

form question/bank/editquestion/question.php (Moodle salva una nuova versione)

voti e risposte

`mod/quiz/report.php?mode=overview

revisione e valutazione manuale

mod/quiz/review.php, mod/quiz/comment.php

Testato su Moodle 4.5.11. I report voti/risposte sono stati verificati solo su quiz senza tentativi di studenti (le anteprime del docente non compaiono nei report).

Licenza

MIT (vedi LICENSE). Resta valida l'indicazione d'uso esclusivamente didattico riportata all'inizio.

Available Tools

29 tools
moodle_add_questions_to_quizAdd questions to quizB

Adds existing question-bank questions to a quiz (at the end, or to a given page).

Inputs: cmid (required), question_ids (required), page.

moodle_add_random_questionsAdd random questionsB

Adds N random-question slots drawing from a question category (each student gets different questions).

Inputs: cmid (required), count (required), category_id (required), page, +2 more.

moodle_create_question_categoryCreate question categoryC

Creates a question category (optionally under a parent category).

Inputs: name (required), cmid, info, courseid, +1 more.

moodle_create_questionsCreate questionsA

Creates one or more questions in a question-bank category from structured definitions (multichoice, truefalse, shortanswer, numerical, essay, match, description). Returns the new question ids.

Inputs: questions (required), category_id (required), cmid, courseid.

moodle_create_quizCreate quizA

Creates a new quiz in a course section. New quizzes are hidden by default (visible=false) unless visible=true is passed. Returns the new cmid.

Inputs: name (required), section (required), courseid (required), intro, +22 more.

moodle_export_questionsExport a question categoryB
Read-only

Exports all questions of a category in GIFT (compact, readable) or Moodle XML (complete).

Inputs: category_id (required), cmid, format, courseid, +1 more.

moodle_get_attempt_reviewAttempt reviewA
Read-only

Detailed review of a single attempt: per question text, answer given, state, mark, feedback, whether manual grading is needed.

Inputs: attempt_id (required).

moodle_get_questionGet questionB
Read-only

Full definition of a question (text, answers, fractions, feedback, settings) as Moodle XML. Embedded images are omitted unless include_files=true.

Inputs: question_id (required), cmid, courseid, include_files.

moodle_get_quizGet quizC
Read-only

Quiz structure (slots with slot id, page, question id, name, type, mark), totals, editability, plus the main settings.

Inputs: cmid (required).

moodle_get_quiz_gradesQuiz gradesB
Read-only

Overview report: each attempt with state, times, total grade and per-question marks, plus attempt ids for moodle_get_attempt_review.

Inputs: cmid (required), attempts.

moodle_get_quiz_responsesQuiz responsesC
Read-only

Responses report: the answer each student gave to each question (optionally with the right answer and question text).

Inputs: cmid (required), attempts, include_right_answer, include_question_text.

moodle_get_quiz_settingsGet quiz settingsB
Read-only

All quiz settings (timing, attempts, grading, layout, behaviour, review options, visibility). include_raw=true also returns every raw form field.

Inputs: cmid (required), include_raw.

moodle_get_quiz_statisticsQuiz statisticsC
Read-only

Statistics report (facility index, discrimination, etc.) of a quiz.

Inputs: cmid (required).

moodle_grade_attempt_questionGrade a question in an attemptB

Manually sets the mark (and optional comment) of one question in a student attempt, e.g. essay questions.

Inputs: mark (required), slot (required), attempt_id (required), comment.

moodle_import_questionsImport questions (GIFT / XML / Aiken)A

Imports questions from text in GIFT, Moodle XML, Aiken, missing-word or Cloze (multianswer) format into a category. Supports every question type. Returns the new question ids.

Inputs: format (required), content (required), category_id (required), cmid, +2 more.

moodle_list_coursesList my coursesC
Read-only

Courses the user is enrolled in (id, name, category).

Inputs: classification.

moodle_list_question_categoriesList question categoriesB
Read-only

Question categories of the course (or quiz) question bank with ids and question counts.

Inputs: cmid, courseid.

moodle_list_questionsList questions in a categoryC
Read-only

Questions of one category: id, name, type, status, version, usage count.

Inputs: category_id (required), cmid, courseid.

moodle_list_quizzesList quizzes of a courseB
Read-only

All quizzes in a course with cmid, visibility and section.

Inputs: courseid (required).

moodle_list_sectionsList course sectionsB
Read-only

Sections (topics) of a course with their numbers, needed to choose where to create a quiz.

Inputs: courseid (required).

moodle_loginSign in to MoodleA

Opens a browser window on the Moodle login page; the user signs in (reCAPTCHA) and the session is saved for the next calls. Normally not needed: the server opens the login window by itself when the session is missing or expired. Blocks until the login completes or times out.

Inputs: no named parameters.

moodle_move_quiz_slotReorder quiz questionB

Moves a slot after another slot (after_slot_id) or to the beginning (after_slot_id omitted).

Inputs: cmid (required), slot_id (required), page, after_slot_id.

moodle_remove_quiz_slotsRemove questions from quizA
Destructive

Removes slots from a quiz (the questions stay in the question bank). Use slot ids from moodle_get_quiz.

Inputs: cmid (required), slot_ids (required).

moodle_repaginate_quizRepaginate quizB

Re-paginates the quiz with N questions per page (0 = all on one page).

Inputs: cmid (required), questions_per_page (required).

moodle_set_quiz_max_gradeSet quiz maximum gradeB

Sets the maximum grade of the quiz (e.g. 10), rescaling the sum of marks.

Inputs: cmid (required), max_grade (required).

moodle_set_slot_markSet question mark in quizC

Sets the maximum mark of one quiz slot.

Inputs: cmid (required), mark (required), slot_id (required).

moodle_statusSession statusA
Read-only

Checks whether the saved Moodle session is valid and who is signed in.

Inputs: no named parameters.

moodle_update_questionUpdate questionB

Edits an existing question (Moodle saves it as a new version). Only the given fields change. "answers" replaces the whole answer list (multichoice/shortanswer/numerical); "correct" is for truefalse.

Inputs: question_id (required), cmid, name, text, +10 more.

moodle_update_quiz_settingsUpdate quiz settingsC

Changes quiz settings; only the given fields are modified. Returns the settings after saving.

Inputs: cmid (required), name, intro, review, +21 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 29 tools

    Disambiguation4/5

    Most tools have crisply separated purposes: quiz structure vs settings vs grades vs responses vs statistics vs attempt review are clearly delineated, as are the slot-manipulation tools. The main overlaps are moodle_create_questions vs moodle_import_questions (both create questions, differing only in input format) and moodle_get_quiz vs moodle_get_quiz_settings, but the descriptions make the boundary reasonably clear.

    Naming Consistency5/5

    Every tool follows the same moodle_verb_noun snake_case pattern with a consistent server prefix (moodle_get_quiz, moodle_list_questions, moodle_create_quiz, moodle_set_slot_mark). Verb choice is predictable by intent: list_* for enumeration, get_* for single-resource detail, create/update/remove/add/move/set for mutations.

    Tool Count3/5

    At 29 tools the surface is heavy and sits above the comfortable range, though the breadth follows from a genuinely large domain (quizzes, slots, question bank, grading, reports). Almost every tool maps to a distinct Moodle operation, so the size is defensible, but several could be consolidated (e.g. get_quiz/get_quiz_settings, create/import questions).

    Completeness3/5

    Read and authoring coverage is strong across quizzes, slots, questions and grading, but destructive lifecycle operations are entirely absent: no delete_quiz, delete_question, delete_question_category, or delete/duplicate quiz, and no enrollment/participant listing. These gaps will force agents to fall back on the Moodle web UI for common cleanup tasks.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers