# Hint Applet (Trigonometric Substitution) Sample Problem

Line 146: | Line 146: | ||

</script> | </script> | ||

END_TEXT | END_TEXT | ||

+ | ################################## | ||

+ | # Setup Flash applet | ||

+ | # -- this does not need to be changed | ||

+ | ################################### | ||

HEADER_TEXT(qq! | HEADER_TEXT(qq! | ||

<script language="javascript"> | <script language="javascript"> |

## Revision as of 13:30, 23 August 2011

## Flash Applets embedded in hint portion of WeBWorK questions Example

## Sample Problem with trigSubWW.swf embedded

*This sample problem shows how to use embed an applet in the hint portion of a WeBWorK problem.*

A standard WeBWorK PG file with an embedded applet has six sections:

- A
*tagging and description section*, that describes the problem for future users and authors, - An
*initialization section*, that loads required macros for the problem, - A
*problem set-up section*that sets variables specific to the problem, - An
*Applet link section*that inserts the applet and configures it, (this section is not present in WeBWorK problems without an embedded applet) - A
*text section*, that gives the text that is shown to the student, and - An
*answer, hint and solution section*, that specifies how the answer(s) to the problem is(are) marked for correctness, gives hints after a given number of tries and gives a solution that may be shown to the student after the problem set is complete.

The sample file attached to this page shows this; below the file is shown to the left, with a second column on its right that explains the different parts of the problem that are indicated above. Immediately is a screenshot of the WeBWorK problem with the swf file showing the step by step hints.

<flash>file=trigSubWWpic.swf|height=400px|width=550px</flash>

Other applet sample problems:

GraphLimit Flash Applet Sample Problem

GraphLimit Flash Applet Sample Problem 2

Derivative Graph Matching Flash Applet Sample Problem

PG problem file | Explanation |
---|---|

##DESCRIPTION ##KEYWORDS('integrals', 'trigonometric','substitution') ## DBsubject('Calculus') ## DBchapter('Techniques of Integration') ## DBsection('Trigonometric Substitution') ## Date('8/20/11') ## Author('Barbara Margolius') ## Institution('Cleveland State University') ## TitleText1('') ## EditionText1('2010') ## AuthorText1('') ## Section1('') ## Problem1('20') ##ENDDESCRIPTION ######################################## # This work is supported in part by the # National Science Foundation # under the grant DUE-0941388. ######################################## |
This is the The description is provided to give a quick summary of the problem so that someone reading it later knows what it does without having to read through all of the problem code. All of the tagging information exists to allow the problem to be easily indexed. Because this is a sample problem there isn't a textbook per se, and we've used some default tagging values. There is an on-line list of current chapter and section names and a similar list of keywords. The list of keywords should be comma separated and quoted (e.g., KEYWORDS('calculus','derivatives')). |

DOCUMENT(); loadMacros( "PGstandard.pl", "AppletObjects.pl", "MathObjects.pl", "parserFormulaUpToConstant.pl", ); |
This is the
The |

# Set up problem TEXT(beginproblem()); $showPartialCorrectAnswers = 1; $a = random(2,9,1); $a2 = $a*$a; $a3 = $a2*$a; $a4 = $a2*$a2; $a4_3 = 3*$a4; $a2_5 = 5*$a2; $funct = FormulaUpToConstant("-sqrt{$a2-x^2}/{x}-asin({x}/{$a})"); |
This is the
The |

################################### # Create link to applet ################################### $appletName = "trigSubWW"; $applet = FlashApplet( codebase => findAppletCodebase("$appletName.swf"), appletName => $appletName, appletId => $appletName, setStateAlias => 'setXML', getStateAlias => 'getXML', setConfigAlias => 'setConfig', maxInitializationAttempts => 10, height => '550', width => '595', bgcolor => '#e8e8e8', debugMode => 0, onInit => 'ggbOnInit', ); ################################### # Configure applet ################################### $applet->configuration(qq {<xml><trigString>sin</trigString></xml>}); $applet->initialState(qq {<xml><trigString>sin</trigString></xml>}); TEXT(MODES(TeX=>"", HTML=><<'END_TEXT')); <script> if (navigator.appVersion.indexOf("MSIE") > 0) { document.write("<div width='3in' align='center' style='background:yellow'> You seem to be using Internet Explorer.<br/> It is recommended that another browser be used to view this page.</div>"); } </script> END_TEXT ################################## # Setup Flash applet # -- this does not need to be changed ################################### HEADER_TEXT(qq! <script language="javascript"> function ggbOnInit(param) { if (param == "$appletName") { applet_loaded(param,1); // report that applet is ready. ww_applet_list[param].safe_applet_initialize(2); } } </script> ! ); |
This is the
Those portions of the code that begin the line with You must include the section that follows The lines |

TEXT(MODES(TeX=>"", HTML=><<'END_TEXT')); <script> if (navigator.appVersion.indexOf("MSIE") > 0) { document.write("<div width='3in' align='center' style='background:yellow'> You seem to be using Internet Explorer. <br/>It is recommended that another browser be used to view this page.</div>"); } </script> END_TEXT |
The text between the |

BEGIN_TEXT Evaluate the indefinite integral. $BR \[ \int\frac{\sqrt{$a2 - x^2}}{x^2}dx \] $BR \{ans_rule( 60) \} END_TEXT ################################## Context()->texStrings; |
This is the |

################################### # # Answers # ## answer evaluators ANS( $funct->cmp() ); TEXT($PAR, $BBOLD, $BITALIC, "Hi $studentLogin, If you don't get this in 5 tries I'll give you a hint with an applet to help you out.", $EITALIC, $EBOLD, $PAR); $showHint=5; Context()->normalStrings; TEXT(hint( $PAR, MODES(TeX=>'object code', HTML=>$applet->insertAll( debug =>0, reinitialize_button => 0, includeAnswerBox=>0, )) )); ################################## Context()->texStrings; SOLUTION(EV3(<<'END_SOLUTION')); $BBOLD Solution: $EBOLD $PAR To evaluate this integral use a trigonometric substitution. For this problem use the sine substitution. \[x = {$a}\sin(\theta)\] $BR$BR Before proceeding note that \(\sin\theta=\frac{x}{$a}\), and \(\cos\theta=\frac{\sqrt{$a2-x^2}}{$a}\). To see this, label a right triangle so that the sine is \(x/$a\). We will have the opposite side with length \(x\), and the hypotenuse with length \($a\), so the adjacent side has length \(\sqrt{$a2-x^2}\). $BR$BR With the substitution \[x = {$a}\sin\theta\] \[dx = {$a}\cos\theta \; d\theta\] $BR$BR Therefore: \[\int\frac{\sqrt{$a2 - x^2}}{x^2}dx= \int \frac{{$a}\cos\theta\sqrt{$a2 - {$a2}\sin^2\theta}} {{$a2}\sin^2\theta} \; d\theta\] \[=\int \frac{\cos^2\theta}{\sin^2\theta} \; d\theta\] \[=\int \cot^2\theta \; d\theta\] \[=\int \csc^2\theta-1 \; d\theta\] \[=-\cot\theta-\theta+C\] $BR$BR Substituting back in terms of \(x\) yields: \[-\cot\theta-\theta+C =-\frac{\sqrt{$a2-x^2}}{x}-\sin^{-1}\left(\frac{x}{$a}\right)+C \] so \[ \int\frac{\sqrt{$a2 - x^2}}{x^2}dx =-\frac{\sqrt{$a2-x^2}}{x}-\sin^{-1}\left(\frac{x}{$a}\right)+C\] END_SOLUTION Context()->normalStrings; ################################## ENDDOCUMENT(); |
This is the
The |

## License

The Flash applets developed under DUE-0941388 are protected under the following license: Creative Commons Attribution-NonCommercial 3.0 Unported License.