MDL-64609 gradebook: Prevent infinite loop in regrading