numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
205 stars 120 forks source link

Rounding and inputting numeric values (dev branch) #9

Closed BillFoster closed 13 years ago

BillFoster commented 13 years ago

Every time I input a value into a numeric box it rounds to 3 decimal places!

christianp commented 13 years ago

I can't reproduce this. Which exam, which browser? What exactly did you type?

BillFoster commented 13 years ago

Question in test2.exam which I wrote on Howth. This is the question - not sure how to push this up to the dev branch.

name: Hullo2 variables: { a: "if(n=2,random(4,9,16,25,36),if(n=3,random(8,27,64),if(n=4,random(16,81),random(32,243))))"

            h: "precround(random(1,-1)*random(0.001..0.1#0.001),3)"
            n: "random(2..5)"
            est: "precround(a^(m/n)+h*m*a^(m/n-1)/n,5)"
            tr: "precround((a+h)^(m/n),5)"
            m: "if(n=2 or n=4,random(1,3,5), if(n=3,random(1,2,4,5),random(1,2,3,4,6)))"
            s1: "random(1,-1)"  
            c: "precround(a^(1/n),0)"
            p: "m-n"
            }   
        statement: "Use the approximation $f(a+h) \approx f(a)+hf\;'(a)$ to estimate \[\var{a+h}^{\frac{\var{m}}{\var{n}}} \]for a suitable function $f(x)$. 
        "
        parts: [
            {
                type: GapFill
                prompt: """In this case $f(x) =\;$ [[0]]        (input your answer to 5 decimal places).

                $a= \;$[[1]] and $h=\; $[[2]]
                Input your estimation to $5$ decimal places: [[3]]

                True value is: [[4]] (input to 5 decimal places)."""
                gaps: [ 
                    {type: jme, answer: "x^({m}/{n})", marks: 0.5}
                    {type: numberentry, answer: "{a}", marks: 0.25}
                    {type: numberentry, answer: "{h}", marks: 0.25}
                    {type: numberentry, answer: "{est}", marks: 2}
                    {type: numberentry, answer: "{tr}", marks: 1}
                ]
            }   
        ]
        advice: 
                """ We have $f(x)=x^\frac{\var{m}}{\var{n}}$ and $a= \var{a}$, $h=\var{h}$.
                Note that $\var{a}^\frac{1}{\var{n}}=\var{c}$ and so using the approximation :
                $f(a+h)\approx f(a)+h\;f\;'(a)$ and $f\;'(x) = \frac{\var{m}}{\var{n}}\simplify[[1111110111111110]{x^({m-n}/{n})}$ 
                we have:
                \[\simplify[1111110111111110]{{a+h}^({m}/{n})}\approx \simplify[simplifyFractions]{{a}^({m}/{n})+{h}*({m}/{n})*{a}^({p}/{n})}=\simplify[1111110111110110]{{c}^{m}+ {h}*({m}/{n})*{c}^{m-n}}=\var{est}\]
                to 5 decimal places.
                The true value to 5 decimal places is {tr}.
                """
    }
BillFoster commented 13 years ago

Pressed the wrong button again! Used Google Chrome.

christianp commented 13 years ago

No, still can't get it to happen.

BillFoster commented 13 years ago

I took the exam test2.exam I created on Howth, copied it into the Numbas exams directory and then compiled it (on the dev branch). Not quite sure how to attach anything to these comment boxes so will send screenshots by email,

christianp commented 13 years ago

Yes. What I'm saying is I can't get that behaviour even on that exam. What version of Chrome are you using? Click on the spanner at the top right and then 'About Google Chrome'.

christianp commented 13 years ago

Can @anthonyyoud repeat this?

BillFoster commented 13 years ago

This is an error to do with display only as asking for rounding to say 5 places in an answer the marking follows this properly - but the display of the input is always to 3 places.

christianp commented 13 years ago

I appreciate that. It doesn't happen on my PC or on howth.

anthonyyoud commented 13 years ago

That exam doesn't work for me at all with the latest dev checkout. It compiles fine and shows the exam front page, but on clicking start I get

(0)@file:///home/ayoud/iassess/numbas/output/test/scripts/exam.js:407
()@file:///home/ayoud/iassess/numbas/output/test/scripts/exam.js:256
()@file:///home/ayoud/iassess/numbas/output/test/scripts/schedule.js:42
(1)@file:///home/ayoud/iassess/numbas/output/test/scripts/schedule.js:63

in Firefox 4.0.1, and

TypeError: Cannot set property ’visited’ of undefined
at Object.changeQuestion (file:///home/ayoud/iassess/numbas/output/test/scripts/exam.js:407:32)
at Object.begin (file:///home/ayoud/iassess/numbas/output/test/scripts/exam.js:256:8)
at file:///home/ayoud/iassess/numbas/output/test/scripts/schedule.js:42:7
at file:///home/ayoud/iassess/numbas/output/test/scripts/schedule.js:63:4

in Google Chrome 11.0.696.68.

The example.exam and mathssample.exam still work fine.

Can you both still compile and run the exam above with the latest dev snapshot?

anthonyyoud commented 13 years ago

The above error messages also appear in Firefox 3.6.17. IE 8 gives

TypeError: ’this.currentQuestion’ is null or not an object
christianp commented 13 years ago

Are you using this exam - http://inishmore.ncl.ac.uk/test2.exam ? Can you also email me the file you're using? I should throw a better error message than the one you're getting.

anthonyyoud commented 13 years ago

OK, I can actually reproduce this using the exam from inishmore, with the latest dev branch. It only seems to happen in Chrome. Enter any floating-point number with greater than 3 decimal places in the m= box, then change focus from the box elsewhere, e.g. tab to next input, or click somewhere else on the page. The input will be rounded to 3d.p.

Also, is it intentional that on Chrome, a thousand separator is added to numbers > 1000?

christianp commented 13 years ago

Problem seemed to be with chrome-stable acting differently to chrome-beta.