maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
138 stars 147 forks source link

edge case [[validation:ans1]] with kids 10-13 #1077

Open Bjoern-Ge opened 7 months ago

Bjoern-Ge commented 7 months ago

[[validation:ans1]] of the input "+1" tells "1". 1+(-3) is shown as 1-3 That is a totally understandable simplification.

Together with the answer-test CAS-equal, I ran into the problem that 1 and +1 is interpreted differently by the answer test.

I suggest that the validation should also tell "+1"

sangwinc commented 7 months ago

Gosh, this really is an edge case to end the week on! For everyone else interested, you can reproduce the underlying issue in a castext session (with simp:false) as

{@disptree(1-3)@} {@disptree(+1-3)@}

This will display the underlying expression trees for 1-3 and +1-3.

ATEqualComAss(+1-3,1-3);

returns "true" (as I'd expect) so which test are you using here? CASEqual?

It's interesting that Maxima's tex command does show the +1, so we must have switched this off somewhere in our parser.

sangwinc commented 7 months ago

Right, that was easy to find: https://github.com/maths/moodle-qtype_stack/blob/master/stack/maxima/stackmaxima.mac#L770

sangwinc commented 7 months ago

I've removed that line and, as expected, we get a lot of failing unit tests. Mostly those are in the student input test section as follows.

Some of them would be ok (and what you're asking for!), but 7, 8, 12 would need work to "fix" and people will complain again about brackets in some of the others. That's probably why I added in that line. I think there were some more serious problems as well with display of derivatives.

Moodle 4.2.3+ (Build: 20231110), d7e3b07082bee1883f180b3a2ee3242f1ad8f7b1
Php: 8.2.7, mariadb: 10.11.4, OS: Linux 6.1.0-13-amd64 x86_64
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

...............................................................  63 / 465 ( 13%)
............................................................... 126 / 465 ( 27%)
............................................................... 189 / 465 ( 40%)
...............................................FFFFFFF.F.FFF... 252 / 465 ( 54%)
..............F................................................ 315 / 465 ( 67%)
............................................................... 378 / 465 ( 81%)
.........................FF.................................... 441 / 465 ( 94%)
........................                                        465 / 465 (100%)

Time: 05:10.544, Memory: 70.50 MB

There were 14 failures:

1) qtype_stack\studentinput_test::test_studentinput with data set #236 ('+1', 'php_true', '+1', 'cas_true', '1', '', 'Unary plus')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1'
+'+1'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

2) qtype_stack\studentinput_test::test_studentinput with data set #237 ('+0.2', 'php_true', '+0.2', 'cas_true', '0.2', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'0.2'
+'+0.2'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

3) qtype_stack\studentinput_test::test_studentinput with data set #238 ('+e', 'php_true', '+e', 'cas_true', 'e', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'e'
+'+e'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

4) qtype_stack\studentinput_test::test_studentinput with data set #239 ('+pi', 'php_true', '+pi', 'cas_true', '\pi', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'\pi'
+'+\pi'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

5) qtype_stack\studentinput_test::test_studentinput with data set #240 ('+i', 'php_true', '+i', 'cas_true', '\mathrm{i}', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'\mathrm{i}'
+'+\mathrm{i}'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

6) qtype_stack\studentinput_test::test_studentinput with data set #241 ('+x', 'php_true', '+x', 'cas_true', 'x', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'x'
+'+x'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

7) qtype_stack\studentinput_test::test_studentinput with data set #242 ('sqrt(+x)', 'php_true', 'sqrt(+x)', 'cas_true', '\sqrt{x}', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'\sqrt{x}'
+'+\sqrt{x}'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

8) qtype_stack\studentinput_test::test_studentinput with data set #244 ('1/sin(+x)', 'php_true', '1/sin(+x)', 'cas_true', '\frac{1}{\sin \left( x \right)}', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'\frac{1}{\sin \left( x \right)}'
+'\frac{1+}{\sin \left( x \right)}'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

9) qtype_stack\studentinput_test::test_studentinput with data set #246 ('(+1)', 'php_true', '(+1)', 'cas_true', '1', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1'
+'+1'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

10) qtype_stack\studentinput_test::test_studentinput with data set #247 ('[1,+2]', 'php_true', '[1,+2]', 'cas_true', '\left[ 1 , 2 \right]', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'\left[ 1 , 2 \right]'
+'\left[ 1 , +2 \right]'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

11) qtype_stack\studentinput_test::test_studentinput with data set #248 ('[+1,+2]', 'php_true', '[+1,+2]', 'cas_true', '\left[ 1 , 2 \right]', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'\left[ 1 , 2 \right]'
+'\left[ +1 , +2 \right]'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

12) qtype_stack\studentinput_test::test_studentinput with data set #266 ('a-+b', 'php_true', 'a-+b', 'cas_true', 'a-b', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'a-b'
+'a+-\left(b\right)'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

13) qtype_stack\studentinput_test::test_studentinput with data set #403 ('a++b', 'php_true', 'a++b', 'cas_true', 'a+b', '', 'The extra plusses or minuses ...s on b')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'a+b'
+'a++\left(b\right)'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

14) qtype_stack\studentinput_test::test_studentinput with data set #404 ('a +++ b', 'php_true', 'a+++b', 'cas_true', 'a+b', '', '')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'a+b'
+'a+++\left(\left(b\right)\right)'

/var/www/html/m402/question/type/stack/tests/fixtures/test_base.php:210
/var/www/html/m402/question/type/stack/tests/studentinput_test.php:49
/var/www/html/m402/lib/phpunit/classes/advanced_testcase.php:81

FAILURES!
Tests: 465, Assertions: 1367, Failures: 14.