From d83eec7714014fbff05b70920139aa42409d354a Mon Sep 17 00:00:00 2001
From: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
Date: Mon, 22 Jul 2024 14:45:39 +0100
Subject: [PATCH] Minor updates to display of test page, and code tidy.

---
 questiontestrun.php                                 |  2 ++
 stack/bulktester.class.php                          |  2 +-
 .../parsingrules/033_no_extra_evaluation.filter.php | 13 ++++++-------
 tests/castext_test.php                              |  2 +-
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/questiontestrun.php b/questiontestrun.php
index 8f0259292..1ceec928f 100644
--- a/questiontestrun.php
+++ b/questiontestrun.php
@@ -203,10 +203,12 @@ if (empty($testscases) && $canedit) {
 }
 
 if (empty($testscases)) {
+    echo "\n<hr/>\n";
     $defaulttest = stack_bulk_tester::create_default_test($question);
     $defaulttestresult = $defaulttest->test_question($questionid, $seed, $context);
     echo stack_string('runquestiontests_explanation');
     echo $defaulttestresult->html_output($question, stack_string('runquestiontests_example'));
+    echo "\n<hr/>\n";
 }
 
 $deployfeedback = optional_param('deployfeedback', null, PARAM_TEXT);
diff --git a/stack/bulktester.class.php b/stack/bulktester.class.php
index b9152c5e8..83c91487d 100644
--- a/stack/bulktester.class.php
+++ b/stack/bulktester.class.php
@@ -451,7 +451,7 @@ class stack_bulk_tester {
         }
 
         if (!$tests) {
-            $defaulttest = stack_bulk_tester::create_default_test($question);
+            $defaulttest = self::create_default_test($question);
             $defaulttestresult = $defaulttest->test_question($qid, $seed, $context);
             if ($defaulttestresult->passed()) {
                 $ok = true;
diff --git a/stack/cas/parsingrules/033_no_extra_evaluation.filter.php b/stack/cas/parsingrules/033_no_extra_evaluation.filter.php
index 9f6061144..6bbd683bf 100644
--- a/stack/cas/parsingrules/033_no_extra_evaluation.filter.php
+++ b/stack/cas/parsingrules/033_no_extra_evaluation.filter.php
@@ -25,15 +25,14 @@ class stack_ast_filter_033_no_extra_evaluation implements stack_cas_astfilter {
     public function filter(MP_Node $ast, array &$errors, array &$answernotes, stack_cas_security $identifierrules): MP_Node {
 
         $process = function($node) use (&$errors, &$answernotes) {
-            if ($node instanceof MP_PrefixOp &&
-                $node->op === "''") {
-                    $node->position['invalid'] = true;
-                    if (array_search('Illegal_extraevaluation', $answernotes) === false) {
-                        $answernotes[] = 'Illegal_extraevaluation';
-                        $errors[] = stack_string('Illegal_extraevaluation');
-                    }
+            if ($node instanceof MP_PrefixOp && $node->op === "''") {
+                $node->position['invalid'] = true;
+                if (array_search('Illegal_extraevaluation', $answernotes) === false) {
                     $answernotes[] = 'Illegal_extraevaluation';
+                    $errors[] = stack_string('Illegal_extraevaluation');
                 }
+                $answernotes[] = 'Illegal_extraevaluation';
+            }
             return true;
         };
         $ast->callbackRecurse($process);
diff --git a/tests/castext_test.php b/tests/castext_test.php
index 11f2ab97d..89c22f154 100644
--- a/tests/castext_test.php
+++ b/tests/castext_test.php
@@ -842,7 +842,7 @@ class castext_test extends qtype_stack_testcase {
         $cs2->add_statement($at1);
         $cs2->instantiate();
 
-        $this->assertEquals('\({3\cdot x^2}\), \({-4.000}\), \({-4.000}\), \({3}\), \({1}\)', 
+        $this->assertEquals('\({3\cdot x^2}\), \({-4.000}\), \({-4.000}\), \({3}\), \({1}\)',
             $at1->get_rendered());
     }
 
-- 
GitLab