You can create multi-part numerical questions that require your students to enter their observed or estimated data and to perform calculations based on their data. These questions are often used for lab classes to record the results of an experiment and perform analysis of the data.

A well-designed answer-dependent question implements the following behaviors:
• Allows students to enter observed or estimated numerical data. Any response that falls within a defined range of values is scored correct.
• Optionally, provides feedback to students for observed or estimated numerical data based on whether the value is lower than, higher than, or within the range of acceptable values.
• Requires students to perform calculations based on the provided data points.
• Enforces sequential entry of data and calculations so students cannot enter the results of calculations before entering the required data. The answer boxes for calculations are not enabled until your students enter the data required for the calculation.
• Indicates to students when a calculation was performed correctly based on underlying data that are not within the range of acceptable values. Each calculation is scored correct only if the calculation was performed correctly and the underlying data are within the range of acceptable values.

Like all numerical questions, answer-dependent questions can require students to specify units or to use a specified number of significant digits or decimal places in their responses.

1. Create a multi-part or multi-mode question with numerical question parts for students to enter observed or estimated data and calculations based on that data.
2. Add the following code at the beginning of Question:
<eqn include('/userimages/feedback/physlabs1.pl')>

This code is required in order to use the userinput() function described in this topic.

3. Optional: To provide feedback to students for observed or estimated numerical data based on whether the response is lower than, higher than, or within the range of acceptable values, add the following code in Question to specify the information that you want to provide:
<eqn>
%feedback = ( low => 'feedback_text',
high => 'feedback_text',
acceptable => 'feedback_text' );
''
</eqn>

where feedback is the name of a hash variable that contains any feedback_text that you specify for responses that are lower than, higher than, or within the range of acceptable values.

Tip: A hash is a special kind of array consisting of name/value pairs. In Perl, hash names are prefixed with %.

You do not have to specify feedback for all three conditions. You might choose, for example, only to specify text for low and high conditions.

To provide different kinds of feedback for different question parts, you can define multiple hashes. Each hash must have a unique name.

Note: For your feedback to be displayed, you must reference the hash for an answer key as described in the following step. Your assignment settings must also allow hints to be shown.
4. To allow students to enter observed or estimated numerical data for a question part, specify the answer key as a range of values with the userinput() function.

You can set a default value that is shown if no response is provided, units, and feedback for responses that are lower than, higher than, or within the range of acceptable values. Use the following code:

<EQN $response=userinput(low,high,default,'unit',\%feedback)> unit where: • response is the name of a variable that stores your student's response for later calculations. • low and high define the lower and upper limits of the range of acceptable values. • default is a value in between low and high that is displayed as the default answer key if no response was provided. • unit is an optional unit specification for question parts that require students to enter units. You must specify the units in two places — in the userinput() function to indicate units for the low, high, and default values, and at the end of the answer key to make the question part check units in your students' responses. • feedback is the optional name of a hash variable that defines values for feedback to be shown if the student's response is lower than, higher than, or within the range of acceptable values. Always prefix feedback with \% — userinput() requires you to reference the hash name with this syntax rather than passing the hash directly. Tip: You can omit both low and high (but not one or the other), if needed. If you do this, your student's response must match default to be scored as correct; however, you can provide feedback based on whether the response is higher or lower than default. For example, the following code in Answer accepts student measurements for the mass and displacement of two objects and provides different feedback for measurements of mass and volume: <EQN$mass1=userinput(0,10000,5000,'g',\%mass_feedback)> g
<EQN $volume1=userinput(0,5000,2500,'ml',\%vol_feedback)> ml <EQN$mass2=userinput(0,10000,5000,'g',\%mass_feedback)> g
<EQN $volume2=userinput(0,5000,2500,'ml',\%vol_feedback)> ml 5. To require students to perform calculations based on the provided data points, specify the answer key as a calculation in terms of the variables used to store your student's observed or estimated numerical data for other question parts. For example, the following code in Answer accepts two values between 20 and 100, and then requires your students to multiply them: <EQN$A=userinput(20,100,50)>
<EQN $B=userinput(20,100,50)> <EQN$SIMPLIFIED=1; $A *$B>

To require your students to perform the computations instead of stating their response as a mathematical expression, set the $SIMPLIFIED,$FRACTION, or $PROPERFRACTION variables to 1 as you would for any other numerical question. 6. To enforce sequential entry of data and calculations, and to indicate to students when a calculation was performed correctly based on underlying data that are not within the range of acceptable values, define the relationship between the prerequisite data and calculation answer keys using the$LABEL and $LINK variables. In each line in Answer that defines an answer key for student data, set$LABEL to a unique identifier for the answer box.

Important:

The value that you set for $LABEL: • must be unique for each answer box • must not be the same as any variable name in the question One way to ensure this is to use a unique prefix, such as box_, for all$LABEL values.

For example:

<EQN $LABEL='box_A';$A=userinput(20,100,50)>
<EQN $LABEL='box_B';$B=userinput(20,100,50)>

In each line in Answer that defines an answer key for a calculation based on student data, set $LABEL to a unique identifier for the answer box. Then, set$LINK to identify the prerequisite answer boxes (using their $LABEL identifiers) followed by a colon and the calculation to be performed. For example: <EQN$LABEL='box_C'; $LINK='box_A, box_B: box_A * box_B';$SIMPLIFIED=1; $A *$B>

Specifying $LINK in this way enables two behaviors: • The current answer box is not enabled until your student enters values in the answer boxes labeled box_A and box_B. • If the values in either box_A or box_B are not within the range of acceptable values, but the student correctly calculates the value of box_A * box_B, the current answer box displays an icon indicating that the calculation was correct even though the data were not. Tip: If you do not want to indicate that the calculation is correct before your students provide correct data, set the formula in$LINK to no_icon. For example:

<EQN $LABEL='box_C';$LINK='box_A, box_B: no_icon';
$SIMPLIFIED=1;$A * $B> You can use any text value that is not a valid response to a numerical question, but no_icon is easy to remember. The values of$LABEL and \$LINK are never displayed to your students.

7. When testing your question, be sure to test each of the following conditions:
• Data that are lower or higher than the range of acceptable values
• Calculations that are made correctly based on out-of-range data
• Data that are within the range of acceptable values
• Incorrect calculations
• Correct calculations that are made based on data that are within the range of acceptable values
• Data and calculations that correctly and incorrectly specify units
8. When your question displays and functions correctly, click Save.

## Example Answer-Dependent Question Without Feedback

The following table summarizes an actual question.

 QID 1589519 Name Template2 3.ANSD.01. Mode Numerical Question  Multiply two numbers between 20 and 100.

<_> × <_> = <_> Answer   Display to Students

## Example Answer-Dependent Question With Feedback and Units

The following table summarizes an actual question.

 QID 1589509 Name Template2 3.ANSD.02. Mode Numerical Question  %feedback = (low => 'Check your measurements.', high => 'Check your measurements.'); '' For both of the samples at your lab station, measure the volume and mass.
Then, calculate the density. Specify units for all values.

SampleMassVolumeDensity
A<_><_><_>
B<_><_><_>
 Answer  kg cm^3 kg/cm^3 kg cm^3 kg/cm^3 Display to Students