Editing USub Applet Sample Problem

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 191: Line 191:
 
<ans func='' lower='' upper ='' theValue='' /></code> <code><br>
 
<ans func='' lower='' upper ='' theValue='' /></code> <code><br>
 
<usub ufunc='x+x^2'/></xml>});</code>
 
<usub ufunc='x+x^2'/></xml>});</code>
<br> configure the applet. The configuration of the applet is done in xml. The applet expects to be told the integrand of the original integral (func='(1+2*x)*cos(x+x^2)'), the lower limit of integration (lower='0'), the upper limit (upper='$b'), the horizontal and vertical grid spacing (xgrid='1' ygrid='$b'), the dimensions of the two graph windows (,code><win xmin='-3' xmax='$ubig' ymin='$vsmall' ymax='$vbig'
+
<br> configure the applet. The configuration of the applet is done in xml. The hintState is set to the variable <code>$hintState</code>, the question type is set to <code>$qtype</code> and the problem seed is the WeBWorK environmental variable <code>$problemSeed</code>. The variables <code>$x1</code>, <code>$x2</code>, <code>$x3</code> and <code>$x4</code> are also passed to the applet.
umin='-3' umax='$ubig' vmin='$vsmall' vmax='$vbig' /></code>) and the u-substitution the student is to use (<code><usub ufunc='x+x^2'/></code>).
+
</p><br>
  +
<p>The code <code>qq{ </code><code>
  +
getQE("inc").value=getApplet("$appletName").get_interval_info("increasing");</code><code>
  +
getQE("dec").value=getApplet("$appletName").get_interval_info("decreasing");</code><code>
  +
getQE("constant").value=getApplet("$appletName").get_interval_info("constant");</code><code>
  +
}</code>
  +
is called when the 'Submit Answers' button in the problem is pressed. There is an external interface function designed inside the applet. The function name is 'get_interval_info'. These lines of code call the function with javascript. <code>get_interval_info</code>, takes one argument: a string value. The string may be any of the following alternatives: "increasing", "decreasing", "constant", "up", "down" or "straight". <code>get_interval_info</code> returns a list of open intervals with the specified characteristic. The line <code>
  +
getQE("inc").value=getApplet("$appletName").get_interval_info("increasing");</code> gets the value of the function <code>get_interval_info</code> and stores this value in the hidden javascript form field named "inc". Note that although we have carriage returns after each of the 'getQE' statements, you should <em>not</em> have these carriage returns in your pg file. They are here so that the text line will allow display of the code next to the explanation. You will get error messages if you have the carriage returns in your pg file.</p>
  +
<p>
  +
The hidden form fields are created in the code block:
  +
<code>
  +
BEGIN_TEXT</code><code>
  +
<input type="hidden" name="inc" id="inc" /></code><code>
  +
<input type="hidden" name="dec" id="dec" /></code><code>
  +
<input type="hidden" name="constant" id="constant" /></code><code>
  +
END_TEXT
  +
</code>
  +
</p><br>
  +
<p>
  +
The applet is configured in the code line:
  +
<code>$applet->configuration(qq{<xml><hintState>$hintState</hintState><qtype>limits</qtype>
  +
<seed>$problemSeed</seed><xlist x1='$x1' x2='$x2' x3='$x3' x4='$x4' /></xml>});</code> and the similar line below it.
  +
The variables $hintState, $problemSeed, and $x1, $x2, $x3, and $x4 are defined within WeBWorK and used by the applet to set the problem up.
 
</p><br>
 
</p><br>
<p>The code <code>qq{getQE("answerBox").value=getApplet("$appletName").getAnswer() }</code>
 
is called when the 'Submit Answers' button in the problem is pressed. This will call the getAnswer function which will return the contents of the four answer blanks in the applet.</p>
 
<br>
 
 
<p>
 
<p>
 
<code>TEXT( MODES(TeX=>'object code', HTML=>$applet->insertAll(
 
<code>TEXT( MODES(TeX=>'object code', HTML=>$applet->insertAll(

Please note that all contributions to WeBWorK_wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see The WeBWorK Project wiki:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)