maths / moodle-qtype_stack

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

ATSigFigsStrict falsely returns false? #346

Closed alcarola closed 5 years ago

alcarola commented 6 years ago

Hi!

ATSigFigsStrict(80, 80, 2) = [0, "ATSigFigsStrict_WithinRange. "]; seems to incorrectly return false?

I think that in this ambiguous case, the student needs to be given right. I attach the question test protocol and the question, as in this case:

ATSigFigsStrict(270, 270, 2) = [1, ""];

Any idea what may be going on? I can attach the question itself if that is useful.

Thanks!

alcarola commented 6 years ago

Update:

ATSigFigsStrict(90, 90, 2) = [0, "ATSigFigsStrict_WithinRange. "]; ATSigFigsStrict(300, 300, 2) = [0, "ATSigFigsStrict_WithinRange. "]; ATSigFigsStrict(4000, 4000, 2) = [0, "ATSigFigsStrict_WithinRange. "];

Maybe it's the case when only the first digit is nonzero that triggers the bug?

sangwinc commented 6 years ago

Mikael,

I think the test is operating correctly. (See http://faraday.maths.ed.ac.uk/demo/question/type/stack/doc/doc.php/Authoring/Answer_tests_numerical.md )

You have chosen the "Strict" test which has the strict interpretation of the official rules. Therefore 90 has precicely 1 significant figure. Therefore SA-"80" is not equivalent to TA=80 to two significant figures, even though this is "within the range" of an ambiguous case. If you wanted 2 significant figures you should, strictly speaking, have SA="8.0e1". I know.... This is something the physics people were felt very strongly about, so we have two tests. The "Strict" test you are using and a less strict one....

I think STACK is behaving as intended, if not as expected!

Chris

On Sun, Feb 4, 2018 at 4:31 PM, Mikael Kurula notifications@github.com wrote:

Update:

ATSigFigsStrict(90, 90, 2) = [0, "ATSigFigsStrict_WithinRange. "]; ATSigFigsStrict(300, 300, 2) = [0, "ATSigFigsStrict_WithinRange. "]; ATSigFigsStrict(4000, 4000, 2) = [0, "ATSigFigsStrict_WithinRange. "];

Maybe it's the case when only the first digit is nonzero that triggers the bug?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/maths/moodle-qtype_stack/issues/346#issuecomment-362920022, or mute the thread https://github.com/notifications/unsubscribe-auth/AAvtL7kXXnOm19IGIfsNgXrB7ihjc5o7ks5tRdt6gaJpZM4R4oAc .

alcarola commented 6 years ago

Hi,

OK, thanks for the clarification! My imagination of the strict test was that it only looks on the form of the number to determine the number of significant figures. I took this into use because I seemed to have some cases where ATNumSigFigs returned the wrong answer, and I didn't want to hand out penalties for answers which were correct but wrongly judged by ATNumSigFigs. I guess I didn't pay enough attention to the "strict" part of the name.

Here is one example of the NumSigFigs problem with zero being the last significant digit:

I have a question with a question test which wrongly behaves as follows: ATNumSigFigs(2.8, 26102519/9315653, 3) = [0, "ATNumSigFigs_WrongDigits. "]; when I enter the same line into my stack-maxima sandbox, I correctly get (%i15) ATNumSigFigs(2.8,26102519/9315653,3); (%o15) [true,true,"",""]

See the attachment. Let me know if I should export the question to an xml file.

The server http://faraday.maths.ed.ac.uk/ is not responding by the way?

EDIT: I changed 2.80 to 2.8 in the sandbox example above, which makes the example clearer but does not influence the result in any way. I also attached the picture that I forgot earlier below and remark that the NumSigFigs test in the PRT checks abs(SAns1) against abs(Tans1) with sigFigs=3 in this case.

null hypothesis 4 sv random variant 268860573

alcarola commented 6 years ago

I can still add that the behaviour is the same even if I change the input type from Algebraic to Numerical. It says in the documentation that trailing zeros should be preserved in the Numerical input type, but I cannot observe that in the question tests.

alcarola commented 6 years ago

Hi again,

Any input on this? Seemingly I cannot deploy enough instances to publish homework for next week and the majority of my 85 students in fact seem to prefer an electronic exam in stack!

The subject is no longer correct, since this is now a discussion about ATNumSigFigs, not about ATSigFigsStrict.

Thanks, Mikael

sangwinc commented 6 years ago

This is all about the question tests! When you set up a question test, you need to use the ephemeral form for a number, in this case you need to specify that the test case actually has three significant figures: dispsf(2.80,3) Then it works.
This is a necessary part of the design because otherwise we can't randomly generate test cases.

The exact preservation of decimal digits through the web forms, PHP, maxima and back again is complex, and not at all obvious. I'm sorry the design got complicated. There we are.

Some docs are here: https://stack2.maths.ed.ac.uk/demo/question/type/stack/doc/doc.php/CAS/Numbers.md (faraday is an internal test machine, and I copied the wrong URL last time). Chris

alcarola commented 6 years ago

Thanks for your response! Please observe that I did use dispsf in the screenshot, but it didn't help. The trailing zero is discarded anyway.

alcarola commented 6 years ago

I could add that I use a fairly old Maxima, version 5.28.0. I cleaned the STACK cache, which unfortunately didn't help.

alcarola commented 6 years ago

I investigated a little bit further. When I try to run the answer tests for NumSigFigs, I only get a Maximapool error 500 after a little while (see attachment), whereas NumRelative gives me no problems (see below). Maybe there is something weird with my system, but how can I troubleshoot it?

Maxima 5.28.0 using Lisp SBCL 1.0.50 $plugin->version = 2017121600; (STACK 4.1 updated via git a few weeks ago)

NumSigFigs.pdf NumRelative.pdf

alcarola commented 6 years ago

I also have a very old maximapool. The date stamp is 5 Jan 2013, but I wonder if it can really be that old. maximapool.conf is date stamped 22 Apr 2015. Could that be a problem?

aharjula commented 6 years ago

Well that could be the problem. At the very least it would mean that you are using a version of the Pool that can't reliably tell STACK about timeouts and most definitely does not deal well with Unicode. You should really update that and switch to a newer Maxima version at the same time. For MaximaPool anything older than October 2015 is bad and newer than December 2017 would be better. I would guess that your MaximaPool is of the single library version branch the newer ones allow you to setup and support multiple STACK library versions in the same pool to allow faster upgrades with the option of rollback when upgrading the STACK Maxima libraries.

sangwinc commented 6 years ago

Mikael, perhaps you could email me an example and I'll happily check it out on the latest code? There have been lots of improvements to the way we deal with numerical quantities. I agree with Matti that the latest code should be used if possible. Happy to help if we still have a problem here.

alcarola commented 6 years ago

Thanks for the advice and reopening! I now installed the latest multi-library maximapool and that indeed fixed all of the NumSigFigs tests except for one! I also compiled and installed the latest sbcl lisp and maxima. Git pull revealed that I already had the latest STACK 4.1.

The STACK-maxima sandbox now starts in a few seconds, but I cannot get STACK to connecto to Maxima from within moodle. Neither the healthcheck script nor the cas chat seems to work. I am not sure that I use the cas chat correctly though, could you give me an example? (Tried googling but found none.)

I do not understand what could be wrong. Any suggestions?

My current STACK settings: Platform type: Linux Maxima version: 5.41.0 Maxima command: /usr/local/bin/maxima

-bash-4.1$ /usr/local/bin/maxima --version Maxima 5.41.0

-bash-4.1$ ll /data/moodledata/stack/ totalt 93904 drwxrwxrwx 2 apache apache 4096 5 maj 2016 logs -rwxrwxrwx 1 apache apache 4071 8 feb 11.44 maximalocal.mac -rwxr-xr-x 1 apache apache 96108592 22 jan 11.56 maxima_opt_auto drwxrwxrwx 2 apache apache 53248 8 feb 11.33 plots drwxrwxrwx 2 apache apache 4096 8 feb 00.06 tmp

-bash-4.1$ tail /data/moodledata/stack/maximalocal.mac stack_unit_other_unit_code:[min, amu, u, mmHg, bar, cc, gal, mbar, atm, torr, rev, deg, rpm, K, day, year, in, ft, mi], stack_unit_other_unit_conversions:[s60, amu, amu, 133.322387415Pa, 10^5Pa, m^310^(-6), 3.785l, 10^2Pa, 101325Pa, 101325/760Pa, 2pirad, pirad/180, pirad/(30s), K, 86400s, 3.156e7s, in, 12in, 528012in], stack_unit_other_unit_tex:["\mathrm{min}", "\mathrm{amu}", "\mathrm{u}", "\mathrm{mmHg}", "\mathrm{bar}", "\mathrm{cc}", "\mathrm{gal}", "\mathrm{mbar}", "\mathrm{atm}", "\mathrm{torr}", "\mathrm{rev}", "\mathrm{{}^{o}}", "\mathrm{rpm}", "\mathrm{K}", "\mathrm{day}", "\mathrm{year}", "\mathrm{in}", "\mathrm{ft}", "\mathrm{mi}"], true)$ / Load the main libraries. / load("stackmaxima.mac")$ load("stats")$ load("distrib")$ load("descriptive")$ print(sconcat("[ STACK-Maxima started, library version ", stackmaximaversion, " ]"))$ -bash-4.1$

-bash-4.1$ cd -bash-4.1$ cd stack-maxima/ -bash-4.1$ maxima Maxima 5.41.0 http://maxima.sourceforge.net using Lisp SBCL 1.4.4 Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. WARNING: redefining MAXIMA::OPAPPLY in DEFMACRO WARNING: redefining MAXIMA::OPCONS in DEFMACRO define: warning: redefining the built-in function intervalp WARNING: redefining MAXIMA::TEX-MQUOTIENT in DEFUN WARNING: redefining MAXIMA::TEX-PREFIX in DEFUN WARNING: redefining MAXIMA::TEX-STRING in DEFUN WARNING: redefining MAXIMA::TEX-DERIVATIVE in DEFUN WARNING: redefining MAXIMA::TEX-D in DEFUN WARNING: redefining MAXIMA::TEX-DABBREV in DEFUN WARNING: redefining MAXIMA::TEX-INT in DEFUN WARNING: redefining MAXIMA::TEX-MEXPT in DEFUN

; file: /var/www/html/moodle/question/type/stack/stack/maxima/mathml.lisp ; in: DEFUN MATHML1 ; (MAXIMA::CONCAT "(" (MAXIMA::STRIPDOLLAR MAXIMA::MEXPLABEL) ")") ; ; caught STYLE-WARNING: ; undefined function: CONCAT ; ; compilation unit finished ; Undefined function: ; CONCAT ; caught 1 STYLE-WARNING condition define: warning: redefining the built-in function texnumformat WARNING: redefining MAXIMA::TEXNUMFORMAT in DEFUN [ STACK-Maxima started, library version 2017121600 ] (%i1)

alcarola commented 6 years ago

Forgot to say that I also have: CAS connection timeout: 30

-bash-4.1$ which maxima /usr/local/bin/maxima

aharjula commented 6 years ago

Are you by any chance loading that maximalocal.mac over an optimised image? If so you should comment out the load commands at the end to not load them again which wastes time and generates those warnings about redefining stuff...

alcarola commented 6 years ago

Hi,

No, I believe I run explicitly /usr/local/bin/maxima in all instances, which is freshly from sudo make install in the maxima source directory. The contents of my stack-maxima directory is only one file that looks as follows:

-bash-4.1$ ls -a . .. maxima-init.mac

-bash-4.1$ cat maxima-init.mac file_search_maxima:append([sconcat("/home/aton6/mkurula/stack-maxima/###.{mac,mc}")],file_search_maxima)$ file_search_lisp:append([sconcat("/home/aton6/mkurula/stack-maxima/###.{lisp}")],file_search_lisp)$ load("/data/moodledata/stack/maximalocal.mac"); -bash-4.1$

Maybe this loads something twice, but it seems to work fine anyway. maximalocal.mac has todays time stamp, from when I tried to run the healthcheck script, probably:

-bash-4.1$ ll /data/moodledata/stack/maximalocal.mac -rwxrwxrwx 1 apache apache 4071 8 feb 11.44 /data/moodledata/stack/maximalocal.mac

It loads the STACK libraries at the end:

/ Load the main libraries. / load("stackmaxima.mac")$ load("stats")$ load("distrib")$ load("descriptive")$ print(sconcat("[ STACK-Maxima started, library version ", stackmaximaversion, " ]"))$

Greetings, Mikael

alcarola commented 6 years ago

Hi! My problem was that I didn't uninstall the old sbcl. For my user, /usr/local/bin/sbcl was the preferred one, but the apache user preferred the old /usr/bin/sbcl. Hence, when STACK started Maxima, it went into some Lisp debug system, because it loaded a Lisp different from that which it was compiled with. So now I have the latest and greatest Maxima, SBCL Lisp, and STACK 4.1 running.

Unfortunately, I still have the same problem with NumSigFigs, please see the violet part in the attached PDF. When I run the same code in my STACK-maxima sandbox or in the STACK CAS chat, I get a different verdict: (%i4) ATNumSigFigs(5, 5.0, 3);
(%o4) [true,true,"",""]

The answer test tests under the STACK settings page agrees with the more strict behaviour of the NumSigFigs in the question tests, so I guess this is the correct behaviour. Then the main problem is that trailing zeros are dropped, even if I use the Numerical or Units input types. I read all the relevant documentation I could find without finding a solution.

I attach the problematic question too. I really have a big problem getting instances deployed of this question. I've tried more than five times to deploy 20 instances, and only managed to get three instances deployed. I'm sorry that the question is far from a minimal case, but it should be easy to spot the problem.

NumSigFigs problem Trailing Zeros.pdf

quiz-SannolStat 2018-Buggy-20180209-0017.xml.zip

alcarola commented 5 years ago

I can no longer reproduce this issue myself, so I close it.