Git just isn't the right tool for that. If I were to use this as a student, I would push nicely sanitized and consistent history after thoroughly rebasing, amending and fixup-ing my mistakes on my local clone.
There's nothing this too can do to prevent me from doing this.
If the teacher then judges the submission by also looking at the history, I will have an unfair advantage by just having read and internalized got features.