Difference between revisions of "AnswerUpToMultiplication1"
Jump to navigation
Jump to search
(Created page with '<h2>Answer is a Function up to Multiplication by a Nonzero Constant</h2> 300pxthumbrightClick to enlarge <p style="backgroundcolor:#f9…') 
Paultpearson (talk  contribs) (PGML example link) 

(2 intermediate revisions by the same user not shown)  
Line 5:  Line 5:  
This PG code shows how to 
This PG code shows how to 

</p> 
</p> 

−  * Download file: [[File:AnswerUpToMultiplication1.txt]] (change the file extension from txt to pg when you save it) 

+  * File location in OPL: [https://github.com/openwebwork/webworkopenproblemlibrary/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1.pg FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1.pg] 

−  * File location in NPL: <code>FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1.pg</code> 

+  * PGML location in OPL: [https://github.com/openwebwork/webworkopenproblemlibrary/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1_PGML.pg FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1_PGML.pg] 

<br clear="all" /> 
<br clear="all" /> 

Line 157:  Line 157:  
[[Category:Top]] 
[[Category:Top]] 

−  [[Category: 
+  [[Category:Sample Problems]] 
+  [[Category:Subject Area Templates]] 
Latest revision as of 21:18, 13 June 2015
Answer is a Function up to Multiplication by a Nonzero Constant
This PG code shows how to
 File location in OPL: FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1.pg
 PGML location in OPL: FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1_PGML.pg
PG problem file  Explanation 

Problem tagging: 

DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); 
Initialization: 
Context("Numeric"); $aSolution = Compute("(x2)(x+1)"); 
Setup: 
Context()>texStrings; BEGIN_TEXT Find a quadratic equation in terms of the variable \( x \) with roots \( 1 \) and \( 2 \). $BR $BR \( y = \) \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()>normalStrings; 
Main Text: 
$showPartialCorrectAnswers = 1; ANS( $aSolution>cmp(checker => sub { my ( $correct, $student, $self ) = @_; my $context = Context()>copy; return 0 if $student == 0; $context>flags>set(no_parameters=>0); $context>variables>add('C0'=>'Parameter'); my $c0 = Formula($context,'C0'); $student = Formula($context,$student); $correct = Formula($context,"$c0 * $aSolution"); return $correct == $student; } ) ); 
Answer Evaluation:
We use a local context with an adaptive parameter to check the answer. For more on adaptive parameters, see AdaptiveParameters When 
Context()>texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()>normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); 
Solution: 