計算題

来自MoodleDocs
stephen Liu讨论 | 贡献2009年3月6日 (五) 06:51的版本
跳转至:导航、​搜索


計算題提供了一種建立個別數字題的方法,題目裏使用通配符(例如 {x} , {y})答題時通配符會被亂數替換。

舉一個例,如果你想要建立很多"矩形面積的計算"問題給你的學生練習,你可以建立有兩個通配符的試題(例如{base}, {height})然後放在"正確答案公式="的輸入欄位{base} * {height} ( * 是乘法的符號)。

正確答案公式= {base}*{height}


當學生作答時,Moodle會隨機選取{base}{height}的值然後使用 正確答案公式來評分。

這個測驗很難同時出現兩次一樣的題目。

這真的是你要的題型嗎?

計算題的主要目的是建立有很多數值的試題版本,這個意思是你必須在答案中有一個以上的通配符。

假如你不需要亂數值,使用數字題型來取代。

通配符及資料集

當Moodle傳送一個計算題給學生,通配符會被隨機選擇的值所取代,然而這些值不總是隨機的- 他們是從已經預先定義好可能數值的資料集中隨機選出的,這樣可以允許你控制一些所選擇的可能值 - 舉個例來說,這是為了確定這些數字是實際的。

這些資料集可以是私用的共享的 - 私用的資料集在一個計算題被一個通配符所使用;共享的資料集是所有的計算題都可以共用這個通配符。

試題設定

要新增(或編輯)計算題有三頁要處理,下面的操作會帶你一步一步地操作這些頁面:

第一頁.編輯計算題

  1. 選取試題類別
  2. 這個類別中共享的通配符會列在下面。假如你改變類別,你需要點擊"更新題庫"按鈕來更新這個列表,有可能沒有共享的通配符 - 假如沒有你可以稍後依照你自己的意願來新增。
  3. 給定試題描述的名稱 - 這個可以允許你在題庫中辦認。
  4. 輸入試題內容,這應該是你想要學生回答的試題,而且必須包含所有要計算答案的資訊,因此他必須含有至少一個通配符在大括弧內,例如,假如你想要學生計算A加B,這個試題內容很可能是這樣:"{A} + {B}=多少?"
  5. 假如你鄉要新增一個試題的圖片就選擇一個圖片來顯示,對學生來說,圖片會顯示在試題內容後答案前,假如你想要控制圖片如何顯示,就把他放在試題內容中用HTML編輯器處理。
  6. 設定預設題目得分 (例如,這個試題的最高分)。
  7. 設定倒扣條件 (見下面的倒扣條件)。
  8. Moodle 1.7+: 假如你願意,新增一般的回饋,這是顯示給學生回答後所要顯示的文字。
  9. 接下來新增正確答案公式這個公式必須含有試題內容中一個以上的通配符,見正確答案公式語法有更進一步的資料。
  10. 選擇成績這個成績是學生針對該試題所給的答案得到的,這應該是題目得分的一個百分比,例如,你可以給正確答案100%,而接近正確答案則給50%,答案中有一個必須是100%分
  11. 決定你可以接受答案錯誤的容許誤差,這個容許誤差及誤差類型設定 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. Geometric - mark correct if dx² / x² <= t²
  12. 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.
  13. Add some feedback which the student will see if they enter this answer.
  14. You can specify as many answer formulae as you like - click "Add another answer blank" to add more.
  15. 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.
  16. 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

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:

  1. In the 'Param' field for each wildcard, enter the value you want
  2. Scroll down to the 'Add' section and click the Add button (leaving the number of items set to 1)
  3. Repeat the above steps as many times as necessary (the maximum number of items is 100)

To delete values from the list:

  1. In the 'Delete' section, select the number of items to delete
  2. Click the Delete button

Letting Moodle create values

  1. Start with the "Range of Values" fields, and enter the lower and upper limits for the values you would accept
  2. Choose a number of decimal places for the value
  3. 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.
  4. Now move down to the 'Add' section and click on "force regeneration"
  5. 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.)
  6. Finally, click Add to append the new values to the list
  7. 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

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 two times cosine of another, 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

Calculated questions can use more than simple arithmetic operators. The following functions are allowed in versions 1.5 and newer.

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

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