All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
If you are unable to lower your gaze from such a teacher and are tempted by looking at her, then you should not attend that class and you can seek another one, if available. Moreover, you should offer her your advice via the apt and due means, and if you could not do that and could not continue attending your classes without falling into temptation, then you should quit that school and join another one, if possible. However, if this option is not possible, it is better for you to quit education entirely so as to preserve your religion; for the preservation of religion is of much more importance than that of education.
We advise you to seek Islamic knowledge from Muslim scholars benefiting from their copious knowledge while steering clear of places of corruption and immorality and obscenity. May Allaah The Exalted Provide you with Islamic knowledge and Render you one of the Muslim Imaams and scholars of guidance. Among the due means that safeguard you against the temptations of women is marriage as soon as you can afford it, otherwise you may fast for fasting weakens sexual desire and connects you to Allaah The Almighty.
Allaah Knows best.