in reply to Efficient Rating of Test Answers
The easiest code I can think of is to map the designation to a scalar, and then use ordinary numeric ranges to compare.
Spanning letters is not an issue.$answer =~ tr/OBAFGKM/1234567/; if ($answer >= 56 && $answer <= 59) ...
Now, you have a lot of the same code but just changing the ranges. Make it into a table, like so:
This lists the half-right range, then the full-right range. The code can extract these 4 values, convert them to numbers, test for full-right first (being a subset), then the larger half-right range, all with one block of code.@results= ( undef, #index 0 unused [ #describe question 1 qw/ g0 k5 g6 g9/ ], # another row for each question.
—John
|
|---|