From cfc936cc600afbe9312c213fa697f741e89f04b7 Mon Sep 17 00:00:00 2001
From: Tim Hunt <T.J.Hunt@open.ac.uk>
Date: Mon, 22 Aug 2022 15:40:51 +0100
Subject: [PATCH] Moodle 4.0: Fix notice in export one script. Fixes #842

---
 exportone.php                           | 8 ++++++--
 tests/behat/create_preview_edit.feature | 3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/exportone.php b/exportone.php
index 304ccdbe8..cf20175cb 100644
--- a/exportone.php
+++ b/exportone.php
@@ -17,6 +17,11 @@
 /**
  * Script to download the export of a single STACK question.
  *
+ * TODO: Since MDL-63738 landed in Moodle 3.6, this has been a core Moodle
+ * feature, so we don't really need to keep mainaining this file. We could
+ * use question/exportone.php, or question/bank/exporttoxml/exportone.php,
+ * as it later became, instead.
+ *
  * @copyright 2015 the Open University
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
@@ -30,8 +35,7 @@ require_once(__DIR__ . '/locallib.php');
 $questionid = required_param('questionid', PARAM_INT);
 
 // Load the necessary data.
-$questiondata = $DB->get_record('question', array('id' => $questionid), '*', MUST_EXIST);
-get_question_options($questiondata);
+$questiondata = question_bank::load_question_data($questionid);
 $question = question_bank::load_question($questionid);
 
 // Process any other URL parameters, and do require_login.
diff --git a/tests/behat/create_preview_edit.feature b/tests/behat/create_preview_edit.feature
index 392592bd8..eea377d42 100644
--- a/tests/behat/create_preview_edit.feature
+++ b/tests/behat/create_preview_edit.feature
@@ -71,7 +71,8 @@ Feature: Create, preview, test, tidy and edit STACK questions
       | Answer note | prt1-1-F |
     When I press "Create test case"
     Then I should see "All tests passed!"
-    And I should see "Test case 1 Pass"
+    And I should see "Test case 1"
+    And following "Export this question" should download between "3700" and "3800" bytes
     When I follow "Preview"
 
     # Use the tidy question script.
-- 
GitLab