Fix range check in next_lesson
When next_lesson checks if there is a validity range after the current validity range, it uses the following if-block:
if validity_index >= len(validity_ranges):
But this would be the correct one:
if validity_index >= len(validity_ranges) - 1: