From 843c39dc3e0d577c905d003a272b20005b5f47f1 Mon Sep 17 00:00:00 2001
From: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
Date: Tue, 24 Oct 2023 16:26:45 +0100
Subject: [PATCH] Revert previous commit altering URLs.

---
 tidyquestion.php | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tidyquestion.php b/tidyquestion.php
index 20fdc98c3..268ac3c39 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');
-- 
GitLab