From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:45:17
|
Log Message: ----------- adding setDemo files to modelCourse Added Files: ----------- webwork2/courses/modelCourse/templates/setDemo: c4s5p2.pg josephus.pg limits.pg liteApplet1.pg liteApplet2.pg nsc2s10p2.pg paperHeaderFile1.pg prob0837.pg prob5.pg prob6b.pg s2_2_1.pg sample_myown_ans.pg sample_units_ans.pg screenHeaderFile1.pg srw1_9_4.pg Revision Data ------------- --- /dev/null +++ courses/modelCourse/templates/setDemo/screenHeaderFile1.pg @@ -0,0 +1,85 @@ +##Screen set header for set 0, Fall 1998 + +&DOCUMENT; + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl" +); + + + +BEGIN_TEXT +This is a demonstration set designed to illustrate the range of types of questions which can be asked using WeBWorK rather than to illustrate a typical calculus problem set. + +$PAR +$BBOLD 1. Simple numerical problem. $EBOLD A simple problem requiring a numerical answer. It illustrates how one can allow WeBWorK to calculate answers from formulas (e.g. an answer such as sqrt(3^2 +4^2) can be entered instead of the answer 5.). It also shows +an example of feedback on the correctness of each answer, rather than grading the entire problem. +$PAR +$BBOLD 2. Graphs and limits. $EBOLD The graph in this example is constructed on the fly. From the graph a student is supposed to determine the values and limits of the function at various points. The immediate feedback on this problem is particularly useful, since students often make unconcious mistakes. +$PAR +$BBOLD 3. Derivatives. $EBOLD An example of checking answers which are formulas, rather than numbers. +$PAR +$BBOLD 4. Anti-derivatives. $EBOLD This example will accept any anti-derivative, adjusting for the fact that the answer is only defined up to a constant. +$PAR +$BBOLD 5. Answers with units. $EBOLD Try entering the answer to this question in meters (m) and also centimeters (cm). +$PAR +$BBOLD 6. A physics example. $EBOLD Includes a static picture. +$PAR +$BBOLD 7. More graphics. $EBOLD An example of on-the-fly graphics. Select the graph of f, it's derivative and it's second derivatives. +$PAR +$BBOLD 8. JavaScript example. $EBOLD I'm particularly fond of this example. The computer provides an "oracle" function: give it a number \(x\) and it will provide you with the value \(f(x)\) of the function at \(x\). Using this, calculate the value of the derivative of \(f\) at 2. (i.e. \(f'(2)\) ). Students are forced to use the Newton quotient, since there are no formulas to work with. I don't think this problem could be asked as written homework. +$PAR +$BBOLD 9. Java example. $EBOLD This gives an example of incorporating a java applet which can be used experimentally to determine answers for WeBWorK questions. This particular example is somewhat forced. There is a lot of room for experimentation and improvement in combining these two technologies. +$PAR +$BBOLD 10. Palindrome. $EBOLD To answer this problem enter any palindrome. This problem illustrates the power of the "answer-evaluator" model. For each problem the problem designer writes a function which accepts a student's answer and produces a 0 or 1 (for incorrect or correct). Usually this is done by comparing with an answer given by the problem designer, but in this case the function checks if the answer is the same forward and backward. +$PAR +$BBOLD 11. Lite Applet. $EBOLD An example of using the map lite applet +$PAR +$PAR +$BBOLD 12. Lite Applet. $EBOLD An example of using the map lite applet where the cities are +chosen randomly.l +$PAR +$BBOLD 13. JavaScript $EBOLD The Josephus problem. Currently the javaScript is a bit too complicated, since it uses frames. With a little more work one might be able to embed this in a PG problem. +$PAR +END_TEXT + + + +BEGIN_TEXT +$HR + +Use this box to give information about this problem +set. Typical information might include some of these facts: +$PAR +WeBWorK assignment number $setNumber is due on : $formatedDueDate. + + +$PAR +The primary purpose of WeBWorK is to let you know if you are getting the right answer or to alert +you if you get the wrong answer. Usually you can attempt a problem as many times as you want before +the due date. However, if you are having trouble figuring out your error, you should +consult the book, or ask a fellow student, one of the TA's or +your professor for help. Don't spend a lot of time guessing -- it's not very efficient or effective. +$PAR + +You can use the Feedback button on each problem +page to send e-mail to the professors. +$PAR +Give 4 or 5 significant digits for (floating point) numerical answers. +For most problems when entering numerical answers, you can if you wish +enter elementary expressions such as 2^3 instead of 8, sin(3*pi/2) instead +of -1, e^(ln(2)) instead of 2, +(2+tan(3))*(4-sin(5))^6-7/8 instead of 27620.3413, etc. +$PAR + Here's the +\{ htmlLink(qq!http://webwork.math.rochester.edu/webwork_system_html/docs/docs/pglanguage/availablefunctions.html!,"list of the functions") \} + which WeBWorK understands. + +Along with the \{htmlLink(qq!http://webwork.math.rochester.edu/webwork_system_html/docs/docs/pglanguage/availablefunctions.html!, "list of units")\} which WeBWorK understands. This can be useful in +physics problems. +END_TEXT + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/sample_myown_ans.pg @@ -0,0 +1,86 @@ +DOCUMENT(); + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl" +); + +TEXT(&beginproblem); +$showPartialCorrectAnswers = 1; + +BEGIN_TEXT + This problem demonstrates how you can write your own procedure to check answers. + The procedure is embedded right in the problem. If you wanted to use it for several + problems, you could put it in a file similar to "PGanswermacros.pl" and load it into + the problem. + + This problem asks you to enter a palindrome, a word, number, or phrase that is the same + when read backwards or forward. For example, madam or Hannah. For us a standard + palindrome will ignore spaces and case, but a strict palindrome will not. So e.g. Hannah + is a standard but not a strict palindrome. We will write a test for both types. $BR $BR + Enter a standard palindrome such as "Hannah", "1234321", or "Mom". $BR + This uses std${US}palindrome${US}test $BR + \{ans_rule(60) \} +END_TEXT + + +$std_palindrome_test = sub { + my $in = shift @_; + my $normalizedCorrectAnswer = "There are many correct answers, e.g. Hannah"; + $in =~ s|~~s+||g; # remove all spaces + ## use ~~ inplace of perl's backslash in problems + $in = uc $in; # Make letters uppercase + ## use ~~ inplace of perl's backslash in problems + my $reverse = reverse $in; + my $correctQ = ($in eq $reverse) ? 1: 0; + my $ansMsg = ''; + unless ($in =~ m|~~S|) { + $correctQ = 0; + $ansMsg = 'An empty string is not accepted as a palindrome'; + } + my $rh_answer = new AnswerHash( score => $correctQ, + correct_ans => $normalizedCorrectAnswer, + student_ans => $in, + ans_message => $ansMsg, + type => 'custom' + ); + $rh_answer; + +}; + +ANS($std_palindrome_test); + + +BEGIN_TEXT; +$PAR +Now enter a strict palindrome such as "1234321", or "mom". $BR +This uses strict${US}palindrome${US}test $BR +\{ans_rule(60) \} +END_TEXT + +$strict_palindrome_test = sub { + my $in = shift @_; + my $normalizedCorrectAnswer = "There are many correct answers, e.g. HannaH"; + $in =~ s/~~s*$//; # remove trailing whitespace ## use ~~ inplace of perl's backslash in problems + $in =~ s/^~~s*//; # remove initial spaces ## use ~~ inplace of perl's backslash in problems + my $reverse = reverse $in; + my $correctQ = ($in eq $reverse) ? 1: 0; + my $ansMsg = ''; + unless ($in =~ m|~~S|) { + $correctQ = 0; + $ansMsg = 'An empty string is not accepted as a palindrome'; + } + + my $rh_answer = {score => $correctQ, + correct_ans => $normalizedCorrectAnswer, + student_ans => $in, + ans_message => $ansMsg, + type => 'custom' + }; + $rh_answer; +}; + +ANS($strict_palindrome_test); + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/nsc2s10p2.pg @@ -0,0 +1,67 @@ +#DESCRIPTION +# Identify the graphs of the function and the derivative +#ENDDESCRIPTION + +#KEYWORDS('derivatives', 'graphs') +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl", + "PGgraphmacros.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 0; + +$a=random(0, 6.3, .1); +$b=random(1.1, 1.5, .1); + +$dom = 4; +@slice = NchooseK(3,3); + +@colors = ("blue", "red", "black"); +@sc = @colors[@slice]; #scrambled colors +@sa = ('A','B','C')[@slice]; + + +$f = "sin($a+$b*cos(x)) for x in <-$dom,$dom> using color:$sc[0] and weight:2"; +$fp = "cos($a+$b*cos(x))*(-$b)*sin(x) for x in <-$dom,$dom> using color=$sc[1] and weight:2"; +$fpp = " -sin($a+$b*cos(x))*$b*$b*sin(x)*sin(x) + cos($a+$b*cos(x))*(-$b)*cos(x) for x in <-$dom,$dom> using color=$sc[2] and weight=2"; + +$graph = init_graph(-4,-4,4,4,'axes'=>[0,0],'grid'=>[8,8]); + +($fRef,$fpRef,$fppRef) = plot_functions( $graph, + $f,$fp,$fpp + ); + +# create labels + +$label_point=-0.75; +$label_f = new Label ( $label_point,&{$fRef->rule}($label_point),$sa[0],"$sc[0]",'left') ; + # NOTE: $fRef->rule is a reference to the subroutine which calculates the + # function. It was defined in the output of plot_functions. It is used here + # to calculate the y value of the label corresponding to the function, + # and below to find the y values for the labels corresponding to the + # first and second derivatives. + +$label_fp = new Label ( $label_point,&{$fpRef->rule}($label_point),$sa[1],"$sc[1]",'left') ; +$label_fpp = new Label ( $label_point,&{$fppRef->rule}($label_point),$sa[2],"$sc[2]",'left'); + +# insert the labels into the graph + +$graph->lb($label_f,$label_fp,$label_fpp); + +BEGIN_TEXT +\{ image(insertGraph($graph))\}$BR +Identify the graphs A (blue), B( red) and C (green) as the graphs of a function and its +derivatives:$PAR +\{ans_rule(4)\} is the graph of the function $PAR +\{ans_rule(4)\} is the graph of the function's first derivative $PAR +\{ans_rule(4)\} is the graph of the function's second derivative $PAR +END_TEXT +ANS(std_str_cmp_list( @sa ) ); + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setDemo/c4s5p2.pg @@ -0,0 +1,50 @@ +#DESCRIPTION +#KEYOWRDS('integrals', 'substitution') +# Integrals - \int_0^{$x1} x(x^2 ?{$a})^5 dx +# Substitution +#ENDDESCRIPTION + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +$n = random(3,6,1); +$n1 = $n-1; + +BEGIN_TEXT +Find \[ F(x) = \int x^{$n1}\cos(x^{$n}) \; dx \] +Give a specific function for \( F(x) \). $BR $BR + +F(x) = \{ans_rule(45)\} +END_TEXT + +$ans = "sin(x^$n)/$n"; +ANS(function_cmp_up_to_constant($ans )); + +#$ans = "sin(x^$n)/$n + c"; # c is the constant of integration which + # is a free parameter. It can be adjusted + # to match the student's answer. +#ANS( fun_cmp($ans, params => ['c'] ) ); +$a1= random(-9,-1,1); +$b1= random(0,9,1); + +BEGIN_TEXT +$BR $BR +Evaluate \[ F(x) = \int_{$a1}^{$b1} x^{$n1}\cos(x^{$n}) \; dx \] +$BR +\{ans_rule(50)\} +END_TEXT + +$ans = (sin($b1**$n) - sin($a1**$n))/$n; + +&ANS(num_cmp($ans )); + + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setDemo/prob6b.pg @@ -0,0 +1,88 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); +#<<<######################################################### +# allow the student to change the seed for this problem. + +$newProblemSeed = ( defined( ${$inputs_ref}{'newProblemSeed'} ) )? +${$inputs_ref}{'newProblemSeed'} : $problemSeed; +$PG_random_generator->srand($newProblemSeed); +BEGIN_TEXT +To see a different version of the problem change +the problem seed and press the 'Submit Answer' button below.$PAR Problem Seed: +\{ MODES( +TeX => qq! Change the problem seed to change the problem:$problemSeed!, +Latex2HTML => qq! Change the problem seed to change the problem: + \begin{rawhtml} + <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10"> + \end{rawhtml}!, +HTML => qq! <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10">! +) +\} +END_TEXT +#########################################################>>> +$p = random(2,9,1); # multiplier +$p2 = ( $p % 2 == 0) ? 2*$p : $p; + +TEXT(beginproblem()); + +# The link to the java applet is hard wired to use the java applet +# served from the University of Rochester WeBWorK machine. +# It is possible to set this up so that the java applet is served +# from any machine +# For details use the Feedback button to contact the authors of WeBWorK + +BEGIN_TEXT +This problem requires a browser capable of running Java. + +$PAR +This problem illustrates how you can Java applets in a WeBWorK example. +$PAR +This polar coordinate grapher was constructed at the Mathematics Department +of The Johns Hopkins University and the applet is being served from their computer. +$PAR +WeBWorK can use existing $BBOLD JavaScript$EBOLD and $BBOLD Java $EBOLD code to +augment its capabilities. +$HR +END_TEXT +TEXT(MODES( +TeX => "\fbox{The Johns Hopkins University Mathematics Department's + polar graph plotting applet goes here}", +HTML => qq{ + <APPLET CODE="PolarApplet/PolarApplet.class" WIDTH="250" HEIGHT="350" + CODEBASE="http://xena.mat.jhu.edu/vander/stable/"> + <PARAM NAME="tmin" VALUE="0"> + <PARAM NAME="tmax" VALUE="2*pi"> + <PARAM NAME="showcartesian" VALUE="no"> + <PARAM NAME="showinterval" VALUE="YES"> + </APPLET> +}, +Latex2HTML => qq!\begin{rawhtml} + <APPLET CODE="PolarApplet/PolarApplet.class" WIDTH="250" HEIGHT="350" + CODEBASE="http://xena.mat.jhu.edu/vander/stable/"> + <PARAM NAME="tmin" VALUE="0"> + <PARAM NAME="tmax" VALUE="2*pi"> + <PARAM NAME="showcartesian" VALUE="no"> + <PARAM NAME="showinterval" VALUE="YES"> + </APPLET>\end{rawhtml} +! +)); + +BEGIN_TEXT +$PAR +For what value of \( k \) does the graph of \( r = \cos(kt) \) look +like a rose with $p2 petals? +$BR +\(k = \) \{ ans_rule(20) \} ; + +$PAR + +END_TEXT + +ANS(num_cmp($p) ); + +ENDDOCUMENT(); + --- /dev/null +++ courses/modelCourse/templates/setDemo/josephus.pg @@ -0,0 +1,206 @@ +&DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); +# define function to be evaluated + +HEADER_TEXT(<<EOF); +<script LANGUAGE="JavaScript"> + +function joeGame(n, k, m){ +this.people = n +this.skip = k +this.keep = m +this.list = new Array(n) +for (var i=0; i<n; i++) { + this.list[i] = 0 + } +} + +var currentGame = new joeGame(10,0,0) + +function joeth(n, k, s) { +var x = k*s +while (x > n) { + x = Math.floor(( k*(x-n) - 1.0 )/ (k-1.0) ) + } +return(x) +} + +function playGame() { + +var newN = parseInt(document.gameForm.peopleNumField.value) +var newK = parseInt(document.gameForm.skipNumField.value) + +var suff = new String("th") + +var s +var n = newN +var k = newK +var numRows = Math.floor(n/20) +var numLeft = n - 20*numRows + +if (!newN || !newK) { + alert ("Enter some data.") + document.gameForm.peopleNumField.focus() + } +else + { + +currentGame = new joeGame(n, k, 1) + +for (var s=1; s<=currentGame.people; s++){ + currentGame.list[s-1] = joeth(n, k, s) + } + +if ((newK % 10) == 1) { + if ((newK == 1) || (newK > 20)) { + suff = "st" + } + else { + suff="th" + } +} +else { + if ((newK % 10) == 2){ + if ((newK == 2) || (newK > 20)) { + suff = "nd" + } + else { + suff="th" + } + } + else { + if ((newK % 10) == 3){ + if ((newK == 3) || (newK > 20)) { + suff = "rd" } + else { + suff="th" + } + } + } +} + +parent.gameStatus.document.clear() +parent.gameStatus.document.write("<H2> The Josephus Game </H2>") +parent.gameStatus.document.write("<FONT SIZE=2> Playing the Josephus Game with <B>" + + document.gameForm.peopleNumField.value + "</B> people, ") +parent.gameStatus.document.write(" eliminating every <B>" + + document.gameForm.skipNumField.value + "</B><SUP>" + suff + "</SUP> person, leaves ") +parent.gameStatus.document.write(" person <U><B>" + currentGame.list[n-1] + "</B></U> as the last survivor. ") +parent.gameStatus.document.write("<P>The entire elimination order is <BR><BR>") + +for (var d=0; d<numRows; d++) { + parent.gameStatus.document.write("<TABLE BORDER=1> \n <TR> <TH> Order Eliminated </TH>") + for (var k=1; k<=20; k++) { + parent.gameStatus.document.write(" <TD> " + (20*d + k) + " </TD> ") + } + parent.gameStatus.document.write("</TR> \n <TR> <TH> Person Eliminated </TH> ") + + for (k=0; k<20; k++) { + parent.gameStatus.document.write(" <TD> " + currentGame.list[20*d+k] + " </TD> ") + } + parent.gameStatus.document.write("</TR> \n </TABLE> <BR>") + } +if (numLeft > 0) { + parent.gameStatus.document.write("<TABLE BORDER=1> \n <TR> <TH> Order Eliminated</TH>") + for (var k=1; k<=numLeft; k++) { + parent.gameStatus.document.write(" <TD> " + (20*d + k) + " </TD> ") + } + parent.gameStatus.document.write("</TR> \n <TR> <TH> Person Eliminated </TH> ") + + for (k=0; k<numLeft; k++) { + parent.gameStatus.document.write(" <TD> " + currentGame.list[20*d+k] + " </TD> ") + } + parent.gameStatus.document.write("</TR> \n </TABLE> <BR></FONT>") + } + } + parent.gameStatus.document.close() +} + + +function clearStuff(){ +parent.gameStatus.document.open() +parent.gameStatus.document.clear() +parent.gameStatus.document.location = "gamestart.html" +parent.gameStatus.document.close() +document.gameForm.peopleNumField.focus() +currentGame.people = 10 +currentGame.skip = 0 +currentGame.keep = 0 +for (var i=0; i++; i<currentGame.people) { + currentGame.list[i] = 0 + } +} + + +function main() { +parent.gameStatus.document.open() +playGame() +parent.gameStatus.document.close() +} + +</script> + + +EOF + + +TEXT(beginproblem()); +TEXT(MODES( +TeX => '', +Latex2HTML => "\begin{rawhtml} <NOSCRIPT> This problem requires that Java + Script be enabled </NOSCRIPT> \end{rawhtml}", +HTML => "<NOSCRIPT> This problem requires that Java Script be + enabled </NOSCRIPT>" +)); + +BEGIN_TEXT +$PAR +This problem illustrates how you can embed JavaScript code in a WeBWorK example +to create an interactive homework problem that could never be provided by a text book. +Stolen from Doug Ensley and mathDL. +http://www.mathdl.org/offsite.html?page=http://www.ship.edu/~deensl/mathdl/Joseph.html&content_id=41520 +END_TEXT + +BEGIN_TEXT +<script> + document.main(); +</script> +END_TEXT +TEXT(<<EOF); +<form NAME="gameForm" onReset="clearStuff()"> +<table CELLSPACING=10 CELLPADDING=10 > +<tr VALIGN=TOP> +<td> +<table> +<tr> +<th><i>n</i> = </th> + +<td><input TYPE="text" NAME="peopleNumField" SIZE=5></td> +</tr> + +<tr> +<th><i>k</i> = </th> + +<td><input TYPE="text" NAME="skipNumField" SIZE=5></td> +</tr> +</table> +<input TYPE="button" NAME="playButton" VALUE="Start" + onClick="playGame()"><input TYPE="reset" NAME="resetButton" VALUE="Clear All"></td> + +<td WIDTH="200"><font size=-1>Set the parameters and press <b>Start</b> +to see the elimination order when you start with <b><i>n</i></b> people +and eliminate every <b><i>k</i></b><sup>th</sup> one.</font></td> +</tr> +</table> + +<p></form> +EOF +$ans =3; + +ANS(num_cmp($ans,reltol=>1,format =>"%0.14g") ); #We are allowing 1 percent error for the answer. + + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/s2_2_1.pg @@ -0,0 +1,56 @@ +##DESCRIPTION +##KEYWORDS('derivatives') +## Find a derivative of a polynomial, evaluate it at a point +##ENDDESCRIPTION + +DOCUMENT(); # This should be the first executable line in the problem. +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT(&beginproblem); +$showPartialCorrectAnswers = 1; + +$a1 = random(2,7,1); +$b1 = random(2,12,1); +$c1 = random(1,40,1); +$x1 = random(1,5,1); +$deriv1 = 2*$a1*$x1-$b1; +$funct1 = "2*$a1*x-$b1"; + +BEGIN_TEXT +If \( f(x) = $a1 x^2 - $b1 x -$c1 \), find \( f'( x ) \). +$BR $BR \{ans_rule(48) \} +$BR +END_TEXT + +$ans = $funct1; +&ANS(fun_cmp($ans)); + +$a1_2 = 2*$a1; +&SOLUTION(EV3(<<'EOT')); +$SOL $BR +In general the derivative of \( x^n \) is \( nx^{n-1} \). Using this (and the +basic sum and constant multiple rules) we find the derivative of $BR +\(${a1}x^2 - ${b1}x -$c1 \quad \) is $BR \( ${a1_2}x - $b1 \).$BR $BR +EOT + +BEGIN_TEXT +Find \( f'( $x1 ) \). +$BR $BR \{ans_rule(48) \} +$BR $BR +END_TEXT + +$ans = $deriv1; +&ANS(num_cmp($ans)); + +&SOLUTION(EV3(<<'EOT')); +$SOL $BR +To find the derivative we just have to evaluate \( f'( x ) \) at +\( x = $x1) \), i.e. \( ${a1_2}\cdot$x1 - $b1 \) or $ans. +EOT + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setDemo/prob5.pg @@ -0,0 +1,138 @@ +&DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); +######################################################### +# allow the student to change the seed for this problem. + +$newProblemSeed = ( defined( ${$inputs_ref}{'newProblemSeed'} ) )? ${$inputs_ref}{'newProblemSeed'} : $problemSeed; +$PG_random_generator->srand($newProblemSeed); +BEGIN_TEXT +To see a different version of the problem change +the problem seed and press the 'Submit Answer' button below.$PAR Problem Seed: +\{ MODES( +TeX => qq! Change the problem seed to change the problem:$problemSeed!, +Latex2HTML => qq! Change the problem seed to change the problem: + \begin{rawhtml} + <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10"> + \end{rawhtml}!, +HTML => qq! <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10">! +) +\} +END_TEXT +######################################################### +# define function to be evaluated +$a= random(1,3,1); +$b= random(-4,4,.1); +$c = random(-4,4,1); +$x0=random(-2,2,1); +$function = FEQ(" ${a}x^2+${b}x +$c "); +sub fp { # define a subroutine to calculate the derivative + my $x = shift; + 2*$a*$x+$b; +} +$ans = fp($x0); +HEADER_TEXT(<<EOF); +<SCRIPT LANGUAGE="JavaScript"> +<!-- This script and many more are available online from --> +<!-- The JavaScript Source!! http://javascriptsource.com --> + +<!-- Begin + +function func(x) { +return( $a*Math.pow(x,2) + $b*x +$c );} + +// End + --> +</SCRIPT> + +EOF + + +TEXT(beginproblem()); +TEXT(MODES( +TeX => '', +Latex2HTML => "\begin{rawhtml} <NOSCRIPT> This problem requires that Java + Script be enabled </NOSCRIPT> \end{rawhtml}", +HTML => "<NOSCRIPT> This problem requires that Java Script be + enabled </NOSCRIPT>" +)); + +BEGIN_TEXT +$PAR +This problem illustrates how you can embed JavaScript code in a WeBWorK example +to create an interactive homework problem that could never be provided by a text book. +$PAR +WeBWorK can use existing $BBOLD JavaScript$EBOLD and $BBOLD Java $EBOLD code to augment its capabilities. +$HR +$PAR +By typing any value x into the left hand window and pressing the --f--\(>\) button +you can determine the value of f(x). +$PAR +Using this 'oracle' function, calculate the derivative of \( f \) at x=$x0. +$PAR +\(f'($x0) =\) \{ans_rule(20) \} You can use a +\{htmlLink(alias('calc.html'), "calculator" ,q!TARGET = "calculator"!) \} + +$PAR +END_TEXT + +$javaScript =<<ENDOFSCRIPT; +<CENTER> +<TABLE BORDER=4> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input1" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output1.value=func(this.form.Input1.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output1" Size="20"> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input2" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output2.value=func(this.form.Input2.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output2" Size="20"> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input3" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output3.value=func(this.form.Input3.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output3" Size="20"> +</TD> +</TR> +</TABLE> + +</CENTER> +ENDOFSCRIPT + +TEXT(M3( + " \fbox{ The java Script calculator was displayed here + }", + "\begin{rawhtml} $javaScript \end{rawhtml}", + $javaScript + )); + + + +ANS(std_num_cmp($ans,1,"%0.14g") ); #We are allowing 1 percent error for the answer. + + +&ENDDOCUMENT; + --- /dev/null +++ courses/modelCourse/templates/setDemo/prob0837.pg @@ -0,0 +1,66 @@ +DOCUMENT(); + +loadMacros( "PGbasicmacros.pl", + "PGauxiliaryFunctions.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl", + "PG_CAPAmacros.pl" +); + +TEXT(beginproblem()); + +# machine translated from CAPA. +# This is probaly not a good model for elegant PG code. +## ************************************** +## +## Projectile motion. +## By F. Wolfs, WO...@NS... +## No unauthorized commercial use +## Imported Files +## ${CAPA_Tools}Problem +## ${CAPA_GraphicsDirectory}Gtype08/prob37.eps +## Values needing defined: +## prob_val (number, e.g. /LET prob_val=1) +## prob_try (number, e.g. /LET prob_try=5) +## +## Last modified 07/08/97 +## by: Patrick D. Freivald, pa...@fr... +## +## ************************************** +## +$L = random( 2.0 , 10.0 , 0.2 ) ; +$h = random( 0.5 , 0.5 * $L , 0.1 ) ; +$Theta = random( 35.0 , 60.0 , 1.0 ) ; +$v0_sq = $smallg * $L / ( 2.0 * cos( $Theta * $degrad ) * cos( $Theta * $degrad ) * ( tan( $Theta * $degrad ) - $h / $L ) ) ; +$v0 = pow( $v0_sq , 0.5 ) ; +## +CAPA_import( " ${CAPA_Tools}Problem " ); +TEXT(CAPA_EV (<<'END_OF_TEXT')); +A basketball player throws the ball at a \{ spf( $Theta , "%0.0f" ) \}\{ $deg_u \} angle above the horizontal to a hoop which is located a horizontal distance \{ CAPA_tex( '/*L/*' , 'L' ) \} = \{ spf( $L , "%0.1f" ) \} \{ $m_u \} from the point of release and at a height \{ CAPA_tex( '/*h/*' , 'h' ) \} = \{ spf( $h , "%0.1f" ) \} \{ $m_u \} above it. What is the required speed if the basketball is to reach the hoop? +\{ CAPA_web( '' , '\noindent {\centerline{\epsfxsize = 2.4 in \epsffile{${CAPA_GraphicsDirectory}Gtype08/prob37.eps}}}' , '<img src = ${CAPA_Graphics_URL}Gtype08/prob37.gif align=center width=275>' ) \} +END_OF_TEXT + +## + +TEXT("$BR$BR",ans_rule(30),"$BR"); +ANS( CAPA_ans( $v0 , 'format' => "%0.2e" , 'sig' => '3 PLUS 13', 'reltol' => 1 , 'wgt' => $prob_val , 'tries' => $prob_try , 'unit' => 'm/s' ) ); +ENDDOCUMENT(); +##################### + +###Error: $smallg not defined in this file +###Error: $degrad not defined in this file +###Error: $degrad not defined in this file +###Error: $degrad not defined in this file +###Error: $deg_u not defined in this file +###Error: $m_u not defined in this file +###Error: $m_u not defined in this file +###Error: $prob_val not defined in this file +###Error: $prob_try not defined in this file + +##################### + + +################################################# +## Processing time = 0 secs ( 0.56 usr 0.00 sys = 0.56 cpu) +################################################# --- /dev/null +++ courses/modelCourse/templates/setDemo/limits.pg @@ -0,0 +1,90 @@ +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT(&beginproblem); +$showPartialCorrectAnswers = 1; + +$a=random(-3,3,1); +$b=random(-2,3,1); +$c=random(-3,2,1); +$m1=random(-1,1,0.5); +$m2=($b - $a)/2; +$m3=($c - $b - 1)/2; +$m4=random(-1,1,0.5); +@slice = NchooseK(3,3); + +@colors = ("blue", "red", "green"); +@sc = @colors[@slice]; #scrambled colors +@sa = ('A','B','C')[@slice]; + +$f1 = FEQ("${m1}(x+1) + $a for x in [-2,-1) using color:$sc[0] and weight:2"); +$f2 = FEQ("${m2}(x-1) + $b for x in (-1,1) using color=$sc[0] and weight:2"); +$f3 = FEQ("${m3}(x-3) + $c for x in [1,3) using color=$sc[0] and weight=2"); +$f4 = FEQ("1+$a for x in [-1,-1] using color=$sc[0] and weight=2"); +$f5 = FEQ("${m4}(x-3) + $c for x in (3,4] using color=$sc[0] and weight=2"); + +$graph = init_graph(-3,-6,5,6,'axes'=>[0,0],'grid'=>[8,12]); + +($f1Ref,$f2Ref,$f3Ref,$f4Ref,$f5Ref) = plot_functions($graph,$f1,$f2,$f3,$f4,$f5); + +BEGIN_TEXT +Let F be the function below.$PAR +If you are having a hard time seeing the picture clearly, click on the picture. It will expand to a larger picture on its own page so that you can inspect it more clearly.$PAR +END_TEXT + +TEXT(image( insertGraph($graph), height=>200, width=>200 )); + +BEGIN_TEXT +$BR +$BR +Evaluate each of the following expressions. $PAR +Note: Enter 'DNE' if the limit does not exist or is not defined. $PAR + +a) \( \lim_{x \to -1^-} F(x) \) = \{ans_rule(4)\} +$PAR + +b) \( \lim_{x \to -1^+} F(x) \) = \{ans_rule(4)\} +$PAR + +c) \( \lim_{x \to -1} F(x) \) = \{ans_rule(4)\} +$PAR + +d) \( F(-1) \) = \{ans_rule(4)\} +$PAR + +e) \( \lim_{x \to 1^-} F(x) \) = \{ans_rule(4)\} +$PAR + +f) \( \lim_{x \to 1^+} F(x) \) = \{ans_rule(4)\} +$PAR + +g) \( \lim_{x \to 1} F(x) \) = \{ans_rule(4)\} +$PAR + +h) \( \lim_{x \to 3} F(x) \) = \{ans_rule(4)\} +$PAR + +i) \( F(3) \) = \{ans_rule(4)\} +$PAR + +END_TEXT + +$ap1 = 1 + $a; +$bp1 = 1 + $b; + +# limits at -1 +ANS(num_cmp( [ $a, $a, $a, $ap1] , strings => ['DNE'] )) ; +# limits at 1 +ANS(num_cmp( [ $b, $bp1,'DNE'] , strings => ['DNE'] )) ; +# limits at 3 +ANS(num_cmp( [ $c, 'DNE' ] , strings => ['DNE'] )) ; + + +ENDDOCUMENT(); # This should be the last executable line in the problem. \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/paperHeaderFile1.pg @@ -0,0 +1,31 @@ +##Problem set header for set 0, Spring 1999 + +&DOCUMENT; + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl" +); + +$dateTime = $formatedDueDate; + +TEXT(EV2(<<EOT)); +$BEGIN_ONE_COLUMN +\noindent {\large \bf $studentName} +\hfill +\noindent {\large \bf MAA Minicourse San Diego January 2002} +\par +\noindent{\large \bf Homework Set $setNumber due $dateTime}\par + +\noindent This is a demonstration set designed to show you some types of questions +that can be asked using WeBWorK. + +\par +\noindent You may need to give 4 or 5 significant digits for some (floating point) +numerical answers in order to have them accepted by the computer. +$END_ONE_COLUMN +EOT + +&ENDDOCUMENT; --- /dev/null +++ courses/modelCourse/templates/setDemo/liteApplet1.pg @@ -0,0 +1,68 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +$showPartialCorrectAnswers = 1; +TEXT(beginproblem()); + +# The link to the java applet is hard wired to use the java applet +# served from the University of Rochester WeBWorK machine. +# It is possible to set this up so that the java applet is served +# from any machine +# For details use the Feedback button to contact the authors of WeBWorK + +BEGIN_TEXT +This is a lite applet designed by Frank Wattenberg. +$BR +\{htmlLink( '/webwork2_course_files/demoCourse/live_map_instructions.html ', +'Instructions for using the map',' target="intro" ' )\} +$HR +END_TEXT +$appletText = +appletLink( +q! archive="/courses/system_html/applets/Image_and_Cursor_All/Image_and_Cursor.jar" +code="Image_and_Cursor" width = 500 height = 458 +!, +q!Your browser does not support Java, so nothing is displayed. + <param name = "applet_width" value = "500"> + <param name = "applet_height" value = "458"> + <param name = "image_width" value = "351"> + <param name = "image_height" value = "378"> + <param name = "backdrop_filename" value = "/courses/system_html/applets/Image_and_Cursor_All/AF-MAP.JPG"> + <param name = "display_placement" value = "1"> + <param name = "display_sw" value = "0"> +! +); +sub dist { + my $ra_pt1 = shift; + my $ra_pt2 =shift; + my $conversion = 300 /(145 - 72); # number of km per pixel + return $conversion* sqrt( ($ra_pt1->[0] - $ra_pt2->[0])**2 + ($ra_pt1->[1] - $ra_pt2->[1])**2); +} + +$kandahar = [132,101]; +$kabul = [209,185]; +$mazur_e_sharif = [170, 243]; +$shindand = [46, 155]; + +$questions = EV3( +"$PAR How far is it from Kandahar to Kabul? " , ans_rule(30), +" $PAR How far is it from Kabul to Mazar-e-Sharif? ", ans_rule(30), +" $PAR How far is it from Kandahar to Shindand? " , ans_rule(30), +); +#TEXT( +#begintable(2), +#row( $appletText, $questions), +#endtable() +#); +TEXT($appletText, $questions); +ANS(num_cmp(dist($kandahar,$kabul), reltol => 3, units=>'km')); +ANS(num_cmp(dist($kabul, $mazur_e_sharif), reltol => 3, units=>'km')); +ANS(num_cmp(dist($kandahar,$shindand), reltol => 3, units=>'km')); + + + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/sample_units_ans.pg @@ -0,0 +1,41 @@ +DOCUMENT(); +loadMacros( "PGbasicmacros.pl", + "PGauxiliaryFunctions.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +TEXT(beginproblem()); + +$showPartialCorrectAnswers = 1; +$showHint =0; + +$fx = random( 2.1, 6.0 , 0.1) ; +$fy = random( 3.1, 8.0 , 0.1) ; +$ansxy = sqrt($fx * $fx + $fy * $fy); +$anscm = $ansxy*100; + +BEGIN_TEXT +This problem demonstrates how WeBWorK handles +numerical answers involving units. WeBWorK can handle all units that +are used in elementary physics courses. +See \{ htmlLink("http://webwork.math.rochester.edu/spring00-phy121/help_units.html","answers with units") \} +for more details. $PAR + +Two perpendicular sides of a triangle are $fx m and +$fy m long respectively. +What is the length of the third side of the triangle? $BR$BR +You can answer this in terms of m's, cm's, km's, in's, ft, etc. but you must enter the units. $BR$BR +Check "Show Hint" and then "Submit Answer" if you don't remember the Pythagorean theorem. +END_TEXT + +HINT(EV3(<<'EOT')); +Remembering the Pythagorean theorem \( A^2 +B^2 = C^2 \), you can enter +sqrt($fx^2 + $fy^2) m or \{spf($ansxy, "%0.2f" )\} m or \{spf($anscm, "%0.2f" )\} cm or ... +EOT + +BEGIN_TEXT +\{ans_rule(40) \} +END_TEXT +ANS(num_cmp("$ansxy", units => 'm')); +ENDDOCUMENT() --- /dev/null +++ courses/modelCourse/templates/setDemo/srw1_9_4.pg @@ -0,0 +1,112 @@ +##DESCRIPTION +## find distance between two points, find coordinates of the midpoint of +## a line segment connecting them +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'coordinate geometry', 'distance', 'midpoint') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGauxiliaryFunctions.pl" +); + +TEXT(&beginproblem); + +$showPartialCorrectAnswers = 1; + +#install_problem_grader(~~&std_problem_grader); ##uncomment to use std grader +#install_problem_grader(~~&custom_problem_grader); ##uncomment to use custom grader + + +$x1 = random(1,5,1); +$y1 = random(-5,-1,1); +$x2 = random(-10,-3,1); +$y2 = random(-9,-2,1); +$len1 = sqrt(($x1-$x2)**2 + ($y1-$y2)**2); +$midx = ($x1+$x2)/2; +$midy = ($y1+$y2)/2; + +BEGIN_TEXT +Consider the two points \( ($x1 ,$y1 )\) and \( ($x2 ,$y2 )\). +The distance between them is:$BR +\{ans_rule(30) \} +$BR +END_TEXT + +$ans = $len1; +&ANS(std_num_cmp($ans)); + +BEGIN_TEXT +The x co-ordinate of the midpoint of the line +segment that joins them is:\{ans_rule(20) \} +$BR +END_TEXT +$ans = $midx; +&ANS(std_num_cmp($ans)); + +BEGIN_TEXT +The y co-ordinate of the midpoint of the line segment that joins them is: +\{ans_rule(20) \} +$BR +END_TEXT +$ans = $midy; +&ANS(std_num_cmp($ans)); + + +sub custom_problem_grader { + my $rh_evaluated_answers = shift; + my $rh_problem_state = shift; + my %form_options = @_; + my %evaluated_answers = %{$rh_evaluated_answers}; + # The hash $rh_evaluated_answers typically contains: + # 'answer1' => 34, 'answer2'=> 'Mozart', etc. + + # By default the old problem state is simply passed back out again. + my %problem_state = %$rh_problem_state; + + + # %form_options might include + # The user login name + # The permission level of the user + # The studentLogin name for this psvn. + # Whether the form is asking for a refresh or is submitting a new answer. + + # initial setup of the answer + my $total=0; + my %problem_result = ( score => 0, + errors => '', + type => 'custom_problem_grader', + msg => 'Part 1 is worth 50% and parts 2 and 3 are worth 25% each.', + ); + + # Return unless answers have been submitted + unless ($form_options{answers_submitted} == 1) { + return(~~%problem_result,~~%problem_state); + } + # Answers have been submitted -- process them. + + $total += .5*($evaluated_answers{'AnSwEr1'}->{score}); + $total += .25*($evaluated_answers{'AnSwEr2'}->{score}); + $total += .25*($evaluated_answers{'AnSwEr3'}->{score}); + + + $problem_result{score} = $total; + # increase recorded score if the current score is greater. + $problem_state{recorded_score} = $problem_result{score} if $problem_result{score} > $problem_state{recorded_score}; + + + $problem_state{num_of_correct_ans}++ if $total == 1; + $problem_state{num_of_incorrect_ans}++ if $total < 1 ; + (~~%problem_result, ~~%problem_state); + +} + + +ENDDOCUMENT(); # This should be the last executable line in the problem. + + --- /dev/null +++ courses/modelCourse/templates/setDemo/liteApplet2.pg @@ -0,0 +1,74 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +$showPartialCorrectAnswers = 1; +TEXT(beginproblem()); + + +BEGIN_TEXT +This is a lite applet designed by Frank Wattenberg. +$BR +\{htmlLink( '/webwork2_course_files/demoCourse/live_map_instructions.html ', +'Instructions for using the map',' target="intro" ' )\} +$HR +END_TEXT +TEXT( +appletLink( +q! archive="/courses/system_html/applets/Image_and_Cursor_All/Image_and_Cursor.jar" +code="Image_and_Cursor" width = 500 height = 458 +!, +q!Your browser does not support Java, so nothing is displayed. + <param name = "applet_width" value = "500"> + <param name = "applet_height" value = "458"> + <param name = "image_width" value = "351"> + <param name = "image_height" value = "378"> + <param name = "backdrop_filename" value = "/courses/system_html/applets/Image_and_Cursor_All/AF-MAP.JPG"> + <param name = "display_placement" value = "1"> + <param name = "display_sw" value = "0"> +! +), +); +sub dist { + my $ra_pt1 = shift; + my $ra_pt2 =shift; + $conversion = 300 /(145 - 72); # number of km per pixel + return $conversion * sqrt( ($ra_pt1->[0] - $ra_pt2->[0])**2 + ($ra_pt1->[1] - $ra_pt2->[1])**2); +} +@cities = ( + { name => 'Kandahar', location => [132,101] }, + { name => 'Kabul', location => [209,185] }, + { name => 'Mazur e Sharif', location => [170, 243] }, + { name => 'Shindand', location => [46, 155] }, + { name => 'Zaranj', location => [39, 93] } +); +@index = NchooseK(scalar(@cities), 3 ); +sub cityName { + my $index = shift ; + $cities[$index -1]->{name}; +} +sub cityLoc { + my $index = shift; + $cities[$index-1]->{location}; +} + +$conversion = 300 /(145 - 72); # number of km per pixel +BEGIN_TEXT +$PAR +How far is it from \{cityName($index[1])\} to \{cityName($index[2])\}? \{ans_rule(30)\} +$PAR +How far is it from \{cityName($index[1])\} to \{cityName($index[3])\}? \{ans_rule(30)\} +$PAR +How far is it from \{cityName($index[2])\} to \{cityName($index[3])\}? \{ans_rule(30)\} +END_TEXT + +ANS(num_cmp(dist(cityLoc($index[1]),cityLoc($index[2])), reltol=>3, units=>'km')); +ANS(num_cmp(dist(cityLoc($index[2]), cityLoc($index[2])), reltol=>3, units=>'km')); +ANS(num_cmp(dist(cityLoc($index[2]),cityLoc($index[2])), reltol=>3, units=>'km')); + + + +ENDDOCUMENT(); \ No newline at end of file |