Sparse Scales (A feature implementation story)

Picture of Jody Steele
Sparse Scales (A feature implementation story)

What do you get when you average an A, a B, 2 Cs, a B- and an A+?  I don't know either, but the faculty at my university just expects it to work.

A feature we've had to implement, due to pressure from the senate at our university, is a way of allowing professors to mark by using a letter instead of a percentage.  After trying to convince them this was a bad idea, it was left to me to come up with something that would work.

With that in mind, I introduce to you the Sparse Scale:

F (0),,,,,,,,,,,,,,,,,,,,,,,,F (24),,,,,,,,,,,,,,,,,,,,,,,,F (48),,,,D-,,,D,,,D+,,,,C-,,,C,,,C+,,,,B-,,,B,,,B+,,,,A-,,,,,A,,,,,,A+,,,,,,,

Here's a tabular representation of the grade values for easier reading:

Scale Label Scale Value
F(0) 0
F(24) 24
F(48) 48
D- 52
D 55
D+ 58
C- 62
C 65
C+ 68
B- 72
B 75
B+ 78
A- 82
A 87
A+ 93

The letter<->percent values were chosen by the faculty, after MUCH back and forth trying to impress upon them that yes the numbers they chose here really did matter and the differen between an F@0% and F@48% was quite often the difference between passing a course and failing it outright (which is why they decided to list 3 different F values).

The first thing you'll likely notice about the scale above is probably "holy crap that's a lot of commas".  100 commas to be precise, representing every grade from 0 to 100. Since we wanted the letters to map to specific numbers, as above, it had to be done this way.

Going back to my initial question, we can now tell you what an A, a B, 2 Cs, a B- and an A+ averages out to: (87+75+65+65+72+93)/6 = 76% (Which when displayed as a letter using our campus letter ranges is a B).

As a first step this was good, because it allows professors to import grades using the grade letters instead of actual percentages, but when they mark the grade item within moodle it stills displays the numerical values for the "empty" spots in the grade dropdown box.

Scale Select box showing many blank entries.

This wasn't what we wanted, so we modified the core scale handling code and added a option, triggered by "%HIDE_EMPTY%" being part of the scale's description, that would remove any empty values from the dropdown.

After coding this, the select box now showed exactly what we wanted

Scale select box with no blank entries

A couple of months down the line, an issue was reported from one of the faculty using this feature.  It appeared that class averages weren't working in his course, and he didn't know why. (For the image I've set the display to be "Real (%)" to show that the percentage is being calculated correctly).

Gradebook with "missing" average for SARP grade

Going back, once again, to my original question, we see that the average would be 76.2, which the scale would round to 76.  The 76th item in the scale is empty.

Here we tossed around a couple of solutions:

1) Always round up (B+)

2) Always round down (B)

3) Round to the closest non-empty scale item (B)

4) Display a range (Between B and B+)

We decided to go with option #4.

Gradebook showing average in SARP column


The other issue that was discovered, around the same time as the above, is with the scale I mentioned, some students were confused about the marks they were receiving.

The user report for grades has a column that shows what range a mark can be, and with scales it shows the lowest value hyphen the hghest value.  Because our custom scale has a empty value, it was showing "F(0)-", making the student think they somehow received an F.

User report showing a range with no top grade

The fix, similar to the above, was to display the highest valid scale entry if the request value was above it, and the same for the lowest.

User report showing range with correct top grade


This is where our "Sparse Scale" implementation is currently (the above 2 bugs having been found/fixed in the past week or so), and leads me to the reason I told this story: I was wondering if you fine people had any comments or recommendations on the solution that we are using for this problem.  I'm the lone developer for a very small Moodle team at our university, and as such don't often have much of a community to bounce ideas off of, which leads to some Cowboy Coding on my part.


Would you have flat out told the faculty no? (not really an option as it was a directive coming from mush higher up the food chain than a single faculty person)  Done it differently?

Do you have any ideas on how we could improve the Sparse Scale feature?

Comments about the decisions we made?

Do you want the code?  Is this a feature request you think I should submit to core?


Anyways, thanks for taking the time to read this, hope I didn't bore you to tears ;)

Picture of Bob Puffer
Re: Sparse Scales (A feature implementation story)
Plugin developersTesters

We've turned off scales being aggregated into the grades because with 300 instructors it became impossible to explain to them that when they created their own custom scale each placehold only incremented the grade value by 1.  It was really quite simple to implement "letter grade input" into the LAE Grader report so an instructor could mark B- or b- and have it calculate to 1 less than the floor value for 'B'.

Picture of Paul Nicholls
Re: Sparse Scales (A feature implementation story)
Core developersPlugin developersTesters

Hi Jody,

Does your "display a range" solution apply to students' final grades as well as the overall average?  If so, that could be very handy for us - we have a situation where some teachers expect to be able to assign letter grades for individual assignments, but don't like the way that they can't immediately tell that a student's final grade has been rounded down.

Whether or not your solution (as it currently stands) does apply to students' final grades, I'd certainly be interested to see your code.  Are you able to make it available in a public Git(hub) repository?