A few 'bad apples' cheated on the test, and now everyone has to take the test again.
a bad/rotten 'apple' [=an apple that has rotted and cannot be eaten]
Everything in the cupboard was (arranged) 'in apple-pie order'.