Possibility to retake a quiz two times


Does anyone know how to implement a function to retake a quiz? In my case till two times.
The user has to give at least 70% right questions, and if below that percentage there has to be a possibility of retaking the quiz.
It would be best if someone has to retake the quiz the answers he gave before are already filled out so he only has to correct the wrong answers.

I hope someone has an idea how to add this functionality!

Thanks in advance!