# Talk:Calculated question type

Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Calculated question type.

I'm trying to create just a SAMPLE calculated question to evaluate moodle quiz export XML, and am finding it about impossible to figure out. I've done some programming, and have figured some of it, but this is a very unfriendly format explanation. It would be lovely if there could be some explanation as to what a wild card is, and how to create data sets. I can put in a bit about the first thing, but the datasets still have me stumped. D.I. von Briesen 18:16, 23 June 2007 (CDT)

Please explain what a "placeholder" is - there is no other mention anywhere in Moodle (according to search!)

How does it match "item" in the question creation?

## Calculate Question: Random Numbers

Calculated Questions in Moodle allow for the creation of a question with "wildcards". The wildcards are used to create a database of numerical values...randomly generated...but static thereafter. So, if only two entries of random numbers are made into the database...(eg. x = 3 and x = 5...randomly generated of course), then the question only uses 3 and 5 for the wildcard. For additional values of the wildcard, additional entries must be randomly generated and placed into the static database.

Why not eliminate the static database, and just have Moodle generate truly random, non-static wildcards into the actual question? I've seen other course management programs that do this, such as LON-CAPA from Michigan State University.

For example...

Q: Find the sum of {x} and {y}. To generate the wildcards, Moodle would randomly choose an "x" and "y" (eg. where {x|0<x<10, step .1} and {y|5<y<10, step 1}), and insert the values directly into the question/answer. The values of "x" and "y" would be randomly chosen each time, greatly improving the variation of question/answer possibilities. This would be an improvement over the current limited static database method.

A static database of randomly-generated numbers is NOT a random number generator. The same two "random" wildcard values get used over and over...and the variation of each question is determined by the number of static entries in the database.

Perhaps Moodle can already perform this action, and I simply haven't found the correct function or procedure. Any suggestions for accomplishing random numbers in calculated quizzes are welcome and appreciated.

There can sometimes be value in having a fixed pool of values to randomly choose from. (One usually has Moodle generate the pool randomly anyway.) For instance, I've written a question to test students' understanding of significant figures that counts off if the student's answer is too precise. But occasionally the numbers happen to work out so that the correctly rounded answer still falls within the "too precise" limits (namely, when the next digit or two are zeroes). So I like the ability to manually remove those possibilities from my question pool.--Steuard Jensen 03:47, 17 August 2011 (WST)

____

SUGGESTED CORRECTION TO: (Chuck Friesen: chuckfriesen@gmail.com): Each function's placeholders and other arguments should be in parentheses (brackets). For example, if you want students to calculate the sine of one angle and two times cosine of another, you would enter sin({a}) + cos({b}*2).

CORRECTION: "... For example, if you want students to calculate the sum of the sine of one angle and the cosine of twice another angle, you would enter sin({a}) + cos({b}*2). "

_____

## Datasets

I would like to see datasets in a bigger perspective. For example:

- same dataset over more then one quiz

- set a dataset for a group for the hole course

With the current version of Moodle I often create a quiz and questions for every group (same questions but different numeric result). Not a very nice solution, but the only one I could find.

Is anybody thinking the same?

## Wildcards within the question text

I'm surprised that the documentation doesn't mention that one can use wildcards within the question text: that's a remarkably useful feature that deserves to be highlighted! For example, the syntax "What is {={A}*{B}} divided by {A}?" with wildcard values A=4 and B=3 shows up as "What is 12 divided by 4?" I'd really like to know if there are any more features associated with this: is there any way to force Moodle to print the "+" before a positive number, or to specific the number of significant figures to show in a value computed this way? (Does there exist something like an "if" statement?) --Steuard Jensen 23:46, 12 August 2011 (WST)

I want to thank Steuard Jensen for posting this above. This is a powerful tool that doesn't seem to be documented elsewhere. Is it possible to create a wildcard based on the value of another wildcard? For example, {y}=5*{x} and then use {y} elsewhere in a quiz?--James Roberts 02:15, 25 February 2013 (WST)James Roberts