Query the Grade Scale Value
Grade scales are stored in the mdl_scale
table, however they are stored as a comma-separated list in the scale column, which makes them quite difficult to query directly from the database. Because the grade is just a number (e.g. 1, 2, 3), it is far more useful to show the corresponding grade scale grade description.
For example, the grade scale might have the following value stored in the scale column (formatted for readability with index):
-
1
Mostly separate knowing, -
2
Separate and connected, -
3
Mostly connected knowing
So a final grade of 2
would translate to Separate and connected if using this grade scale.
You can use the substring_index
function in MySQL or MariaDB to perform a look up of the corresponding grade scale value (grade description) using the grade value.
select
scale,
trim(substring_index(substring_index(scale, ',', 2), ',', -1))
from
mdl_scale
where
id = 1;
Simply, replace the index in the inner substring_index
call with the appropriate grade value (e.g. 1, 2, or 3) for this scale and it will give you corresponding grade scale grade description.
No Comments