Praise be to Allaah.
We thank you very much for sending this question to us, and we urge you to hasten to enter Islam, for Allaah does not accept any other religion. We also give you the glad tidings of a good future and good life if you enter this religion.
With regard to your question, we would like to answer it with another question, by which we do not mean anything silly or foolish:
If a student needs to go to the bathroom urgently during class, what does he do? The obvious answer is: he asks the teacher for permission and leaves the room.
Praying on time is more important than answering the call of nature. We would remind you of the following points:
Firstly: the times for prayer in Islam are long, praise be to Allaah. For example, the time for the Zuhr (midday) prayer – which is the prayer time which usually comes during the school day) does not end until the time for ‘Asr (mid-afternoon) prayer begins, so you can pray Zuhr from the time when the sun is at its zenith until the time when the shadow of an object is equal to its length. This time is a period of hours, not minutes, so there is bound to be an opportunity to pray within this time.
Secondly: there are usually breaks between classes; even if the break is only five minutes, you can make the most of it. There are also breaks for recess and for lunch during which you could pray. Otherwise you could pray after school is over and before the time for the prayer ends. Or you could ask the teacher for permission to leave before the class finishes so that you can go and pray. In some countries there are laws which enable the followers of different religions to practise the observances of their faiths at a specific time during the work or school day, so you could avail yourself of these laws if they exist.
Whatever the case, whoever fears Allaah and does his duty towards Him, Allaah will show him a way out and make things easier for him. When Allaah knows that a Muslim is keen to do the obligatory actions, He will help him. Finally, we would like to thank you once again for your question. We ask Allaah to guide you to the way of truth sooner rather than later, and to grant you good health and keep you safe and sound. May He grant you strength and success in your life and keep you safe from all evils.
May Allaah bless our Prophet Muhammad and all his family and companions.