When opening all doors, they swing away from Harry no matter if he is on the outside or inside of the doors.
Ron tells Harry that there is a troll on the loose, who's cornered Hermione and because of that, needs to be attended at once. After following Ron to the correct door, that triggers the minigame in which you run away from the troll. After that, Harry and Ron act as if they are tricking the troll into the bathroom, and then act surprised after hearing Hermione scream. The timeline does not make sense.