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.
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.
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.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
feedbackis the name of a hash variable that contains anyfeedback_textthat you specify for responses that are lower than, higher than, or within the range of acceptable values.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.
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)> unitwhere:
responseis the name of a variable that stores your student's response for later calculations.lowandhighdefine the lower and upper limits of the range of acceptable values.defaultis a value in betweenlowandhighthat is displayed as the default answer key if no response was provided.unitis an optional unit specification for question parts that require students to enter units. You must specify the units in two places — in theuserinput()function to indicate units for thelow,high, anddefaultvalues, and at the end of the answer key to make the question part check units in your students' responses.feedbackis 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 prefixfeedbackwith\%—userinput()requires you to reference the hash name with this syntax rather than passing the hash directly.
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)> mlTo 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$PROPERFRACTIONvariables to 1 as you would for any other numerical question.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
$LABELand$LINKvariables.In each line in Answer that defines an answer key for student data, set
$LABELto a unique identifier for the answer box.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
$LABELto a unique identifier for the answer box. Then, set$LINKto identify the prerequisite answer boxes (using their$LABELidentifiers) 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
$LINKin this way enables two behaviors:- The current answer box is not enabled until your student enters values in the answer boxes labeled
box_Aandbox_B. If the values in either
box_Aorbox_Bare not within the range of acceptable values, but the student correctly calculates the value ofbox_A * box_B, the current answer box displays an iconindicating that the calculation was correct even though the data were not.
The values of
$LABELand$LINKare never displayed to your students.- The current answer box is not enabled until your student enters values in the answer boxes labeled
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
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 <eqn include('/userimages/feedback/physlabs1.pl')> Multiply two numbers between 20 and 100. <br><br> <_> × <_> = <_> Answer <EQN $A=userinput(20,100,50)> <EQN $B=userinput(20,100,50)> <EQN $A * $B> 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 <eqn include('/userimages/feedback/physlabs1.pl')> <eqn> %feedback = (low => 'Check your measurements.', high => 'Check your measurements.'); '' </eqn> For both of the samples at your lab station, measure the volume and mass.<br> Then, calculate the density. Specify units for all values.<br><br> <table frame="void" rules="all"> <thead> <tr><th>Sample</th><th>Mass</th><th>Volume</th><th>Density</th></tr> </thead> <tbody> <tr><th>A</th><td><_></td><td><_></td><td><_></td></tr> <tr><th>B</th><td><_></td><td><_></td><td><_></td></tr> </tbody> </table> Answer <EQN $LABEL='box_massA'; $massA=userinput(0,20,10,'kg',\%feedback)> kg <EQN $LABEL='box_volA'; $volA=userinput(0,200,10,'cm^3',\%feedback)> cm^3 <EQN $LABEL='box_densityA'; $LINK='box_massA,box_volA: box_massA/box_volA'; $massA/$volA> kg/cm^3 <EQN $LABEL='box_massB'; $massB=userinput(0,20,10,'kg',\%feedback)> kg <EQN $LABEL='box_volB'; $volB=userinput(0,200,10,'cm^3',\%feedback)> cm^3 <EQN $LABEL='box_densityB'; $LINK='box_massB,box_volB: box_massB/box_volB'; $massB/$volB> kg/cm^3 Display to Students 
- Create Multiple-Choice Questions
- Create True/False Questions
- Create Yes/No Questions
- Create Multiple-Select Questions
- Create Fill-in-the-Blank Questions
- Create File Upload Questions
- Create Free Response Questions
- Create Image Map Questions
- Create Multi-Part Questions That Have One Question Mode
- Create Multi-Mode Questions
- Create Polling Questions
- Add Expandable Sections to Multi-Part Questions
- Create Scored Tutorial Questions
- Create Popup Tutorial Questions
- Create Integer or Decimal Number Questions
- Create mathPad Questions Using Symbolic Mode
- Create mathPad Questions Using Algebraic Mode with Mathematica
- Create a NumberLine Question
- Create Graphing Questions
- Create chemPad Questions for Formulas
- Create List and Rank-Order chemPad Questions
- Create chemPad Questions for Reactions
- Create chemPad Questions for Kinetic or Equilibrium Expressions
- Create chemPad Questions for Electrochemical Cell Notation
- Create chemPad Questions for Electron Configuration
- Create Marvin JS Questions That Require Students to Create a New Drawing
- Create Marvin JS Questions That Display an Initial Drawing
- Create Marvin JS Questions That Use Canonical or Combinatorial SMILES Strings
- Randomize Question Values
- Create Fraction Questions
- Require Units in Numerical Questions
- Check Significant Figures in Numerical Questions
- Check Decimal Places in Numerical Questions
- Change Tolerance for Numerical Questions
- Mathematic Functions and Operators