Difference between revisions of "DisableFunctions1"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
<h2>Disabling Functions so Students Must Simplify Answers</h2>
 
<h2>Disabling Functions so Students Must Simplify Answers</h2>
   
  +
[[File:DisableFunctions1.png|300px|thumb|right|Click to enlarge]]
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
This PG code shows how to disable all functions and restrict student answers to fractions.
 
This PG code shows how to disable all functions and restrict student answers to fractions.
<ul>
 
<li>Download file: [[File:DisableFunctions1.txt]] (change the file extension from txt to pg when you save it)</li>
 
<li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg</code></li>
 
</ul>
 
 
</p>
 
</p>
  +
* Download file: [[File:DisableFunctions1.txt]] (change the file extension from txt to pg when you save it)
  +
* File location in NPL: <code>FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg</code>
   
  +
  +
<br clear="all" />
 
<p style="text-align:center;">
 
<p style="text-align:center;">
 
[[SubjectAreaTemplates|Templates by Subject Area]]
 
[[SubjectAreaTemplates|Templates by Subject Area]]

Revision as of 16:19, 2 December 2010

Disabling Functions so Students Must Simplify Answers

Click to enlarge

This PG code shows how to disable all functions and restrict student answers to fractions.

  • Download file: File:DisableFunctions1.txt (change the file extension from txt to pg when you save it)
  • File location in NPL: FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg



Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"AnswerFormatHelp.pl",
"contextFraction.pl",
);

TEXT(beginproblem());

Initialization:

Context("Fraction-NoDecimals");

$f1 = Formula("cos(pi)");
$f2 = Formula("sin(pi/3)");

Context()->functions->disable("All");
Context()->functions->enable("sqrt");

$answer1 = Compute("-1");
$answer2 = Compute("sqrt(3)/2");

Setup: We choose a context that requires fractions as answers and does not allow decimals. After constructing the formulas involving trig functions, we disable all functions and re-enable the sqrt() function. This means that students are not allowed to type in fractions and square roots, but not much else (e.g., they'll get an error message if they type in a trig function).

Context()->texStrings;
BEGIN_TEXT
Enter your answers as simplified fractions.
$BR
$BR
\( $f1 = \)
\{ ans_rule(20) \}
\{ AnswerFormatHelp("fractions") \}
$BR
$BR
\( $f2 = \)
\{ ans_rule(20) \}
\{ AnswerFormatHelp("fractions") \}
END_TEXT
Context()->normalStrings;

Main Text:

$showPartialCorrectAnswers = 1;

ANS( $answer1->cmp() );

ANS( $answer2->cmp() );

Answer Evaluation:

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area