All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Both menstruation and Janabah (major ritual impurity) prevent one from staying in the mosque.
'Aa’ishah narrated that the Prophet said: "It is not permissible for a menstruating woman and a person who is in the state of Janabah to remain in the Mosque." [Abu Daawood]
Another Hadeeth from Umm Salah reads: "A mosque is not lawful for a menstruating woman and one who is in the state of Janabah." [Ibn Maajah and at-Tabarani]
There is agreement among the scholars that it is forbidden for a menstruating woman and a person who is in the state of Janabah to stay in the mosque, but it is allowed for her/him to pass through it.
Allah Says (what means): {…or in a state of janabah, except those passing through [a place of prayer], until you have washed [your whole body].} [Quran 4:43]
'Aa’ishah, may Allah be pleased with her, said: "The Messenger of Allah ordered me that I should get him the mat from the mosque. I said: “I am menstruating.” He (the Prophet) said: “Do get me that, for menstruating is not in your hand."
Based on the above statement, we say it is permissible for a menstruating woman and one who is in the state of Janabah to pass through a mosque to take some need, without staying there.
As for the room for teaching Arabic and Quran, then there is no harm to pass through and remain there, since it takes the ruling of a school and it is not a mosque.
Allah knows best.