How to test:
To test this, you need to force quiz_attempts.id and question_attempts.id to be out of step. In most Moodle installs, they are always the same, but there is no reason why this should be the case. The fact that they are normally the same tends to mask bugs.
So, before testing, use phpMyAdmin or something to just insert a row into the question_attempts table.
Then, you need to test:
1. Log in as a student and attempt an adaptive mode quiz. For at least one question, take several tries to get it right.
2. Log in as a teacher and review. Find the question with multiple tries, and in the history of responses table under the question, click on the step numbers for some earlier steps to open the question in that state in a pop-up.
3. Also as teacher, use the Make comment and override grade link to manually grade the question.
Those are the bits I actually changed. You should probably also test some other aspects of the quiz, like the manual grading report, and reviewing a question by clicking on its score in the quiz reports. Also, if you are brave, try re-grading.
The 'close window' button code was broken and I fixed it along the way. Try to find some other places that have a popup with a Close window button, and make sure they work.