Is there any function or other way to set an array or list of values in a calculated question?

Is there any function or other way to set an array or list of values in a calculated question?

by Otski Idi -
Number of replies: 4

Hello moodle folks,

Since 2 days I am having a really hard time doing some formulas containing several wildcards and an array/list of numbers in a calculated question. For example, I want to calculate the file size of an image in megabytes from given specifications - {h} for height, {w} for width, "b" for bit depth. I can set a range of integer numbers for {h} and {w} and add them as wildcard sets but I also want to let moodle to choose the value of "b" from a predefined array or list. To be more precise, the bit depth value should be a any number of these - 1, 8, 16, 24, 32, 48. If there is such a function for this, I suppose it should be working like min/max or something like that array_rand(1,8,16,24,32,48).  Is it possible to do something like that and how exactly? 

The calculated question until now is working perfectly with the following formula - ({h}*{w}*{b})/(8*1024*1024), with the exception of the the "b" value which is always a random number from a set range just like {h} and {w} and not any of those six bit values.

I would really appreciate if you can help me to solve this problem!

Average of ratings: -
In reply to Otski Idi

Re: Is there any function or other way to set an array or list of values in a calculated question?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In reply to Tim Hunt

Re: Is there any function or other way to set an array or list of values in a calculated question?

by Otski Idi -

Thank you very much, I will check these out!

In reply to Otski Idi

Re: Is there any function or other way to set an array or list of values in a calculated question?

by Otski Idi -

UPDATE: After a lot of testing of different plugins I have found that the "Formulas question type" plugin is what I've been serching for, doing all I need and the way I need!

Regardsing those suggested by Tim Hunt - varnumericset lacks a lot of options I need and STACK is just too overwhelming. But thanks anyway! smile

In reply to Otski Idi

Re: Is there any function or other way to set an array or list of values in a calculated question?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I love the built-in "calculated multiple choice" question type.  It takes a little to set it up.  But then you don't have to worry about students keying in incorrect characters.  When I use it, I make some of the wrong answers be calculated, too.