Shows how to add strings to the context.
Download file: StringsInContext.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Preamble
These standard macros need to be loaded.Context()->strings->add(none => {}); # or, if we wanted a case-sensitive string, # we would instead use # Context()->strings->add(none=>{caseSensitive=>1});
Setup
Add the strings that are to be allowed in answers to the Context. Note that the add call has the form string => { options }
. The most common use of options is to allow “aliases”, i.e., strings that are marked the same as others, e.g.,
"none" }); Context()->strings->add(none => {}, N => { alias =>
(Which would allow “N” to be used instead of “none”.)
By default, strings are case-insensitive. To make them case sensitive, include this as an option in the Context call.
There are some shortcuts available if you need to add many allowable strings all at once. See parserAutoStrings.pl.
BEGIN_PGML Enter the positive real value of [`x`] for which [`x^2 = -2`] : [`x = `] [___]{'none'} _(Enter **none** if there are no values that satisfy the equation .) _ END_PGML
Statement
It’s usually a good idea to include some indication of what strings are expected or allowed in the answer.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.