Difference between revisions of "DisableFunctions1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Created page with '<h2>Disabling Functions so Students Must Simplify Answers</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to disable all fun…')
 
Line 65: Line 65:
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
  +
Context("Numeric");
  +
  +
$f1 = Compute("cos(pi)");
  +
$f2 = Compute("sin(pi/3)");
  +
 
Context("Fraction-NoDecimals");
 
Context("Fraction-NoDecimals");
   
$x = Formula("cos(pi)");
 
  +
Context()->functions->disable("All");
  +
Context()->functions->enable("sqrt");
   
$y = Formula("sin(pi/3)");
+
$answer1 = Compute("-1");
  +
$answer2 = Compute("sqrt(3)/2");
 
</pre>
 
</pre>
 
</td>
 
</td>
Line 89: Line 95:
 
$BR
 
$BR
 
$BR
 
$BR
\( $x = \)
+
\( $f1 = \)
 
\{ ans_rule(20) \}
 
\{ ans_rule(20) \}
 
\{ AnswerFormatHelp("fractions") \}
 
\{ AnswerFormatHelp("fractions") \}
 
$BR
 
$BR
 
$BR
 
$BR
\( $y = \)
+
\( $f2 = \)
 
\{ ans_rule(20) \}
 
\{ ans_rule(20) \}
 
\{ AnswerFormatHelp("fractions") \}
 
\{ AnswerFormatHelp("fractions") \}
Line 114: Line 120:
 
$showPartialCorrectAnswers = 1;
 
$showPartialCorrectAnswers = 1;
   
ANS( Real($x->eval)->cmp() );
+
ANS( $answer1->cmp() );
   
ANS( Real($y->eval)->cmp() );
+
ANS( $answer2->cmp() );
 
</pre>
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<td style="background-color:#eeccff;padding:7px;">

Revision as of 23:41, 1 December 2010

Disabling Functions so Students Must Simplify Answers

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: NationalProblemLibrary/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",
"contextFractions.pl",
);

TEXT(beginproblem());

Initialization:

Context("Numeric");

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

Context("Fraction-NoDecimals");

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

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

Setup:

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