Check number of lessons before writing to database.