Note: You are currently viewing documentation for Moodle 2.5. Up-to-date documentation for the latest stable version of Moodle may be available here: Simple calculated question type.

Simple calculated question type: Difference between revisions

From MoodleDocs
 
(25 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Questions}}
{{Questions}}
 
Simple calculated questions offer a way to create individual numerical questions whose response is the result of a numerical formula which contain variable numerical values  by the use of wildcards  (i.e '''{x}''' , '''{y}''') that are substituted with random values when the quiz is taken.
This page is in development as this is a new question type
that is only available in Moodle Head [[User:Pierre Pichet|Pierre Pichet]] 18:46, 3 June 2009 (UTC)
 
Calculated questions offer a way to create individual numerical questions whose response is the result of a numerical formula which contain variable numerical values  by the use of wildcards  (i.e '''{x}''' , '''{y}''') that are substituted with random values when the quiz is taken.


The simple calculated questions offers the most used features of the calculated question with a much simpler creation interface.
The simple calculated questions offers the most used features of the calculated question with a much simpler creation interface.


== My first Simple calculated question ==
== My first Simple calculated question ==
As a first example you will create a question asking for the surface of a rectangle.
As a first example you will create a question asking for the surface of a rectangle. Here are the quick steps we will go over in detail:
*Create the question content with variables shown in {}
*Enter the formula using the variables and set the tolerance
*Determine the range of the generated set of variables that will appear in the question content
*Review the generated set of question contents
*Since it is your first, check your work from a student's view


===Initiating the creation process===
===Initiating the creation process===


Go to the question bank, select "create a new question" and in the pop-up window select the Simple calculated.
Go to the [[Question bank]], select "create a new question" and in the pop-up window select the Simple calculated.
The Simple calculated question interface will appear.
The Simple calculated question interface will appear.
Give a name to your question .
Give a name to your question in the title.
 
===The question text===
===The question text===
Fill the question text (note that the {{param}} names can be choose at will.
Fill the question text (note that the '''{param}''' names can be chosen at will.
[[Image:Simple_calculated_first_question_text.jpg]]
[[Image:Simple_calculated_first_question_text.jpg]]


===The Correct Answer Formula===
===The Correct Answer Formula===
Fill the Correct Answer Formula using the {{{param}}} names unsed in the question text.
Fill the Correct Answer Formula using the '''{param}''' names used in the question text.
[[Image:Simple_calculated_first_question_formula.jpg]]
[[Image:Simple_calculated_first_question_formula.jpg]]


===Other answer and response parameters===
===Other answer and response parameters===
You must set the Grade to 100% as this is the only answer in this question.
You will set the Grade to 100%, as this is the only answer in this question.
Leave the other parameters as they appears ( 0.01 relative means ±1% tolerance)
 
Leave the other parameters as they appears ( 0.01 relative means ±1% tolerance).
 
===Find the '''{param}''' in the formula===
In simple calculated only the '''{param}''' that are in the formula will be used.
 
In the question text , the '''{param}''' that are in the formula
will appear with there numerical values i.e 6.7 .
 
Any other {enclosed text} will appear as is i.e. {enclosed text}.


===Find the {{{param}}} in the formula===
In simple calculated only the {{{param}}} that are in the formula will be used.
Any other {enclosed text} in the question will appear as {enclosed text}.
[[Image:Simple_calculated_first_question_find_wild_card.jpg]]
[[Image:Simple_calculated_first_question_find_wild_card.jpg]]


Line 59: Line 68:
The two sets illustrate that the variability defined by the Min and Max values.
The two sets illustrate that the variability defined by the Min and Max values.


Note that the formula resutl is analyzed and  
Note that the formula result is analyzed and  


the tolerance limit (here 1% relative) is shown
the tolerance limit (here 1% relative) is shown
Line 69: Line 78:
===Click on the Save button===
===Click on the Save button===


==Test your first Sinple calculated question==
===Test your first Sinple calculated question===
On the question bank click on the preview icon.
On the question bank click on the preview icon.


Line 82: Line 91:
[[Image:Previewsimple_calculated_rectangle_example_graded.jpg]]
[[Image:Previewsimple_calculated_rectangle_example_graded.jpg]]


==Editing a Simple Calculated question: Additional comments==


==Wildcards and datasets==
When Moodle delivers a Calculated question to the student, the wildcards are replaced with randomly-selected values. However, these values are not completely random - rather, they are randomly selected from a pre-defined ''dataset'' of possible values. This allows you some control over the possible values chosen - for example, in order to make sure the numbers are realistic.
These datasets can be ''private'' or ''shared'' - private datasets are used by one wildcard within one calculated question; shared datasets are used by one wildcard within all calculated questions that use it.
==Question set-up==
To create (or modify) a calculated question there are three pages to work through. The instructions below take you through the pages, step by step:
===Page 1. Editing a Calculated question ===
#Select the question '''category'''
#Any shared wildcards for this category are listed beneath. If you change category, you'll need to click the "Update the category" button to refresh this list. There may not be any shared wildcards yet - if not, you can create them later if you wish.
#Give the question a descriptive '''name''' - this allows you to identify it in the question bank.
#Enter the '''question text'''. This should be the question you want the student to answer, and it must include all the information they need to calculate an answer. Therefore it must contain at least one wildcard, inside curly braces. For example, if you wanted the student to sum numbers A and B, the question text might read: "What is {A} + {B}?"
#Select an image to display if you want to add a picture to the question. For the student, it appears immediately after the question text and before the choices. If you want more control over how the image appears, include it in the question text above, using the HTML editor.
#Set the '''default question grade''' (i.e. the maximum number of marks for this question).
#Set the '''default question grade''' (i.e. the maximum number of marks for this question).
#Set the '''Penalty factor''' (see [[Calculated_question_type#Penalty_factor|Penalty factor]] below).
#Set the '''Penalty factor''' (see [[Calculated_question_type#Penalty_factor|Penalty factor]] below).
#''Moodle 1.7+:'' If you wish, add general feedback. This is text that appears to the student after he/she has answered the question.
[[Calculated_question_type#Correct_answer_formula|Correct answer formula syntax]] for further details.
#Next add the '''formula for the answer'''. This formula must contain at least the wildcards that appear in the question text. See [[Calculated_question_type#Correct_answer_formula|Correct answer formula syntax]] for further details.
# Choose the '''grade''' that the student will get for this question if they give this answer. This should be a percentage of the total marks available. For example, you could give 100% for a correct answer, and 50% for an answer that is nearly right. '''One of the answers must have a 100% grade'''.
# Choose the '''grade''' that the student will get for this question if they give this answer. This should be a percentage of the total marks available. For example, you could give 100% for a correct answer, and 50% for an answer that is nearly right. '''One of the answers must have a 100% grade'''.
#Determine the '''tolerance''' for error that you will accept in the answer. The tolerance and tolerance type settings combine to give a range of acceptable scores. So, if tolerance = t, correct answer = x and the difference between the user's answer and the correct answer is dx, then the tolerance types are as follows:
#Determine the '''tolerance''' for error that you will accept in the answer. The tolerance and tolerance type settings combine to give a range of acceptable scores. So, if tolerance = t, correct answer = x and the difference between the user's answer and the correct answer is dx, then the tolerance types are as follows:
##Nominal - mark correct if dx <= t
##Nominal - mark correct if dx <= t
##Relative - mark correct if dx / x <= t
##Relative - mark correct if dx / x <= t
##Geometric - mark correct if dx² / x² <= t²
# The next 2 settings, "Correct answer shows" and "Format" determine the '''precision''' of the Correct answer shown. They are not used for grading.
# The next 2 settings, "Correct answer shows" and "Format" determine the '''precision''' of the answer. Use these to select the number of decimal places or significant figures you want to use.
# Add some '''feedback''' which the student will see if they enter this answer.
# Add some '''feedback''' which the student will see if they enter this answer.
# You can specify as many answer formulae as you like - click "Add another answer blank" to add more.
# You can specify as many answer formulae as you like - click "Add another answer blank" to add more.
# You can also specify units for the answers. For example, if you enter a unit of 'cm' here, and the accepted answer is 15, then the answers '15cm' and '15' are both accepted as correct. If you add more than one unit, you can also specify a multiplier. So, if your main answer was 5500 with unit W, you can also add the unit kW with a multiplier of 0.001. This means that the answers '5500', '5500W' or '5.5kW' would all be marked correct. Note that the accepted error is also multiplied, so an allowed error of 100W would become an error of 0.1kW.
# You can also specify units for the answers. For example, if you enter a unit of 'cm' here, and the accepted answer is 15, then the answers '15cm' and '15' are both accepted as correct. If you add more than one unit, you can also specify a multiplier. So, if your main answer was 5500 with unit W, you can also add the unit kW with a multiplier of 0.001. This means that the answers '5500', '5500W' or '5.5kW' would all be marked correct. Note that the accepted error is also multiplied, so an allowed error of 100W would become an error of 0.1kW.
# Finally (!) you can click "Next page" to save what you've done and move on. If you are editing an existing question, you can click "Next page (new question)" to create a completely new question based on an existing one.


==== Penalty factor ====
==== Penalty factor ====


The 'penalty factor' only applies when the question is used in a quiz using adaptive mode - i.e. where the student is allowed multiple attempts at a question even within the same attempt at the quiz. If the penalty factor is more than 0, then the student will lose that proportion of the '''maximum''' grade upon each successive attempt. For example, if the default question grade is 10, and the penalty factor is 0.2, then each successive attempt after the first one will incur a penalty of 0.2 x 10 = 2 points.
The 'penalty factor' only applies when the question is used in a quiz using adaptive mode - i.e. where the student is allowed multiple attempts at a question even within the same attempt at the quiz. If the penalty factor is more than 0, then the student will lose that proportion of the '''maximum''' grade upon each successive attempt. For example, if the default question grade is 10, and the penalty factor is 0.2, then each successive attempt after the first one will incur a penalty of 0.2 x 10 = 2 points.
===Page 2. Choose dataset properties ===
Each wildcard that you specify in the answer formula must have an associated set of possible values - this is its ''dataset''. Each of the wildcards is listed on this page along with a choice of dataset:
*'''private''' i.e. only used by this question
*'''shared''' i.e shared with other calculated questions in the same category
Using a shared dataset can save time when you are creating a lot of similar calculated questions.
If there is anything in the question text that looks like a wildcard, but does not appear in any of the answer formulae, you can specify whether or not this is meant to be a wildcard. If it is, you can choose whether it should use a private or shared dataset.
To continue, simply choose your preferred dataset for each wildcard, then click "Next Page".
===Page 3. Edit the datasets ===
Now we need to create the set of possible values that each wildcard can take. ''Warning'' - this page is a bit confusing!
There are two ways of creating values - you can type them in yourself and add them to the list, or you can have Moodle generate them for you.
==== Adding/deleting your own values ====
Adding individual values to the list is easy:
# In the 'Param' field for each wildcard, enter the value you want
# Scroll down to the 'Add' section and click the Add button (leaving the number of items set to 1)
# Repeat the above steps as many times as necessary (the maximum number of items is 100)
To delete values from the list:
# In the 'Delete' section, select the number of items to delete
# Click the Delete button
==== Letting Moodle create values ====
# Start with the "Range of Values" fields, and enter the lower and upper limits for the values you would accept
# Choose a number of decimal places for the value
# Choose the distribution of values between the limits - 'uniform' means any value between the limits is equally likely to be generated; 'loguniform' means that values towards the lower limit are more likely.
# Now move down to the 'Add' section and click on "force regeneration"
# In the menu next to the Add button, choose the number of sets of random values (items) you wish to add to the list. (Note that the maximum total number of items in your list is 100.)
# Finally, click Add to append the new values to the list
# '''Note:''' If you want more control over the items that Moodle adds, you can do them one at a time and preview the values before you add them. Click the "Get New Item to Add" button to make Moodle generate new values in the "Item to Add" section at the top. If you like them, click "Add" for 1 item; if not, click "Get New Item to Add" again to get new values.
==== Finishing off ====
Once your list of items (values) is complete, you are finished. It's up to you how many values you add - the more values you add, the more a question can be used by the students without them seeing the same values repeatedly.
Note that if you delete values from the list, you can put them back again. Change the "Next Item to Add" option to "reuse previous value if available", then the next time you add items, Moodle will restore your previously-deleted items from the dataset.
Once your list of values is complete, you can click 'Save changes' to finish.
==== What does the 'Update the datasets parameters' button do? ====
As far as I can tell, it has the same function as the "Get New Item to Add" button, i.e. it generates a new set of values and displays them in the "Item to Add" section. However, it is less conveniently placed that that button, so it is probably best ignored.


==Correct answer formula syntax ==
==Correct answer formula syntax ==
Line 182: Line 119:


* As a general rule, write these formulas like you would in a calculator e.g. <code>3 + 5 * sin(3/{x})</code> A notable exception is exponentiation, where x<sup>3</sup> cannot be entered as <code>{x}^3</code>, but instead should be entered as <code>pow(x, 3)</code>.
* As a general rule, write these formulas like you would in a calculator e.g. <code>3 + 5 * sin(3/{x})</code> A notable exception is exponentiation, where x<sup>3</sup> cannot be entered as <code>{x}^3</code>, but instead should be entered as <code>pow(x, 3)</code>.
* 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 <code>sin({a}) + cos({b}*2)</code>.
* 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 cosine of two times of another angle, you would enter <code>sin({a}) + cos({b}*2)</code>.
* It's usually better to have too many parentheses (brackets) than too few.  The server won't care, and the more specific you are about what you mean, the more likely it will like your complex formulas.
* It's usually better to have too many parentheses (brackets) than too few.  The server won't care, and the more specific you are about what you mean, the more likely it will like your complex formulas.
* There is no implicit multiplication.  To you, the human editor, "5(23)" or "5x" may seem perfectly obvious.  To the server doing the math, it's crazy talk and won't be understood.  Always use the "*" for multiplication.
* There is no implicit multiplication.  To you, the human editor, "5(23)" or "5x" may seem perfectly obvious.  To the server doing the math, it's crazy talk and won't be understood.  Always use the "*" for multiplication.
Line 189: Line 126:
==Available functions==
==Available functions==


Calculated questions can use more than simple arithmetic operators. The following functions are allowed in versions 1.5 and newer.
The [[Calculated_question_type#Available_functions|available functions]] are the same as for the calculated question type.
 
{| width="97%" border="1px"
!Function
!Explanation
|-
|abs
|Absolute value
|-
|acos
|Arc cosine -- in radians!!!  Convert your degree measurement to radians before you take the acos of it.
|-
|acosh
|Inverse hyperbolic cosine -- in radians!!!  Convert your degree measurement to radians before you take the acosh of it.
|-
|asin
|Arc sine -- in radians!!!  Convert your degree measurement to radians before you take the asin of it.
|-
|asinh
|Inverse hyperbolic sine -- in radians!!!  Convert your degree measurement to radians before you take the asing of it.
|-
|atan2
|Arc tangent of two variables -- pass in two values like (x, y), and you'll get the atah(y/x), adjusted to the proper quadrant.
|-
|atan
|Arc tangent -- in radians!!!  Convert your degree measurement to radians before you take the atan of it.
|-
|atanh
|Inverse hyperbolic tangent
|-
|bindec
|Binary to decimal
|-
|ceil
|Round fractions up
|-
|cos
|Cosine -- in radians!!!  Convert your degree measurement to radians before you take the cos of it.
|-
|cosh
|Hyperbolic cosine -- in radians!!!  Convert your degree measurement to radians before you take the cosh of it.
|-
|decbin
|Decimal to binary
|-
|decoct
|Decimal to octal
|-
|deg2rad
|Converts the number in degrees to the radian equivalent
|-
|exp
|Calculates the exponent of e
|-
|expm1
|Returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero
|-
|floor
|Round fractions down
|-
|fmod
|Returns the floating-point modulus of two numbers - i.e. the remainder when the first is divided by the second.
|-
|is_finite
|Finds whether a value is a legal finite number
|-
|is_infinite
|Finds whether a value is infinite
|-
|is_nan
|Finds whether a value is not a number
|-
|log10
|Base-10 logarithm
|-
|log1p
|Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero
|-
|log
|Natural logarithm (''ln'')
|-
|max
|Find highest value
|-
|min
|Find lowest value
|-
|octdec
|Octal to decimal
|-
|pi
|Get value of pi
|-
|pow (numberToRaise, NumberRaisedTo)
|Exponential expression
|-
|rad2deg
|Converts the radian number to the equivalent number in degrees
|-
|rand
|Generate a random integer
|-
|round
|Rounds a float
|-
|sin
|Sine -- in radians!!!  Convert your degree measurement to radians before you take the sin of it.
|-
|sinh
|Hyperbolic sine -- in radians!!!  Convert your degree measurement to radians before you take the sinh of it.
|-
|sqrt
|Square root
|-
|tan
|Tangent -- in radians!!!  Convert your degree measurement to radians before you take the tan of it.
|-
|tanh
|Hyperbolic tangent -- in radians!!!  Convert your degree measurement to radians before you take the tanh of it.
|}


==Predefined constants==
==Predefined constants==
Actually there is NO Predefined constant that is allowed other than pi() as a function without parameter.
Actually there is NO Predefined constant that is allowed other than pi() as a function without parameter.


[[Category:Questions]]
[[Category:Mathematics]]
[[Category:Mathematics]]


[[de:Berechnungsfragen]]
[[de:Berechnungsfragen]]
[[es:Tipo de Pregunta Calculada Simple]]
[[zh:計算題]]
[[zh:計算題]]
[[User:Pierre Pichet|Pierre Pichet]] 00:00, 5 June 2009 (UTC)

Latest revision as of 10:50, 3 October 2013


Simple calculated questions offer a way to create individual numerical questions whose response is the result of a numerical formula which contain variable numerical values by the use of wildcards (i.e {x} , {y}) that are substituted with random values when the quiz is taken.

The simple calculated questions offers the most used features of the calculated question with a much simpler creation interface.

My first Simple calculated question

As a first example you will create a question asking for the surface of a rectangle. Here are the quick steps we will go over in detail:

  • Create the question content with variables shown in {}
  • Enter the formula using the variables and set the tolerance
  • Determine the range of the generated set of variables that will appear in the question content
  • Review the generated set of question contents
  • Since it is your first, check your work from a student's view

Initiating the creation process

Go to the Question bank, select "create a new question" and in the pop-up window select the Simple calculated. The Simple calculated question interface will appear. Give a name to your question in the title.

The question text

Fill the question text (note that the {param} names can be chosen at will. Simple calculated first question text.jpg

The Correct Answer Formula

Fill the Correct Answer Formula using the {param} names used in the question text. Simple calculated first question formula.jpg

Other answer and response parameters

You will set the Grade to 100%, as this is the only answer in this question.

Leave the other parameters as they appears ( 0.01 relative means ±1% tolerance).

Find the {param} in the formula

In simple calculated only the {param} that are in the formula will be used.

In the question text , the {param} that are in the formula

will appear with there numerical values i.e 6.7 .

Any other {enclosed text} will appear as is i.e. {enclosed text}.

Simple calculated first question find wild card.jpg

Click on the button

On reload the two {b} and {h} will be displayed.

Set the minimum and maximum values

Here the {b} range has been set to a 15-20 range and

the {h} range has been set to a 5-10 range

as we want a rectangle with a larger base than height.

Simple calculated first question set min max.jpg

Select the number of sets to generate (here 10) and to display(here 2)

Just to illustrate that you can control the number of values displayed which is useful if you create 100 sets.

Also note the (red) warning that a valid question needs at least one set of {wild card} values. You will not be allowed to save the question if you don't do the next step.

Click on the generate button

Simple calculated values.jpg

Note the sets are shown in reverse order so the the number indicates how many sets were created.

The two sets illustrate that the variability defined by the Min and Max values.

Note that the formula result is analyzed and

the tolerance limit (here 1% relative) is shown

The correct response that will be shown to the student is also shown.

The 2 decimals where defined are the default values defined as the last parameter under the Correct formula.

Click on the Save button

Test your first Sinple calculated question

On the question bank click on the preview icon.

Enter the result you have calculated yourself or click on the Fill with Correct button.

The values should be identical... Preview simple calculated rectangle example.jpg


Click on the submit button

Previewsimple calculated rectangle example graded.jpg

Editing a Simple Calculated question: Additional comments

  1. Set the default question grade (i.e. the maximum number of marks for this question).
  2. Set the Penalty factor (see Penalty factor below).

Correct answer formula syntax for further details.

  1. Choose the grade that the student will get for this question if they give this answer. This should be a percentage of the total marks available. For example, you could give 100% for a correct answer, and 50% for an answer that is nearly right. One of the answers must have a 100% grade.
  2. Determine the tolerance for error that you will accept in the answer. The tolerance and tolerance type settings combine to give a range of acceptable scores. So, if tolerance = t, correct answer = x and the difference between the user's answer and the correct answer is dx, then the tolerance types are as follows:
    1. Nominal - mark correct if dx <= t
    2. Relative - mark correct if dx / x <= t
  3. The next 2 settings, "Correct answer shows" and "Format" determine the precision of the Correct answer shown. They are not used for grading.
  4. Add some feedback which the student will see if they enter this answer.
  5. You can specify as many answer formulae as you like - click "Add another answer blank" to add more.
  6. You can also specify units for the answers. For example, if you enter a unit of 'cm' here, and the accepted answer is 15, then the answers '15cm' and '15' are both accepted as correct. If you add more than one unit, you can also specify a multiplier. So, if your main answer was 5500 with unit W, you can also add the unit kW with a multiplier of 0.001. This means that the answers '5500', '5500W' or '5.5kW' would all be marked correct. Note that the accepted error is also multiplied, so an allowed error of 100W would become an error of 0.1kW.

Penalty factor

The 'penalty factor' only applies when the question is used in a quiz using adaptive mode - i.e. where the student is allowed multiple attempts at a question even within the same attempt at the quiz. If the penalty factor is more than 0, then the student will lose that proportion of the maximum grade upon each successive attempt. For example, if the default question grade is 10, and the penalty factor is 0.2, then each successive attempt after the first one will incur a penalty of 0.2 x 10 = 2 points.

Correct answer formula syntax

DO NOT PUT THE = sign in the formula.

  • In the recent versions of the calculated question type, you could have more than one answer formula and applied a specific grading value to each of them as long as there is at least one 100% correct answer formula.
If more than one correct answer formula input field are displayed when editing, 
your site has the multiple answer feature. 


  • As a general rule, write these formulas like you would in a calculator e.g. 3 + 5 * sin(3/{x}) A notable exception is exponentiation, where x3 cannot be entered as {x}^3, but instead should be entered as pow(x, 3).
  • 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 cosine of two times of another angle, you would enter sin({a}) + cos({b}*2).
  • It's usually better to have too many parentheses (brackets) than too few. The server won't care, and the more specific you are about what you mean, the more likely it will like your complex formulas.
  • There is no implicit multiplication. To you, the human editor, "5(23)" or "5x" may seem perfectly obvious. To the server doing the math, it's crazy talk and won't be understood. Always use the "*" for multiplication.
  • Any special mathematical function must have parentheses around its values. Take the sine function in the first bullet point for instance. Notice that the 3 / x is wrapped in parentheses (brackets)--this is so the server can understand it properly. Without those parentheses, the server won't know if you mean "(sin 3) / x" or "sin (3 / x)" and will reject the entire formula accordingly.

Available functions

The available functions are the same as for the calculated question type.

Predefined constants

Actually there is NO Predefined constant that is allowed other than pi() as a function without parameter.

Pierre Pichet 00:00, 5 June 2009 (UTC)