Skip to main content
Glama

get_quiz_grade

Retrieve a student's quiz grade on Moodle by specifying the student ID and quiz ID. Simplifies grading management for educators using the Moodle MCP Server.

Instructions

Obtiene la calificación de un estudiante en un quiz específico

Input Schema

NameRequiredDescriptionDefault
quizIdYesID del quiz
studentIdYesID del estudiante

Input Schema (JSON Schema)

{ "properties": { "quizId": { "description": "ID del quiz", "type": "number" }, "studentId": { "description": "ID del estudiante", "type": "number" } }, "required": [ "studentId", "quizId" ], "type": "object" }

Implementation Reference

  • The main handler function that implements the get_quiz_grade tool. It validates input, calls the Moodle API (mod_quiz_get_user_best_grade), processes the response, and returns the quiz grade information.
    private async getQuizGrade(args: any) { if (!args.studentId || !args.quizId) { throw new McpError( ErrorCode.InvalidParams, 'Student ID and Quiz ID are required' ); } console.error(`[API] Requesting quiz grade for student ${args.studentId} on quiz ${args.quizId}`); try { const response = await this.axiosInstance.get('', { params: { wsfunction: 'mod_quiz_get_user_best_grade', quizid: args.quizId, userid: args.studentId, }, }); // Procesamos la respuesta const result = { quizId: args.quizId, studentId: args.studentId, hasGrade: response.data.hasgrade, grade: response.data.hasgrade ? response.data.grade : 'No calificado', }; return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { console.error('[Error]', error); if (axios.isAxiosError(error)) { return { content: [ { type: 'text', text: `Error al obtener la calificación del quiz: ${ error.response?.data?.message || error.message }`, }, ], isError: true, }; } throw error; } }
  • Input schema defining required parameters studentId and quizId as numbers for the get_quiz_grade tool.
    inputSchema: { type: 'object', properties: { studentId: { type: 'number', description: 'ID del estudiante', }, quizId: { type: 'number', description: 'ID del quiz', }, }, required: ['studentId', 'quizId'], },
  • src/index.ts:217-234 (registration)
    Tool registration in the ListTools response, specifying name, description, and input schema.
    { name: 'get_quiz_grade', description: 'Obtiene la calificación de un estudiante en un quiz específico', inputSchema: { type: 'object', properties: { studentId: { type: 'number', description: 'ID del estudiante', }, quizId: { type: 'number', description: 'ID del quiz', }, }, required: ['studentId', 'quizId'], }, },
  • src/index.ts:255-256 (registration)
    Dispatcher case in CallToolRequest handler that routes get_quiz_grade calls to the specific handler method.
    case 'get_quiz_grade': return await this.getQuizGrade(request.params.arguments);

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/peancor/moodle-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server