VectorParametric2
Motion and Velocity with a Parametric Curve
This PG code shows how to construct a custom answer checker that extracts the component functions from the student's answer and makes some derivative calculations with them.
- File location in OPL: FortLewis/Authoring/Templates/Parametric/VectorParametric2.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Parametric/VectorParametric2_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserVectorUtils.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); |
Initialization:
Although not necessary for the code below, we load |
Context("Vector2D"); #Context("Vector"); # for 3d vectors Context()->variables->are(t=>"Real"); Context()->variables->set(t=>{limits=>[0,5]}); Context()->flags->set( ijk=>0, ijkAnyDimension => 1 ); $answer = Vector("<2t,(2t)^2>"); |
Setup:
We choose not to display the answer using ijk notation. Also, use |
Context()->texStrings; BEGIN_TEXT Find a vector parametric function \( \vec{r}(t) \) for a bug that moves along the parabola \( y = x^2 \) with velocity \( \vec{v}(t) = \langle 2, 8t \rangle \) for all \( t \). $BR $BR \( \vec{r}(t) = \) \{ ans_rule(20) \} \{ AnswerFormatHelp("vectors") \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers = 1; sub mycheck { my ($correct, $student, $ansHash) = @_; my $xstu = $student . Vector(1,0); my $ystu = $student . Vector(0,1); if ( ($xstu->D('t')==Formula("2")) && ($ystu->D('t')==Formula("8t")) ) { return 1; } else { return 0; } } ANS( $answer->cmp( checker=>~~&mycheck ) ); |
Answer Evaluation:
Use dot products of the student answer with the vectors |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |