diff --git a/mod/quiz/view.php b/mod/quiz/view.php
index a59f9f2531b..778208d05d5 100644
--- a/mod/quiz/view.php
+++ b/mod/quiz/view.php
@@ -382,24 +382,20 @@
if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) {
$attempturl = sid_process_url($attempturl);
}
-
- // TODO eliminate this nasty JavaScript that prints the button.
-?>
-
+ }
+ echo " window.open('$attempturl','$window','$windowoptions'); ".' " />';
+
+?>
-\n";