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.
All the Muslim scholars agreed in a consensus that turning one's face to the Qiblah is a compulsory condition for the validity of the prayer.
Allah Says (what means): {And from wherever you go out [for prayer], turn your face toward al-Masjid al-Haram. And wherever you [believers] may be, turn your faces toward it.} [Quran 2:150]
They have also agreed upon that facing the Ka'bah itself is compulsory for the one who can see it.
As for the one who cannot see the Ka'bah, he has to turn only to its direction as Abu Hurayrah narrated that the Prophet said: “Al-Qiblah is what is between the East and the West.” [Al-Tirmithi who graded it Hasan and Saheeh]
This Hadeeth applies to the inhabitants of al-Madeenah and the Levant. Those who live in the East or the West, their Qiblah is what is between the North and the South; likewise, everyone should follow the direction of the Qiblah from his place.
Therefore, a slight turning aside from the Ka'bah itself does not affect the validity of the prayer.
Based on the above details, if the turning away from the Ka'bah is slight and it does not get you out from its direction, then there is no harm to perform Prayers in this mosque leaving it in the same position. However, if it is possible to turn accurately towards the Qiblah even with the help of putting lines on the floor, then it is preferable.
On the other hand, if the direction is different more than 45 degree, then you have to change the direction towards the Qiblah. If it is not possible, then at least you should change the direction of rows towards the Qiblah while praying.
Allah knows best.