Skip to main content
Glama

get_submission_content

Retrieve detailed student assignment submissions including text content and attached files from Moodle. Use student and assignment IDs to access specific submission data for review or analysis.

Instructions

Obtiene el contenido detallado de una entrega específica, incluyendo texto y archivos adjuntos

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
studentIdYesID del estudiante
assignmentIdYesID de la tarea

Implementation Reference

  • The handler function that executes the tool logic: fetches detailed submission content from Moodle using mod_assign_get_submission_status, processes online text and file plugins, constructs a response object, and returns it as JSON text.
    private async getSubmissionContent(args: any) { if (!args.studentId || !args.assignmentId) { throw new McpError( ErrorCode.InvalidParams, 'Student ID and Assignment ID are required' ); } console.error(`[API] Requesting submission content for student ${args.studentId} on assignment ${args.assignmentId}`); try { // Utilizamos la función mod_assign_get_submission_status para obtener el contenido detallado const response = await this.axiosInstance.get('', { params: { wsfunction: 'mod_assign_get_submission_status', assignid: args.assignmentId, userid: args.studentId, }, }); // Procesamos la respuesta para extraer el contenido relevante const submissionData = response.data.submission || {}; const plugins = response.data.lastattempt?.submission?.plugins || []; // Extraemos el texto de la entrega y los archivos adjuntos let submissionText = ''; const files = []; for (const plugin of plugins) { // Procesamos el plugin de texto en línea if (plugin.type === 'onlinetext') { const textField = plugin.editorfields?.find((field: any) => field.name === 'onlinetext'); if (textField) { submissionText = textField.text || ''; } } // Procesamos el plugin de archivos if (plugin.type === 'file') { const filesList = plugin.fileareas?.find((area: any) => area.area === 'submission_files'); if (filesList && filesList.files) { for (const file of filesList.files) { files.push({ filename: file.filename, fileurl: file.fileurl, filesize: file.filesize, filetype: file.mimetype, }); } } } } // Construimos el objeto de respuesta const submissionContent = { assignment: args.assignmentId, userid: args.studentId, status: submissionData.status || 'unknown', submissiontext: submissionText, plugins: [ { type: 'onlinetext', content: submissionText, }, { type: 'file', files: files, }, ], timemodified: submissionData.timemodified || 0, }; return { content: [ { type: 'text', text: JSON.stringify(submissionContent, null, 2), }, ], }; } catch (error) { console.error('[Error]', error); if (axios.isAxiosError(error)) { return { content: [ { type: 'text', text: `Error al obtener el contenido de la entrega: ${ error.response?.data?.message || error.message }`, }, ], isError: true, }; } throw error; } }
  • src/index.ts:199-216 (registration)
    Registration of the 'get_submission_content' tool in the ListToolsRequestSchema handler, including its name, description, and input schema.
    { name: 'get_submission_content', description: 'Obtiene el contenido detallado de una entrega específica, incluyendo texto y archivos adjuntos', inputSchema: { type: 'object', properties: { studentId: { type: 'number', description: 'ID del estudiante', }, assignmentId: { type: 'number', description: 'ID de la tarea', }, }, required: ['studentId', 'assignmentId'], }, },
  • Dispatch case in the CallToolRequestSchema handler that routes calls to the getSubmissionContent method.
    case 'get_submission_content': return await this.getSubmissionContent(request.params.arguments);
  • TypeScript interface defining the expected structure of the submission content returned by the tool.
    interface SubmissionContent { assignment: number; userid: number; status: string; submissiontext?: string; plugins?: Array<{ type: string; content?: string; files?: Array<{ filename: string; fileurl: string; filesize: number; filetype: string; }>; }>; timemodified: number; }

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