class form_service

Methods

static moodle_url
generate_file_exporter(form $form)

Generates a file exporter URL based on the provided form data.

static moodle_url
generate_file_url(string $content, form $form)

Generates a URL for the exported file based on the provided content and form.

static bool
validate_import_structure(stdClass $json)

Validates the structure of an imported JSON object for a form configuration system.

static stdClass
replicate(stdClass $form)

Imports a form object, validates its structure, creates a new form if necessary, and performs custom form actions. Updates the form ID if the import is successful.

static deprecated_item
get_form_by_idnumber(string $idnumber)

Retrieves a form by its idnumber.

Details

at line 46
static moodle_url generate_file_exporter(form $form)

Generates a file exporter URL based on the provided form data.

Parameters

form $form

the form object containing the raw data to process

Return Value

moodle_url

the generated URL for the file exporter

Exceptions

moodle_exception
RandomException
JsonException

at line 69
static moodle_url generate_file_url(string $content, form $form)

Generates a URL for the exported file based on the provided content and form.

Parameters

string $content

the content to be written to the generated file

form $form

the form object used to generate the file's metadata and context

Return Value

moodle_url

the URL pointing to the generated file

at line 93
static bool validate_import_structure(stdClass $json)

Validates the structure of an imported JSON object for a form configuration system.

Parameters

stdClass $json

The JSON object to be validated. Expected to contain specific properties and nested structures.

Return Value

bool

returns true if the structure of the JSON object is valid, false otherwise

at line 142
static stdClass replicate(stdClass $form)

Imports a form object, validates its structure, creates a new form if necessary, and performs custom form actions. Updates the form ID if the import is successful.

Parameters

stdClass $form

The form object to be imported. The structure and configuration of the form will be validated during this process.

Return Value

stdClass

the imported form object with updated ID and configurations

Exceptions

moodle_exception

at line 178
static deprecated_item get_form_by_idnumber(string $idnumber)

Retrieves a form by its idnumber.

Parameters

string $idnumber

the unique identifier of the form

Return Value

deprecated_item

the form object if found, or false if no matching form exists

Exceptions

coding_exception
dml_exception