Difference between revisions of "AnswerWithUnits1"
Jump to navigation
Jump to search
Paultpearson (talk | contribs) |
Paultpearson (talk | contribs) (Add link to PGML version in OPL) |
||
Line 6: | Line 6: | ||
</p> |
</p> |
||
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits1.pg FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits.pg] |
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits1.pg FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits.pg] |
||
+ | * PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits1_PGML.pg FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits1_PGML.pg] |
||
<br clear="all" /> |
<br clear="all" /> |
Revision as of 16:02, 7 June 2015
Answer is a Number or Formula with Units
This PG code shows how to require students to enter units with their answers.
- File location in OPL: FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits.pg
- 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", ); 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'); $answer[0] = FormulaWithUnits("$v","ft/s"); $answer[1] = NumberWithUnits("$v1","ft/s"); $answer[2] = FormulaWithUnits("$a","ft/s^2"); |
Setup:
We use the differentiation operator |
Context()->texStrings; BEGIN_TEXT 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. $BR $BR (a) What is the velocity of the object? Include units in your answer. $BR \{ ans_rule(20) \} \{ helpLink("units") \} $BR $BR (b) What is the velocity of the object when it hits the ground? Include units in your answer. $BR \{ ans_rule(20) \} \{ helpLink("units") \} $BR $BR (c) What is the acceleration of the object? Include units in your answer. $BR \{ ans_rule(20) \} \{ helpLink("units") \} END_TEXT Context()->normalStrings; |
Main Text:
Don't forget to use |
$showPartialCorrectAnswers = 1; foreach my $i (0..2) { ANS( $answer[$i]->cmp() ); } |
Answer Evaluation: |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |