The html bit that mod_quiz_get_attempt_data returns is just the bit that is for the questions of the quiz. It's not a complete html document. You need to add <html></html>, <head></head> and <body></body> pairs to that to build a complete html document.
Here is what you can do. Using your browser, go the quiz page and then view the page source (html code). Using the generated html you see there, create an html document like below:
<!-- the hole content of the head section -->
<!-- the html bit you get from mod_quiz_get_attempt_data -->