Why are you shocked? You’re basically advising OP to do the same thing that other posters are recommending.
(Also, you still have the OP’s original UN in your post).
@roundglasses74: you mentioned not getting your friend who gave you the answers in trouble. I wouldn’t worry about your friend, but rather about yourself. The issue at the moment is what YOU did, not your friend. You wouldn’t be posting here if you weren’t concerned about you, right?
There is nothing “selfish” in telling your teacher exactly what happened and why it won’t happen again. If that includes telling your teacher who gave you the answers to the earlier quiz, then so be it. The issue here is you.
Also, have you spoken to your parents? Before taking advice here, I would strongly recommend you speak to them and discuss what you should do.
Wishing you the very best!