# Difference between revisions of "DisableFunctions1"

## 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: `FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg`

PG problem file Explanation

Problem tagging:

```DOCUMENT();

"PGstandard.pl",
"MathObjects.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");

```

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
\$BR
\$BR
\( \$f1 = \)
\{ ans_rule(20) \}
\$BR
\$BR
\( \$f2 = \)
\{ ans_rule(20) \}
END_TEXT
Context()->normalStrings;
```

Main Text:

```\$showPartialCorrectAnswers = 1;

```

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

COMMENT('MathObject version.');

ENDDOCUMENT();
```

Solution: