asalam au alaikum
i have been wondering that if it is right to pray in the class room while at school . the class rooms are quite dirty to pray in and the carpets are dirty as well so i will be looking forward for an answer.
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 is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
The purity of the place is a condition for the validity of the prayer. So, any person who prays in a place that lacks purity, his/her prayer is invalid. So if you mean by "dirty" that there is some Najaasah (religiously considered impurity) on the floor of the room or on the carpet, then the prayer in such a place is invalid. But if you mean by "dirty" that the place is dusty or just stained by some pure products, then praying there is possible provided there is no impurity on that floor or carpet. However, it is more appropriate that the person looks for a clean and pure place to pray in.
Finally, we would like to draw your attention to the fact that all places are initially pure and their being dirty with dust and the like does not necessarily imply that they are impure. The Prophet said: "Allaah has made the ground (earth) a mosque and a pure place for me (to pray in)." [Al-Bukhari and Muslim]
Allaah Knows best.
You can search for fatwa through many choices