JSXGraph – can someone explain to me how this question works?

32 views
Skip to first unread message

Thomas Cottrell

unread,
Dec 7, 2021, 7:24:32 AM12/7/21
to Numbas Users
I am pretty new to using JSXGraph, and I'm trying to get my head around how this question – which uses JSXGraph to draw a right-angled triangle based on question variables – works:

The code used to draw the triangle is
{if(switcharoo=0,triangle(),otherway())}

I don't understand how this is doing anything, since there aren't variables called 'triangle()' or 'otherway()' defined in the question. (Although I do understand that switcharoo is a variable deciding which way round the triangle should appear.)

Can anyone shed any light on this?

Timur Zaripov

unread,
Dec 7, 2021, 7:27:41 AM12/7/21
to numbas...@googlegroups.com
Dear Thomas,

You can find otherway() and triangle() functions defined in “Extensions and scripts -> Functions”. 

To help you easier find these, note, that the links are either blue or green. Blue means that everything is in default state, green means there is something custom in that area.

With best regards,
Timur Zaripov.

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/a678b4f6-887a-4fde-9e11-1dce0383af0bn%40googlegroups.com.

Christian Lawson-Perfect

unread,
Dec 7, 2021, 7:28:54 AM12/7/21
to numbas...@googlegroups.com
`triangle` and `otherway` are functions, defined in the "Extensions and scripts" tab.

I wouldn't build on that question, though - the new ways of making JSXGraph diagrams with JessieScript or JME are much simpler. I'll see if I can make a copy of the question using those.

--

Christian Lawson-Perfect

unread,
Dec 7, 2021, 9:09:41 AM12/7/21
to numbas...@googlegroups.com
I've made two copies of this question:

I think the code for the Eukleides version is easier to read, and it produces a diagram with annotations for assistive tech such as screen readers.

Timur Zaripov

unread,
Dec 7, 2021, 10:49:46 AM12/7/21
to numbas...@googlegroups.com
Dear Christian,

Playing with the two implementations, I have notices the the font sizes on the figure are inconsistent for different parameters in the Eukledes implementation. It can be reproduced by clicking “Try another question like this one” multiple times.

With best regards,
Timur Zaripov.

Christian Lawson-Perfect

unread,
Dec 7, 2021, 10:50:54 AM12/7/21
to numbas...@googlegroups.com
Yep, I didn't set the bounding box of the diagram explicitly, so it auto-scales. Maybe it shouldn't!

Message has been deleted

Thomas Cottrell

unread,
Dec 14, 2021, 10:11:30 AM12/14/21
to Numbas Users

Thanks Timur and Christian, that's all very helpful!

I had no idea bout the blue/green colour-coding for links.

Also, yes, the Eukleides diagram sometimes has very tiny text!

Thomas Cottrell

unread,
Dec 14, 2021, 10:51:33 AM12/14/21
to Numbas Users
How would I set the bounding box/stop it from auto-scaling? I can't find much about it in the documentation.

On Tuesday, 7 December 2021 at 15:50:54 UTC christia...@gmail.com wrote:

Christian Lawson-Perfect

unread,
Jan 12, 2022, 10:26:26 AM1/12/22
to numbas...@googlegroups.com
Sorry, that was missing! I've updated the documentation: in the `eukleides` function, you give four numbers after the description parameter, giving the positions of the left, bottom, right and top of the bounding box.
I've added an example to the end of the "how to construct a diagram" section of the docs: https://numbas.github.io/numbas-extension-eukleides/docs/#how-to-construct-a-diagram

Reply all
Reply to author
Forward
0 new messages