1. past ---->now = have you finished?
2. past ---->end of exercise<------now = did you finish?
1. Means have you finished (now or yet)? Implies they are nearly out of time.
2. Means did you finish (at all)? Implies that the students were out of time in the past.
Were we to say 'did you finish' at the time of 1. it would indirectly imply that they are out of time and should stop work. If they haven't finished now they will not finish at all.