Unless someone is paid to take the entire class. If it's not in your subject (a big 200 person Chemistry 101 class), how would you even know? A Chemist could just show up for the tests and earn $1k for 4 ~ 5 days of work.
Obviously this will be a problem for massive lecture classes, maybe those should be graded heavily on attendance with mandatory id inspection. But you're right, in the conditions you describe, this problem is not solvable.