Difference between revisions of "TableOfValues1"
Jump to navigation
Jump to search
Paultpearson (talk  contribs) 
Paultpearson (talk  contribs) (PGML example link) 

Line 6:  Line 6:  
</p> 
</p> 

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

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

<br clear="all" /> 
<br clear="all" /> 
Latest revision as of 21:07, 13 June 2015
Fill in a Table of Values for a Function
This PG code shows how to create a table with answer blanks in it.
 File location in OPL: FortLewis/Authoring/Templates/Precalc/TableOfValues1.pg
 PGML location in OPL: FortLewis/Authoring/Templates/Precalc/TableOfValues1_PGML.pg
PG problem file  Explanation 

Problem tagging: 

DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); 
Initialization: 
Context("Numeric"); $f = Formula("3^(x)"); @answer = (); foreach my $i (0..2) { $answer[$i] = $f>eval(x=>$i); } 
Setup:
We create an empty array 
Context()>texStrings; BEGIN_TEXT If \( f(x) = $f \), fill in the table of values with numbers. \{ AnswerFormatHelp("numbers") \} $PAR $BCENTER \{ begintable(5) . row( "\(x = \)", "0", "1", "2" ) . row( "\(f(x) = \)", ans_rule(5), ans_rule(5), ans_rule(5) ) . endtable(); \} $ECENTER END_TEXT Context()>normalStrings; 
Main Text:
Notice that the table is inside a Perl code block 
$showPartialCorrectAnswers = 1; foreach my $i (0..2) { ANS( $answer[$i]>cmp() ); } 
Answer Evaluation: 
Context()>texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()>normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); 
Solution: 