A "who" clause is framed by commas when it is nonessential information. The sentence with commas means essentially "The students were allowed to go on a special field trip and oh by the way they passed their midterm but you don't really need to know that because all the students were allowed to go on that trip."
The sentence without commas means there were students who didn't pass their midterm and who therefore didn't get to go on the trip.