Selecting variables from list of possible numbers

12 views
Skip to first unread message

Bob Morris

unread,
Jul 5, 2021, 10:11:22 AM7/5/21
to Numbas Users
I am fairly new to Numbas but am very familiar with Canvas Quizzes and wondered if there was a way to choose randomly from a list of "sensible" variables when producing a question.

For example I would like to ask the question:- How many mls of medicine would be needed for "x" days treatment at a dose of "y" mg,  "t" daily? I would need the variables to be something like x= 5, 7, 10, 14, 21 or 28 and y = some specific numbers relating to a particular strength of medicine plus t = once, twice, three times or four times.

I have tried finding the answer in the documentation but had no luck and I am not great at coding.

Bob

Timur Zaripov

unread,
Jul 6, 2021, 3:20:45 AM7/6/21
to Numbas Users
Dear Bob,

Yes, you can do that using JME expression when defining a variable.
Consider picking random element from predefined list:

random([1,2,4])

Example taken from:

Timur.

Bob Morris

unread,
Jul 6, 2021, 4:18:19 AM7/6/21
to numbas...@googlegroups.com
Thanks Timur. I suspected I would have to use JME. I have no experience of this coding but will explore and try it out. 

Sent from my iPhone. Bob Morris


On Jul 6, 2021, at 08:20, Timur Zaripov <zar...@gmail.com> wrote:


--
You received this message because you are subscribed to a topic in the Google Groups "Numbas Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/numbas-users/ynwn-ZRF8x4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/07a5d927-0a49-4c43-aad4-454546d18ab8n%40googlegroups.com.

Timur Zaripov

unread,
Jul 6, 2021, 5:20:12 AM7/6/21
to Numbas Users
Dear Bob,

There isn't much to it in this case. I have attached screenshot implementing what you want, you just need to change values in square brackets. Hopefully I understood your issue correctly.

With best regards,
Timur.
Screenshot from 2021-07-06 10-16-57.png
Reply all
Reply to author
Forward
0 new messages