-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
-
3.7.7, 3.8.4
-
None
-
1.0.0
-
MOODLE_37_STABLE, MOODLE_38_STABLE
Hi,
We have recently finished a new plugin which aims to categorize the courses and activities via the new custom field API (Moodle 3.7+).
Tagging was not an option as the categorisation was more similar to a list of options and sometimes the same tag could have been used for a different meaning (for example: Language (English, French...) or Theme (Building, Science, English...).
We ended up thinking about building custom fields specifically for this purpose. The end product is here : https://github.com/call-learning/moodle-local_resourcelibrary
But the discussion here is more about how to integrate, facilitate, reuse or improve some aspect of this implementation for a fully fledged course catalog or other purpose. Note that this implementation also adds the same custom fields to activities/modules to make a similar type of catalog.
As of now:
- All custom field types can be used as input value
- Some types of filtering is missing (for example we have equal or contain but not "not equal" for example).
- If a new type of custom field is added, then we need to add a new filter type
- It would have to be integrated with the global search.
I wanted to share some aspect I wish that were easier to integrate or some improvement that can be made if necessary (we can then probably create specific tickets for these).
So, sorry for the long ticket, I will shorten it if necessary.
I will also link tickets for improvements that are not related to this implementation but could make the Custom Field API (and user interface) easier to use.
Adding new custom field types to new entities: I wished there were a standard way to do it (i.e. maybe just add the custom field type in the local plugin).
- For the activities I used the hooks coursemodule_standard_elements, coursemodule_edit_post_actions, coursemodule_validation. However I wished that there could be an easier way/more standard way to do it for custom fields.
- For the courses: the current implementation of the new custom fields (3.7) courses is doing this directly in the edit/validation routine of the course. So it cannot be directly overridden (I used the $CFG->customscripts hack, but this should not be the case). In any case there is no Hook available to do the same thing as on the course modules.
Filters: I guess that it will have to be reviewed under the new report facility that Moodle workplace has. But this for now is very much "custom built". I was wondering if we could not integrate the filtering (display, and then building of the query) directly in the custom field API. I.e. this way we could maybe display a search bar for custom fields with the relevant filters.
Custom field API: I was wondering if we could not change the datafield() method to a static method (so without building an instance of a data controller). The real need here was to be able to obtain the right data field column name for an SQL query, so not sure we can entirely generalise so this can be maybe be left out.
Anyways, thanks for the good work on the CustomField API, this is definitely something that will allow us to add more features to Moodle.