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 identifiers.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
quizIdYesID del quiz
studentIdYesID del estudiante

Implementation Reference

  • The primary handler function for the 'get_quiz_grade' tool. Validates input, calls Moodle API 'mod_quiz_get_user_best_grade', processes response into JSON with hasGrade and grade fields, handles Axios 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 for 'get_quiz_grade' tool 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 ListToolsRequestSchema handler, defining name, description, and input schema for 'get_quiz_grade'.
    { 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'], }, },
  • Dispatcher switch case in CallToolRequestSchema handler that invokes the getQuizGrade 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