Thousands of pupils have been taught by unqualified teachers due to a shortage of fully trained supply teachers.