## PREP 2013 Question Authoring - Archived

### Pl point out the error

by Ravinder Kumar -
Number of replies: 3
What and why is the error in the following, when processed on the interactive lab editior? I am typing exactly same as in one of the problems.

### Re: Pl point out the error

by John Travis -
Davide's "lab" is special with some stuff not allowed for various reasons. Try this in a regular WeBWorK question and it should work.

### Re: Pl point out the error

by Paul Pearson -
Hi Ravinder,

Both example 1 and example 2 below work as stand-alone .pg files. As John already pointed out already, the problem you're having is due to using Davide's PG "Lab" which has some restrictions on what code is allowed to be executed. I know that Context()->texStrings; and Context()->normalStrings; are a lot to type, but once they are in the problem authoring templates you use, they get copied into the new problems you write and thus free you up from having to remember to write \{ $f->TeX \} every time you want a LaTeX version of the formula$f.

Good luck!

Paul

##### Example 1
DOCUMENT();
"PGstandard.pl",
"MathObjects.pl",
);
Context("Numeric");
$f = Formula("2x/(x-1)"); BEGIN_TEXT Suppose $$f(x) = \{ f->TeX \}$$. END_TEXT ENDDOCUMENT(); ##### Example 2 DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", ); Context("Numeric");$f = Formula("2x/(x-1)");
Context()->texStrings;
BEGIN_TEXT
Suppose $$f(x) = f$$.
END_TEXT
Context()->normalStrings;
ENDDOCUMENT();

### Re: Pl point out the error

by Davide Cervone -
The PG lab and the Problem lab differ in some important respects.

The PG lab (problem 87) was designed to accept short code snippets, and have its output be the result of the last command executed. This is to allow you to see the result of a MathObject computation or other short bit of PG code without having to worry about how to produce output.

The Problem lab, on the other hand, is designed for you to experiment with complete problems and play with the output they produce and the answers they require.

The PG lab doesn't expect you to produce output other than the result of the last command, and so does not process BEGIN_TEXT/END_TEXT or the other similar blocks. It is actually this limitation that is causing the problems in your example above (though it is not easy to determine that from the error message).

Those text blocks (and output in general) are processed in the Problem lab, however, and so your example would be better suited to the Problem lab, where it should work fine.

Davide