prevent overlap when student booking an appointmen

Hello again!
I use Scheduler in our university for a two years. And there is one of the firs thing that I was change in Scheduler. It is possible when student book appointments in the different courses in the same time. From my education practice I seen this as impossible thing.
There I move part of code that prevent to book an appointments in the different courses in the same time to the separated branch there. Currently one current student is checked - not group appointment is analyzed. Also student appointment by teacher is not analyzed. But I propose this code for you to review. Hope it will be helpful...