Parent Directory
|
Revision Log
Problem Authoring Tutorial and Templates for the wiki page SubjectAreaTemplates
1 ## DESCRIPTION 2 ## Trigonometry: periodic answers 3 ## ENDDESCRIPTION 4 5 ## KEYWORDS('trigonometry', 'periodic answer') 6 7 ## DBsubject('WeBWorK') 8 ## DBchapter('WeBWorK Tutorial') 9 ## DBsection('Fort Lewis Tutorial 2011') 10 ## Date('01/30/2011') 11 ## Author('Paul Pearson') 12 ## Institution('Fort Lewis College') 13 ## TitleText1('') 14 ## EditionText1('') 15 ## AuthorText1('') 16 ## Section1('') 17 ## Problem1('') 18 19 20 #################################### 21 # Initialization 22 23 DOCUMENT(); 24 25 loadMacros( 26 "PGstandard.pl", 27 "MathObjects.pl", 28 "AnswerFormatHelp.pl", 29 "answerHints.pl", 30 ); 31 32 TEXT(beginproblem()); 33 34 35 #################################### 36 # Setup 37 38 Context("Numeric"); 39 40 # 41 # We redefine the function whose 42 # name is tan(x) to take values 43 # exp(pi * x). 44 # 45 Context()->functions->remove("tan"); 46 package NewFunc; 47 # this next line makes the function a 48 # function from reals to reals 49 our @ISA = qw(Parser::Function::numeric); 50 sub tan { 51 shift; my $x = shift; 52 return CORE::exp($x*3.1415926535); 53 } 54 package main; 55 # Make it work on formulas as well as numbers 56 sub tan {Parser::Function->call('tan',@_)} 57 # Add the new functions to the Context 58 Context()->functions->add( 59 tan => {class =>'NewFunc', TeX =>'\tan'}, ); 60 61 62 63 #################################### 64 # Main Text 65 66 Context()->texStrings; 67 BEGIN_TEXT 68 Simplify the expression as much as possible. 69 $BR 70 $BR 71 \( \tan(x) \cos(x) \) = \{ ans_rule(20) \} 72 \{ AnswerFormatHelp("formulas") \} 73 END_TEXT 74 Context()->normalStrings; 75 76 77 ################################### 78 # Answer evaluation 79 80 $showPartialCorrectAnswers = 1; 81 82 ANS(Formula("sin(x)")->cmp() 83 ->withPostFilter(AnswerHints( 84 Compute("tan(x)*cos(x)") => 85 "No credit for entering what you were given.", 86 )) 87 ); 88 89 90 ################################### 91 # Solution 92 93 Context()->texStrings; 94 BEGIN_SOLUTION 95 ${PAR}SOLUTION:${PAR} 96 Solution explanation goes here. 97 END_SOLUTION 98 Context()->normalStrings; 99 100 COMMENT("MathObject version. Prevents students from entering trivial identities (entering what they were given). Redefines 'tan(x)' internally as 'exp(pi*x)'."); 101 102 ENDDOCUMENT();
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |