AnswerWithUnits1
Jump to navigation
Jump to search
Answer is a Number or Formula with Units
This PG code shows how to require students to enter units with their answers.
- PGML location in OPL: FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( 'PGstandard.pl', 'MathObjects.pl', 'parserNumberWithUnits.pl', 'parserFormulaWithUnits.pl', 'PGML.pl', 'PGcourse.pl' ); TEXT(beginproblem()); |
Initialization:
We load |
Context('Numeric')->variables->are(t=>'Real'); $h = Formula('-16 t^2 + 16'); $v = $h->D('t'); $v1 = $v->eval(t=>1); $a = $v->D('t'); $answer1 = FormulaWithUnits("$v",'ft/s'); $answer2 = NumberWithUnits("$v1",'ft/s'); $answer3 = FormulaWithUnits("$a",'ft/s^2'); |
Setup:
We use the differentiation operator |
BEGIN_PGML Suppose the height of a falling object, in feet above the ground, is given by [` h(t) = [$h] `] for [` t \geq 0 `], where time is measured in seconds. a. What is the velocity of the object? [______________]{$answer1} b. What is the velocity of the object when it hits the ground? [______________]{$answer2} c. What is the acceleration of the object? Include units in your answer. [______________]{$answer3} Note: use units in all answers. [@ helpLink('units') @]* END_PGML |
Main Text:
Don't forget to use |
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION COMMENT('Uses PGML.'); ENDDOCUMENT(); |
Solution: |