The decimal question type in XLSForms and rtSurvey is used to collect numeric responses that may include fractional parts. This question type is essential for gathering precise numerical data such as measurements, prices, or percentages.

Basic XLSForm Specification

typenamelabel
decimalweightEnter your weight in kg

For more details on the basic decimal question type, see the XLSForm specification.

Uses

Decimal questions are commonly used for:

  1. Measurements (e.g., weight, height, distance)
  2. Financial data (e.g., prices, salaries)
  3. Percentages
  4. Scientific data collection
  5. Any numeric data that requires precision beyond whole numbers

Best Practices

  1. Use clear and concise labels to specify the expected input and unit of measurement.
  2. Implement range constraints to prevent unrealistic or erroneous inputs.
  3. Consider using hint text to provide examples or clarify the expected format.
  4. Specify the desired number of decimal places in the label or hint if precision is important.

Constraints and Validation

You can add constraints to ensure the entered value falls within a specific range:

typenamelabelconstraintconstraint_message
decimalheightEnter your height in meters.>0 and .<=3Height must be between 0 and 3 meters

Example Usage

Here’s an example of how you might use decimal questions in a health survey:

typenamelabelconstraintconstraint_message
decimalweightEnter your weight in kg.>0 and .<=500Weight must be between 0 and 500 kg
decimalheightEnter your height in meters.>0 and .<=3Height must be between 0 and 3 meters
decimalbody_tempEnter your body temperature in Celsius.>=35 and .<=42Temperature must be between 35°C and 42°C
calculatebmi

In the calculate row for BMI, you can use:

  calculation | ${weight} / (${height} * ${height})
  

This will calculate the BMI using the entered weight and height.

rtSurvey Extensions

While the basic XLSForm specification for decimal questions is straightforward, rtSurvey may offer additional features or customizations:

  1. Precision control (number of decimal places)
  2. Custom input formats (e.g., percentage, currency)
  3. Advanced validation rules

(Note: The specific extensions available in rtSurvey for decimal questions would need to be confirmed and detailed here.)

Limitations

  • The precision of decimal numbers may be limited by the underlying system or database.
  • Users may need guidance on the expected decimal separator (period or comma) depending on their locale.
  • Large decimal numbers may be difficult to read or input accurately on mobile devices.
Was this page helpful?