MIDDAG for Moodle

customform_api_controller extends api_controller

Public SDK API Controller.

Extend this class to expose JSON-first endpoints that leverage the framework routing and middleware without touching Moodle globals directly.

Table of Contents

Methods

clone()  : JsonResponse
Clones a custom form by its ID.
export()  : JsonResponse
Exports a custom form by generating a downloadable file URL.
import()  : JsonResponse
Imports a custom form from a JSON file.
submit()  : JsonResponse
This method handles both save customform data.

Methods

clone()

Clones a custom form by its ID.

public clone(int $formid) : JsonResponse
Parameters
$formid : int

the unique identifier of the form to be cloned

Attributes
#[Route]
$path: '/customform/{formid}/clone'
$name: 'api_customform_clone'
$methods: ['POST']
Return values
JsonResponse

returns a JSON response containing the success status and a message indicating the result of the clone operation

export()

Exports a custom form by generating a downloadable file URL.

public export(int $formid) : JsonResponse
Parameters
$formid : int

the unique identifier of the form to be exported

Attributes
#[Route]
$path: '/customform/{formid}/export'
$name: 'api_customform_export'
$methods: ['GET']
Return values
JsonResponse

returns a JSON response containing the success status and the exported file URL, or an error message if the export fails

import()

Imports a custom form from a JSON file.

public import() : JsonResponse
Attributes
#[Route]
$path: '/customform/import'
$name: 'api_customform_import'
$methods: ['POST']
Return values
JsonResponse

returns a JSON response containing the success status and a message indicating the result of the import operation

submit()

This method handles both save customform data.

public submit() : JsonResponse
Attributes
#[Route]
$path: '/customform/submit'
$name: 'api_customform_submit'
$methods: ['POST']
Return values
JsonResponse

        
On this page

Search results