Skip to main content
Glama

get_quiz_grade

Retrieve a student's grade for a specific quiz from the Moodle platform using student and quiz IDs.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
studentIdYesID del estudiante
quizIdYesID del quiz

Implementation Reference

  • The main execution handler for the 'get_quiz_grade' tool. Validates studentId and quizId, calls Moodle API 'mod_quiz_get_user_best_grade', formats response with grade or 'No calificado', handles errors.
    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 numeric parameters: studentId and quizId.
    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 MCP server's tools list, 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'], }, },
  • Switch case dispatcher that routes 'get_quiz_grade' tool calls to the handler method.
    case 'get_quiz_grade': return await this.getQuizGrade(request.params.arguments);

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/cfsandoval/Mcp'

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