diff --git a/tidyquestion.php b/tidyquestion.php
index 20fdc98c34e99e840c570b15e05196e2fbf8663b..268ac3c39e7d5508bbd3d54960ea2317ff1898bf 100644
--- a/tidyquestion.php
+++ b/tidyquestion.php
@@ -51,7 +51,12 @@ $PAGE->set_pagelayout('admin');
 require_login();
 
 // The URL back to the preview page.
-$returnurl = new moodle_url('/question/type/stack/questiontestrun.php', $urlparams);
+// TODO, when we drop support for Moodle 3, this link needs to go back to the dashboard, not the preview.
+if (stack_determine_moodle_version() < 400) {
+    $returnurl = question_preview_url($questionid, null, null, null, null, $context);
+} else {
+    $returnurl = qbank_previewquestion\helper::question_preview_url($questionid, null, null, null, null, $context);
+}
 // Create the question usage we will use.
 $quba = question_engine::make_questions_usage_by_activity('qtype_stack', $context);
 $quba->set_preferred_behaviour('adaptive');