The answer here is surely a monitored environment. An online editor/tester/compiler that logs not only the resulting code, but the way they got there. Anyone who pastes in 99% and just renamed the variables is trivially discovered. This probably works for far more than computer science.
It's not just a stick to beat kids with. You can work back to actually see where they're falling down, do seminars where you can open your environment to allow TAs and others to work on a single codebase collaboratively. This must exist already, no?