Number entry#

Number entry parts ask the student to enter a number, which is marked correct if it is in a specified range.

You can find the number entry part’s built-in marking algorithm at GitHub.

Marking#

Minimum accepted value#

The smallest value accepted as correct.

Maximum accepted value#

The largest value accepted as correct.

Display answer#

The value to use for the expected answer.

If this is left empty, then the displayed value depends on the minimum and maximum accepted values \((min,max)\):

\((min,max)\)

Displayed value

Both finite

\(\frac{1}{2}(min + max)\)

Only \(min\) is finite

\(min\)

Only \(max\) is finite

\(max\)

\((-\infty, \infty)\)

\(0\)

\((-\infty, -\infty)\)

\(-\infty\)

\((+\infty, +\infty)\)

\(\infty\)

If Display the correct answer as a fraction? is ticked, then the value will be displayed as a fraction. Otherwise, it will be displayed as a decimal using the part’s precision settings and the Correct answer style.

Precision restriction#

You can insist that the student gives their answer to a particular number of decimal places or significant figures. For example, if you want the answer to be given to 3 decimal places, \(3.1\) will fail this restriction, while \(3.100\) will pass.

The minimum and maximum answer are both rounded off to the same precision as the student used, or the required precision - whichever is greater. If the student’s answer is between the rounded-off minimum and maximum, then it is marked correct. Finally, if the student’s answer is not given to the required precision, the penalty is applied.

If the precision doesn’t matter, select None.

Allow the student to enter a fraction?#

This option is only available when no precision restriction is applied, since they apply to decimal numbers. If this is ticked, the student can enter a ratio of two whole numbers, e.g. -3/8, as their answer.

Must the fraction be reduced?#

This option only applies when “Allow the student to enter a fraction” is ticked. If this is ticked, the student must enter their fractional answer reduced to lowest terms. For example, consider a part whose correct answer is \(5/4\). If this is ticked, 10/8 will be marked as incorrect.

Show fraction input hint?#

If this is ticked and Must the fraction be reduced? is ticked, then text explaining that the student must reduce their fraction to lowest terms is shown next to the input box.

Display the correct answer as a fraction?#

This option is only available when no precision restriction is applied. If this is ticked, the correct answer to the part will be rendered as a fraction of two whole numbers instead of a decimal. For example, if the answer is \(0.5\), it will be displayed as 1/2 instead of 0.5.

Require trailing zeros?#

This option only applies when a precision restriction is selected. If this is ticked, the student must add zeros to the end of their answer (when appropriate) to make it represent the correct precision. For example, consider a part whose correct answer is \(1.4\), and you want the student’s answer to be correct to three decimal places. If “Require trailing zeros?” is ticked, only the answer \(1.400\) will be marked correct. If it is not ticked, any of \(1.4\), \(1.40\) or \(1.400\) will be marked as correct. If too many zeros are used, e.g. \(1.4000\), the answer is marked as incorrect.

Partial credit for wrong precision#

This option only applies when a precision restriction is selected. If the student does not give their answer to the required precision, they only get this much of the available credit for the part.

Message if wrong precision#

This option only applies when a precision restriction is selected. If the student does not give their answer to the required precision, they are given this feedback message.

Show precision restriction hint?#

If this is ticked, then some text describing the rounding the student must perform is shown next to the input box. For example, “round your answer to 3 decimal places”.

Allowed notation#

The styles of number notation that the student can use to enter their answer. There are different ways of writing numbers, based on culture and context. Tick an option to allow the student to use that style in their answer. Note that some styles conflict with each other: for example, 1.234 is a number between 1 and 2 in English, while it’s the integer 1234 in French. The student’s answer will be interpreted using the first allowed style for which it is a valid representation of a number. See Number notation for more on styles of notation.

Correct answer style#

The style of number notation to use when displaying the student’s answer.

Marking settings#

The studentAnswer marking parameter is a string value, containing the string the student typed in the answer box.

This part type provides the following properties to the settings object:

minvalue#

Minimum accepted value, as a number.

maxvalue#

Maximum accepted value, as a number.

correctAnswerFraction#

Display the correct answer as a fraction?

allowFractions

Allow the student to enter a fraction?

mustBeReduced#

Must the fraction be reduced?

mustBeReducedPC#

The proportion of credit to award if the student’s answer is a non-reduced fraction.

notationStyles#

A list of the styles of notation to allow, other than <digits>.<digits>. See Number notation.

displayAnswer

A representative correct answer to display, as a number.

precisionType#

The type of precision restriction to apply, as set by Precision restriction. One of "none", "dp", or "sigfig".

strictPrecision#

Require trailing zeros?

precision#

The number of decimal places or significant figures to require.

precisionPC#

The proportion of credit to award if the student’s answer is not given to the required precision.

precisionMessage#

A message to display in the marking feedback if the student’s answer was not given to the required precision.

Example#

A question in the Numbas demo demonstrates a variety of ways of using number entry parts.

Numbas demo: number entry part type