Difference between revisions of "Spacecurve1"
Paultpearson (talk | contribs) m (Deprecate examples using LiveGraphics3D) |
Paultpearson (talk | contribs) m (Oops. Remove deprecation.) |
||
Line 1: | Line 1: | ||
− | <h2> |
+ | <h2>A Parametric Curve in Space</h2> |
[[File:Spacecurve1.png|300px|thumb|right|Click to enlarge]] |
[[File:Spacecurve1.png|300px|thumb|right|Click to enlarge]] |
||
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> |
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> |
||
− | This PG code shows how to ask a parametric curve question with three answer blanks and use MultiAnswer to check the answer |
+ | This PG code shows how to ask a parametric curve question with three answer blanks and use MultiAnswer to check the answer. |
</p> |
</p> |
||
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/Spacecurve1.pg FortLewis/Authoring/Templates/Parametric/Spacecurve1.pg] |
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/Spacecurve1.pg FortLewis/Authoring/Templates/Parametric/Spacecurve1.pg] |
Revision as of 16:23, 7 June 2015
A Parametric Curve in Space
This PG code shows how to ask a parametric curve question with three answer blanks and use MultiAnswer to check the answer.
- File location in OPL: FortLewis/Authoring/Templates/Parametric/Spacecurve1.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserMultiAnswer.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); |
Initialization:
Since we will have multiple answer blanks that depend on each other, we need to use |
Context("Numeric"); Context()->variables->are(t=>"Real"); Context()->variables->set(t=>{limits=>[0,10]}); $a = random(-5,-2,1); $x = Formula("$a * t**2"); $y = Formula("0"); $z = Formula("t"); $multians = MultiAnswer($x, $y, $z)->with( singleResult => 1, checker => sub { my ( $correct, $student, $self ) = @_; my ( $xstu, $ystu, $zstu ) = @{$student}; return 0 unless $xstu->isFormula; if (($xstu==$a*$zstu**2) && ($ystu==0)) { return 1; } else { return 0; } } ); |
Setup:
We use |
Context()->texStrings; BEGIN_TEXT Find a parametrization of the curve \( x = $a z^2 \) in the \(xz\)-plane. Use \( t \) as the parameter for all of your answers. $BR $BR \( x(t) = \) \{$multians->ans_rule(20)\} \{ AnswerFormatHelp("formulas") \} $BR \( y(t) = \) \{$multians->ans_rule(20)\} \{ AnswerFormatHelp("formulas") \} $BR \( z(t) = \) \{$multians->ans_rule(20)\} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; |
Main Text:
Notice that we use |
$showPartialCorrectAnswers = 0; ANS($multians->cmp()); |
Answer Evaluation: |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |