Your version of the answer is correct, because when you were answering the teacher's question, you both were in the present. So only
I went to the toilet.
..is okay.
If you were relating this whole story later to somebody, then you might use the Past Perfect:
When I returned, the teacher asked me where I had been. I replied that I had gone to the toilet.
The Past Perfect is possible because you are retelling this story now. The moment when the teacher asked you is in the past, and the moment then you visited the toilet is in a deeper past.
Grammar terminology: my second example uses "backshifting" of tenses. More specifically, this is called "a backshift in reported speech" (here's another helpful explanation).
I think we can answer the question by ruling out the incorrect options.
- I had gone to Peru, which is right next door.
This sentence is in past perfect tense. Past perfect is used to avoid ambiguity when we mention two events that happened in the past. We use the past perfect for the earlier event. However, in many cases the chronological order is obvious; then we can use the simple past tense without causing any ambiguity.
- I was gone to Peru, which is right next door.
Here, "gone" is an adjective. At the first glance I confused it with a passive structure, but the verb "go" is an intransitive verb. By the way, the adjective "gone" describes "leaving a place". Therefore, it does not make sense in this context.
- I did go to Peru, which is right next door.
I think this sentence does not have a serious problem in terms of using tenses.
- I was going Peru, which is right next door.
In this sentence we have the past progressive (or continuous) tense. Progressive aspects are used to talk about a process. "I was going to Peru" implies that you were in the middle of your trip, for example somewhere between Peru and the location where you started your journey.
Therefore, as a learner, I would choose the third answer among those four options.
Best Answer
The slight nuanced difference might be
implies a short time ago
Whereas
might mean you missed the train by a greater amount of time than "left".
Both mean you were