Gmail content compliance rule (apps/Workspace/Gmail/compliance) should do the trick.
Create a new compliance rule, check all boxes in step 1, step 2 (expressions) you need to add an advanced content match where location is "sender header" , match type is contains text, and content is the student1's email address. You'll need to add another advanced content match choosing "recipient header" and specifying student2's email address. Step 3 choose REJECT message, then save.
You'll then need to create another compliance rule REVERSING the email addresses from the first rule, as the first rule only handles sending from student1 to student 2.