StringOrOtherType1
This problem has been replaced with a newer version of this problem
Answer is a String, or a Number, or a Function, etc.
This PG code shows how to prevent error messages from appearing when an answer may be one of several data types.
- File location in OPL: FortLewis/Authoring/Templates/Precalc/StringOrOtherType1.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Precalc/StringOrOtherType1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); |
Initialization: |
Context("Numeric"); $y = random(0,4,1); if ($y < 4) { $answer = String("none"); } else { $answer = Formula("2*x"); } |
Setup:
There are several predefined strings, such as |
Context()->texStrings; BEGIN_TEXT Is there a line through the points \( (0,0) \), \( (1,2) \), and \( (2,$y) \)? If there is, the equation for this line. If not, enter ${BITALIC}NONE${EITALIC}. $BR $BR \( y = \) \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers = 1; ANS( $answer->cmp( typeMatch=>Formula("x") ) ); |
Answer Evaluation:
When |
Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |