I was reviewing the mod_forum code for adding new discussions and posts in order to create new external functions for posting via the app. I noticed that the post_form.php is pretty complex since the form elements depends on capabilities, specific settings of the module or group settings/configurations.
We have to think also that moodle field forms have dependencies, size limitations, etc.. (everything you can configure via quickforms)
So basically, I see that there are 3 alternatives for retrieve all the information needed for building the form:
- Creating new external functions matching Moodle APIs, (groups_get_activity_allowed_groups, groups_get_activity_groupmode, has_capability, etc..)
PROS: Since they are generic, we can reuse them in other areas
CONS: Lot of logic and requests required in the code - Creating a new external function (generic) for retrieving all the user permissions and group status in a forum (so we retrieve in a single request all the information we need to build the form)
PROS: With a single request we'll retrieve all the information we need
CONS: It solves the request problem, but we still need complex logic for creating the form and we will need a new external function for every form - Retrieving all the Quickform elements generated in the post_form.php (including name, type, maxchars, validation rules, disabling rules, etc..)
PROS: We will be able to reuse the logic everywhere (for any moodle form)
CONS: It will require to implement a local framework for creating angularforms via quickform settings - As suggested by fred, create simple features / external functions (just title and post text). This means a partial implementation of the WS (or a _simple function)
Any ideas?