Parent Directory
|
Revision Log
Updated example files to use new features of parser and its answer checkers.
1 ########################################################## 2 # 3 # Example showing how to use the built-in answer checker for parsed values. 4 # 5 6 DOCUMENT(); # This should be the first executable line in the problem. 7 8 loadMacros( 9 "PGbasicmacros.pl", 10 "PGanswermacros.pl", 11 "Parser.pl", 12 "parserUtils.pl", 13 ); 14 15 TEXT(beginproblem()); 16 17 ########################################################## 18 # 19 # The setup 20 # 21 22 Context("Interval"); 23 24 $a = non_zero_random(-5,5,1); 25 $f = Formula("(x^2+1)/(x-$a)")->reduce; 26 $R = Formula("(-inf,$a),($a,inf)")->eval; 27 28 ########################################################## 29 # 30 # The problem text 31 # 32 33 Context()->texStrings; 34 BEGIN_TEXT 35 36 Suppose \(\displaystyle f(x) = $f\). 37 $PAR 38 Then \(f\) is defined on the intervals \{ans_rule(30)\}. 39 $PAR 40 ${BCENTER} 41 ${BSMALL} 42 To enter more than one interval, separate them by commas.$BR 43 Use ${LQ}${BTT}infinity${ETT}${RQ} for ${LQ}\(\infty\)${RQ} and 44 ${LQ}${BTT}-infinity${ETT}${RQ} for ${LQ}\(-\infty\)${RQ}. 45 ${ESMALL} 46 ${ECENTER} 47 48 END_TEXT 49 Context()->normalStrings; 50 51 ########################################################### 52 # 53 # The answer 54 # 55 56 ANS($R->cmp); 57 $showPartialCorrectAnswers = 1; 58 59 ########################################################### 60 61 ENDDOCUMENT(); # This should be the last executable line in the problem.
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |