Fix cur_grade to be relative to the relevant program's start date

This should fix #1216. Also includes some other cleanup around grade and schoolyear logic.
I split it into two functions; I think the function names (+ comments) are more self-explanatory now.