The religion of Islam has closed all the doors that will, and can lead to illicit behavior. We are ordered from Allah tala in the Holy Quran to keep our gaze lowered. Surah Al Noor, verse 30:
قُلْ لِلْمُؤْمِنِينَ يَغُضُّوا مِنْ أَبْصَارِهِمْ وَيَحْفَظُوا فُرُوجَهُمْ ذَلِكَ أَزْكَى لَهُمْ إِنَّ اللَّهَ خَبِيرٌ بِمَا يَصْنَعُونَ))
Translation: And say to the believers, that they are to lower their gaze, and protect their private parts. For surely that is most suitable for them. Verily, Allah is all aware of that which they do.
It is NOT permissible to gaze at a woman (non- mahram) that is not fully covered in accordance to shariah. Whether that individual is a professor or a fellow class mate. The shariah of Allāh tala takes preference in all our affairs.
One should bear in mind, that the shariah is in place to protect us from any wrong doings and to keep us on the path of purity and righteousness.
Another thing to consider, that shaytan is the ultimate enemy of mankind. His plots are very deceiving and filthy. One of the biggest tools that shayton uses in trapping men in doing wrong, is the use of the opposite gender. Our beloved Prophet has mentioned:
(النساء حبائل الشيطان) رواه رزين
Translation: Women are the traps of shayton.
We see in the hadith above that Rasool Allah) صلي الله عليه و سلم) is informing us, that shayton uses women in trapping men. Since we know that men are naturally inclined towards the opposite gender, shayton uses that to capture men in his evil plots.
Whether that be by bringing uncovered women in front of the gaze of men, in the form of a professor, Or bringing them in the form of a class mate. We must abstain from any means that can lead us to be in such a predicament. Therefore, Allāh tala mentions in the holy Quran in Surah Al Israa, verse number 32:
وَلَا تَقْرَبُوا الزِّنَا ۖ إِنَّهُ كَانَ فَاحِشَةً وَسَاءَ سَبِيلًا))
Translation: And do not even come near fornication. Verily it is an immoral act and an evil path.
We see in the verse above, that Allāh tala is not only prohibiting us from fornication, but he is ordering us to not even come close to such an act. Simply because what we have discussed above, that shayton uses many different means to trap us in his plot. The wise and righteous ones are those, who don’t give shayton the opportunity or means to stray us from the right path.