Parameters in AJAX Call

Re: Parameters in AJAX Call

by Damyon Wiese -
Number of replies: 0

You are free to do what you think makes sense it your own plugins.

Yes it is OK to call lib functions from externallib (in fact this is good separation and re-use). The extra things an external lib function needs to take care of are: validating parameters, calling external_format_text / external_format_string on strings that are returned, ensure permission checks are correct.

However - IMO an API function returning a HTML table is not a clear separating of logic and presentation. A better alternative would be to return the data for the table from the API function and render the table with a template.

https://docs.moodle.org/dev/Templates

This also means a themer can override the template to format the table differently for their theme (e.g. bootstrap has classes to make nice looking tables).


Average of ratings: Useful (2)