Details
Description
The way scales are implemented currently (Moodle 2.7) is that the activity modules each re-implement the logic of retrieving a list of scale items for a given scale and creating a menu from it. The chosen item is then pushed to the gradebook via the "grade_update" method where the grade_item in the gradebook identifies the scale in use. It would be much better if there was a single function responsible for creating a form element that represents a scale. There are other bits of scales logic hard coded in modules such as getting the min and max for a scale, converting a scale item to a points value, getting a list of scale items, getting a normalized grade from a scale item and getting the closest scale item to a value specified in points.
We should extend grade_scale from the "grade" api to encapsulate all this logic.
This API needs unit tests.