مَا نَجَحَ إِلَّا خَالِدٌ.
Only Khalid succeeded.
Within the relevant discourse, success is restricted to Khalid. The terminology of maqṣūr and maqṣūr ʿalayh identifies what is being restricted and to what the restriction is assigned. Yet the direction of restriction cannot be identified by spotting illā alone; the whole predication and the preceding question matter.
If the conversation concerns a stated set of examination candidates, 'only Khalid' is naturally understood within that set. It is not a universal assertion about every person in every possible examination.