Hm. Ok. To me, reading the code and the comments, it looks like you only update the db when the problem is score-able, and the student has *not* earned 100%. To me, it looks like if the student scores 100%, you do not write to database!!

That's not what you're saying is going on, so better comments are needed to help people reading the code not have that confusion.