I mentioned this on the general developer list, without drawing any comment, so I'll try here, even though it is not a MAJOR feature.
There are many sets of constants defined against small sets of integers. For example, completion/criteria/completion_criteria.php defines such a set. File cc1 excerpts the relevant definitions.
These constants are ubiquitous in the database tables, and they obscure the meanings. To determine the contents of such records requires manual cross-referencing with the code, as in this example from the contributed ad-hoc queries.
CASE WHEN p.criteriatype = 1 THEN "Self" WHEN p.criteriatype = 2 THEN "By Date" WHEN p.criteriatype = 3 THEN "Unenrol Status" WHEN p.criteriatype = 4 THEN "Activity" WHEN p.criteriatype = 5 THEN "Duration" WHEN p.criteriatype = 6 THEN "Course Grade" WHEN p.criteriatype = 7 THEN "Approve by Role" WHEN p.criteriatype = 8 THEN "Previous Course" END AS criteriatype,
If these constants change, the query will no longer work as expected, and may not work at all.
I noticed this when I was trying to grasp some of the intricacies of Moodle by looking at the install.xml files and making my own ad hoc db queries.
It seems to me that this situation can be relieved, without impacting the integrity of the code by creating an ancillary table or tables that provide a mapping from constants to meaningful text:- the reverse of the definitions in the code.
File cc2 shows an outline of the changes to the previous file. The procedure as outlined would create an in-memory mapping as well as the database mapping, but that can be dispensed wth.
Such changes can be made incrementally, gradually increasing the number of mappings. I, for example, am looking for a way to automatically assign a grade to the simple completion or non-completion of a particular activity, so I could map the constants that are of interest to me. Others, with other areas of interest, could extend the mappings.
Is this of any interest to the developers?