Answer: Initially when the student spilled the bottle of ammonia the ammonia gas particles diffused with the particles of air in the room. We know that the rate of diffusion of gases is very high. So the entire room filled up with the pungent smell of ammonia.
When he opened the doors and windows and switched on the exhaust fan, the air from the room along with the ammonia gas diffused with the air outside the room.Moreover, outside air entered into the room so the concentration of ammonia gas in the room air reduced.Due to these reasons the student got relief.