File:  [LON-CAPA] / doc / homework / homework5.html
Revision 1.13: download - view: text, annotated - select for diffs
Thu Mar 28 22:55:35 2002 UTC (22 years, 1 month ago) by albertel
Branches: MAIN
CVS tags: stable_2002_april, HEAD
- updated <randomlist> description

    1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    2: <html>
    3:   <head>
    4:     <title>LON-CAPA Homework System</title>
    5:   </head>
    6: 
    7:   <body bgcolor="white">
    8:     <h1>LON-CAPA Homework System</h1>
    9: 
   10:     <h2>Tags</h2>
   11:     <ul>
   12:       <li>
   13: 	Response tags
   14: 	<p>
   15: 	  Arguments for all response tags
   16: 	</p>
   17: 	<ul>
   18: 	  <li>
   19: 	    <i>ID</i>, if this isn't set it will be set during
   20: 	    the publication step. It is used to assign parameters names
   21: 	    in a way that can be tracked if an instructor modifies
   22: 	    things by hand.
   23: 	  </li>
   24: 	  <li>
   25: 	    <i>name</i> optional, if set, it will be used by the
   26: 	    resource assembly tool when one is modifying parameters.
   27: 	    </li>
   28: 	</ul>
   29: 	<p>
   30: 	  Implemented response tags
   31: 	</p>
   32: 	<ul>
   33: 	  <li>
   34: 	    <b>&lt;responseparam&gt;</b> if it appears it should be
   35: 	    inside of a &lt;*response&gt; tag, defines an externally
   36: 	    adjustable parameter for this question. Arguments:
   37: 	    <ul>
   38: 	      <li>
   39: 		<i>default</i> required, specifies a default value for
   40: 		the parameter
   41: 	      </li>
   42: 	      <li>
   43: 		<i>name</i> required, specifies an internal name for
   44: 		the parameter
   45: 	      </li>
   46: 	      <li>
   47: 		<i>type</i> required specifies the type of parameter,
   48: 		one of "tolerance", "int", "float", "string", "date"
   49: 		(configuration of paramters is handled by
   50: 		lonparmset.pm and parameter.html)
   51: 	      </li>
   52: 	      <li>
   53: 		<i>description</i> a string describing the parameter,
   54: 		this is what is used to talk about a parameter outside
   55: 		of a problem
   56: 	      </li>
   57: 	    </ul>
   58: 	  </li>
   59: 	  <li>
   60: 	    <b>&lt;numericalresponse&gt;</b> implements a numerical
   61: 	    answer, it needs an internal <b>&lt;textline&gt;</b> for
   62: 	    the response to go in. It checks all styles of numerical
   63: 	    supported in CAPA. Possible args are:
   64: 	    <ul>
   65: 	      <li><i>answer</i> required, specifies the correct answer, may be either a perl list or scalar</li>
   66: 	      <li><i>units</i> optional, specifies unit of correct answer, CAPA style</li>
   67: 	    </ul>
   68: 	  </li>
   69: 	  <li>
   70: 	    <b>&lt;stringresponse&gt;</b> implements a string answer,
   71: 	    it needs an internal <b>&lt;textline&gt;</b> for the
   72: 	    response to go in. It can check the string for either case
   73: 	    or order.
   74: 	    <ul>
   75: 	      <li><i>answer</i> required, specifies the correct answer, may be either a perl list or scalar</li>
   76: 	      <li><i>type</i> optional, CAPA style str args, cs/ci/mc
   77: 		<ul>
   78: 		  <li>cs - case senesitive, order important</li>
   79: 		  <li>ci - case insenesitive, order important</li>
   80: 		  <li>mc - case insenesitive, order unimportant</li>
   81: 		</ul>
   82: 	      </li>
   83: 	    </ul>
   84: 	  <li>
   85: 	    <b>&lt;essayresponse&gt;</b> implements a ungraded large
   86: 	    text response, it need an internal <b>&lt;textarea&gt;</b>
   87: 	    for the response to go in.
   88: 	  </li>
   89: 	  <li>
   90: 	    <b>&lt;imageresponse&gt;</b> implements a image click
   91: 	    style image submission, uses the foil structure tags <a
   92: 	    href="#foil">below</a>. Additional tags that should appear
   93: 	    in a &lt;foil&gt; are:
   94: 	    <ul>
   95: 	      <li><b>&lt;image&gt;</b> required, the contained text
   96: 	      specifies a published graphical resource that is the
   97: 	      image used, should only appear once per foil</li>
   98: 	      <li><b>&lt;rectangle&gt;</b> required, the contained text
   99: 	      specifies a rectangular area that is correct, should
  100: 	      look like (1,2)-(3,4), at least 1 required</li>
  101: 	      <li><b>&lt;text&gt;</b> required, the contained text is
  102: 	      printed on top of the image.</li>
  103: 	    </ul>
  104: 	  </li>
  105: 	  <li>
  106: 	    <b>&lt;optionresponse&gt;</b> implements a "select from
  107: 	    these choices" style question, the choices are specified
  108: 	    by the instructor, it uses the foil structure tags <a
  109: 	    href="#foil">below</a> with this additional args: 
  110: 	    <ul>
  111: 	      <li>
  112: 		<b>&lt;foilgroup&gt;</b> is required to have
  113: 		<i>options</i> which should be a perl list of possible
  114: 		options for the student.
  115: 	      </li>
  116: 	    </ul>
  117: 	  </li>
  118: 	  <li>
  119: 	    <b>&lt;radiobuttonresponse&gt;</b> implements a true / false
  120: 	    style question with 1 correct answer.it uses the foil
  121: 	    structure tags <a href="#foil">below</a> but the
  122: 	    <i>value</i> of a &lt;foil&gt;can only be "true" or
  123: 	    "false" or "unused"
  124: 	  </li>
  125: 	  <li>
  126: 	    <b>&lt;dataresponse&gt;</b> implements a straight data
  127: 	    storage entry idea, needs and interveing input tag like
  128: 	    &lt;textline&gt; to work correctly.<br>
  129: 	    Arguments:
  130: 	    <ul>
  131: 	      <li>
  132: 		<i>name</i> internal name for the value, it will have
  133: 		the part id and respose id added on to it
  134: 	      </li>
  135: 	      <li>
  136: 		<i>type</i> type of data stored in this response
  137: 		field, should be one of the types supported by
  138: 		parameter.html
  139: 	      </li> 
  140: 	      <li>
  141: 		<i>display</i> a string that will be used to describe
  142: 		the field when interfacing with humans
  143: 	      </li>
  144: 	    </ul>
  145: 	  <li>
  146: 	</ul>
  147: 	<li>
  148: 	<a name="foil">Foil Structure Tags</a>
  149: 	<p>
  150: 	  All tags that implement a foil structure have an optional
  151: 	  arg of <i>max</i> that controls the maximum number of total
  152: 	  foils to show.
  153: 	</p>
  154: 	<ul>
  155: 	  <li>
  156: 	    <b>&lt;foilgroup&gt;</b> required, must be the tag that
  157: 	    surrounds all foil definitions	    
  158: 	  </li>
  159: 	  <li>
  160: 	    <b>&lt;foil&gt;</b> required, all data inside is a possible foil
  161: 	  </li>
  162: 	  <li>
  163: 	    <b>&lt;conceptgroup&gt;</b> optional, surrounds a
  164: 	    collection of &lt;foil&gt;, when a problem is displayed
  165: 	    only one of the contained &lt;foil&gt;is selected for
  166: 	    display. It receives one required argument
  167: 	    <i>concept</i>.
  168: 	  </li>
  169: 	</ul>
  170:       </li>
  171:       <li>
  172: 	Hint structure
  173: 	<p>
  174: 	  All of these tags must appear inside a <b>&lt;*response&gt;</b> tag.
  175: 	</p>
  176: 	<ul>
  177: 	  <li>
  178: 	    <b>&lt;hintgroup&gt;</b> Tag that surrounds all of a hint.
  179: 	  </li>
  180: 	  <li>
  181: 	    <b>&lt;hintpart&gt;</b> required, Tag to implement
  182: 	    conditional hints. It has a required argument
  183: 	    <i>on</i>. When a &lt;*hint&gt; tag named the same as the
  184: 	    value the </i>on</i> attribute evaluates to be correct the
  185: 	    &lt;hintpart&gt; will show. If no other &lt;hintpart&gt;
  186: 	    are to show then all hintparts with a <i>on</i> of
  187: 	    "default" will show
  188: 	  </li>
  189: 	  <li>
  190: 	    <b>&lt;numericalhint&gt;</b> has all the arguments that
  191: 	    &lt;numericalresponse&gt;, does and the required attribute
  192: 	    <i>name</i> which should be set to the value of which
  193: 	    &lt;hintpart&gt; will be shown. 
  194: 	  </li>
  195: 	</ul>
  196:       </li>
  197:       <li>
  198: 	Input Tags
  199: 	<p>
  200: 	  This group of tags implement a mechanism for getting data
  201: 	  for students, they will usually be used by a
  202: 	  &lt;*response&gt;.
  203: 	</p>
  204: 	<ul>
  205: 	  <li>
  206: 	    <b>&lt;textarea&gt;</b> creates a Large text input box, If
  207: 	    data appears between the start and end tags, the data will
  208: 	    appear i the textarea if the student has not yet made a
  209: 	    submission. Additionally it takes two arguments <i>rows</i>
  210: 	    and <i>cols</i> which control the height and width of the
  211: 	    area respectively. It defaults to 10 and 80.
  212: 	  </li>
  213: 	  <li>
  214: 	    <b>&lt;textline&gt;</b> creates a single line of input
  215: 	    element, it accepts 1 argument <i>size</i> which controls
  216: 	    the width on the textline, it defaults to 20.
  217: 	  </li>
  218: 	</ul>
  219:       </li>
  220:       <li>
  221: 	Output Tags
  222: 	<p>
  223: 	  This group of tags generate useful pieces of output.
  224: 	</p>
  225: 	<ul>
  226: 	  <li>
  227: 	    <b>&lt;displayduedate&gt;</b> this will insert the current
  228: 	    duedate if one is set into the document. It is generated
  229: 	    to be inside a table of 1x1 elements
  230: 	  </li>
  231: 	  <li>
  232: 	    <b>&lt;displaytitle&gt;</b> this will insert the title of
  233: 	    the problem from the metadata of the problem
  234: 	  </li>
  235: 	  <li>
  236: 	    <b>&lt;window&gt;</b> the text in between is put in a
  237: 	    popup javascript window
  238: 	  </li>
  239: 	  <li>
  240: 	    <b>&lt;m&gt;</b> the inside text is LaTeX, and is
  241: 	    converted to HTML (or MathML) on the fly, if the argument
  242: 	    <i>eval</i> is set to "on" the intervening text will have
  243: 	    a perl var expansion done to it before being converted.
  244: 	  </li>
  245: 	</ul>
  246:       </li>
  247:       <li>
  248: 	Scripting
  249: 	<p>
  250: 	  These tags allow the document to behave programatically
  251: 	</p>
  252: 	<ul>
  253: 	  <li>
  254: 	    <b>&lt;display&gt;</b> the intervening perl script is
  255: 	    evaluated in the safe space and the return value of the
  256: 	    script replaces the entire tag
  257: 	  </li>
  258: 	  <li>
  259: 	    <b>&lt;import&gt;</b> causes the parse to read in the file
  260: 	    named in the body of the tag and parse it as if the entire
  261: 	    text of the file had existed at location of the tag
  262: 	  </li>
  263: 	  <li>
  264: 	    <b>&lt;parserlib&gt;</b> the enclosed filename contains
  265: 	    definitions for new tags
  266: 	  </li>
  267: 	  <li>
  268: 	    <b>&lt;script&gt;</b> if the argument <i>type</i> is set
  269: 	    to "loncapa/perl" the enclosed data is a perl script which
  270: 	    is evaluated inside the perl Safe space. The return value
  271: 	    of the script is ignored.
  272: 	  </li>
  273: 	  <li>
  274: 	    <b>&lt;scriptlib&gt;</b> the enclosed filename contains
  275: 	    perl code to run in the safe space
  276: 	  </li>
  277: 	  <li>
  278: 	    <b>&lt;block&gt;</b> has a required argument
  279: 	    <i>condition</i> that is evaluated, it the condition is
  280: 	    true everything inside the tag is evaluated, if it is false
  281: 	    everything inside the block tag is skipped
  282: 	  </li>
  283: 	  <li>
  284: 	    <b>&lt;notsolved&gt;</b> everything inside the tag is
  285: 	    skipped if the problem is "solved"
  286: 	  </li>
  287: 	  <li>
  288: 	    <b>&lt;postanswerdate&gt;</b> everything inside the tag is
  289: 	    skipped if the problem is before the answer date
  290: 	  </li>
  291: 	  <li>
  292: 	    <b>&lt;preduedate&gt;</b> everything inside the tag is
  293: 	    skipped if the problem is after the due date
  294: 	  </li>
  295: 	  <li>
  296: 	    <b>&lt;randomlist&gt;</b> the enclosed tags are parsed in
  297: 	    a stable random order, optional argument <i>show</i>
  298: 	    restricts the number of tags indie that are actually
  299: 	    parsed the no more than <i>show</i>.
  300: 	  </li>
  301: 	  <li>
  302: 	    <b>&lt;solved&gt;</b> everything inside the tag is
  303: 	    skipped if the problem is "not solved"
  304: 	  </li>
  305: 	  <li>
  306: 	    <b>&lt;while&gt;</b> implements a while loop, required
  307: 	    argument <i>condition</i> is a perl scriptlet that when
  308: 	    evaluated results in a true or false value, on true the
  309: 	    entirety of the text between the whiles is parsed. The
  310: 	    condition is tested again, etc. If false it goes to the
  311: 	    next node in the parse.
  312: 	  </li>
  313: 	</ul>
  314:       </li>
  315:       <li>
  316: 	Structure Tags
  317: 	<p>
  318: 	  These tags give the problem a structure and take care of the
  319: 	  recording of data and giving the student messages.
  320: 	</p>
  321: 	<ul>
  322: 	  <li>
  323: 	    <b>&lt;problem&gt;</b> must be the first tag in the file,
  324: 	    this tag sets up the header of the webpage and generates
  325: 	    the submit buttons, it also handles due dates properly
  326: 	  </li>
  327: 	  <li>
  328: 	    <b>&lt;part&gt;</b> must be below &lt;problem&gt; if it is
  329: 	    going to be used. It does many of the same tasks as
  330: 	    &lt;problem&gt; but allows multiple separate problems to
  331: 	    exist in a single file.
  332: 	  </li>
  333: 	  <li>
  334: 	    <b>&lt;startouttext&gt;</b><b>&lt;endouttext&gt;</b> these
  335: 	    tags are somewhat special, they must have no internal text
  336: 	    and occur in pairs. Their use is to mark up the problem so
  337: 	    the web editor knows what sections should be edited in a
  338: 	    plain text block on the web.
  339: 	  </li>
  340: 	</ul>
  341:       </li>
  342:     </ul>
  343:     <h2>&lt;script&gt; Functions</h2>
  344:     <p> 
  345:       A list of functions that have been written that are available in 
  346:       the Safe space scripting environment inside a problem. 
  347:     </p>
  348:     <ul>
  349:       <li>sin(x), cos(x), tan(x)</li>
  350:       <li>asin(x), acos(x), atan(x), atan2(y,x)</li>
  351:       <li>log(x), log10(x)</li>
  352:       <li>exp(), pow(x,y), sqrt(x)</li>
  353:       <li>abs(x), sgn(x)</li>
  354:       <li>erf(x), erfc(x)</li>
  355:       <li>ceil(x), floor(x)</li>
  356:       <li>min(...), max(...)</li>
  357:       <li>factorial(n)</li>
  358:       <li>N%M</li>
  359:       <li>sinh(x), cosh(x), tanh(x)</li>
  360:       <li>asinh(x), acosh(x), atanh(x)</li>
  361:       <li>roundto(x,n)</li>
  362:       <li>web("a","b","c") or web(a,b,c)</li>
  363:       <li>html("a") or html(a)</li>
  364:       <li>j0(x), j1(x), jn(n,x), jv(y,x)</li>
  365:       <li>y0(x), y1(x), yn(n,x), yv(y,x)</li>
  366:       <li>random</li>
  367:       <li>choose</li>
  368:       <li>tex("a","b") or tex(a,b)</li>
  369:       <li>var_in_tex(a)</li>
  370:       <li>to_string(x), to_string(x,y)</li>
  371:       <li>class(), section()</li>
  372:       <li>name(), student_number()</li>
  373:       <li>open_date(), due_date(), answer_date()</li>
  374:       <li>sub_string()</li>
  375:       <li>array_moments(array)</li>
  376:       <li>format(x,y)</li>
  377:       <li>map(...)</li>
  378:       <li>caparesponse_check</li>
  379:       <li>caparesponse_check_list</li>
  380:     </ul>
  381: <!-- Table inserted by H. K. Ng 
  382:     06/01/2001
  383:     06/12/2001
  384: -->
  385:     <p> 
  386:       Detailed descriptions of each function and comparison with CAPA.
  387:     </p>
  388: 
  389:   <table border=1>
  390:       <tr>
  391:             <td valign="top"><b>CAPA Functions</b</td>
  392:             <td valign="top"><b>LON-CAPA</b</td>
  393:             <td valign="top"><b>Descriptions</b</td>
  394:             <td valign="top"><b>Differences (if any)</b</td>
  395:      </tr>
  396: 
  397:     <tr>
  398:              <td valign="top">sin(x), cos(x), tan(x)</td>
  399:              <td valign="top">&amp;sin($x), &amp;cos($x), &amp;tan($x)</td>
  400:              <td valign="top">Trigonometric functions where x is in radians. $x
  401:          can be a pure number, i.e., you can call &amp;sin(3.1415)</td>
  402:               <td valign="top">&nbsp</td>
  403:     </tr>
  404: 
  405:     <tr>
  406:              <td valign="top">asin(x), acos(x), atan(x), atan2(y,x)</td>
  407:              <td valign="top">&amp;asin($x), &amp;acos($x), &amp;atan($x), &amp;atan2($y,$x)</td>
  408:              <td valign="top">Inverse trigonometric functions. Return value is
  409:                  in radians. For asin and acos the value of x must be between -1 and 1.
  410:                  The atan2 returns a value between -pi and pi the sign of which is determined
  411:                  by y. $x and $y can be pure numbers</td>
  412:              <td valign="top">&nbsp;</td>
  413:     </tr>
  414: 
  415:     <tr>
  416:              <td valign="top">log(x), log10(x)</td>
  417:              <td valign="top">&amp;log($x), &amp;log10($x)</td>
  418:              <td valign="top">Natural and base-10 logarithm. $x can be a pure number</td>
  419:              <td valign="top">&nbsp;</td>
  420:     </tr>
  421: 
  422:     <tr>
  423:              <td valign="top">exp(x), pow(x,y), sqrt(x)</td>
  424:              <td valign="top">&amp;exp($x), &amp;pow($x,$y), &amp;sqrt($x)</td>
  425:              <td valign="top">Exponential, power and square root, i.e.,e<sup>x</sup>, x<sup>y</sup> and /x.                  $x and $y can be pure numbers</td>
  426: 
  427:              <td valign="top">&nbsp;</td>
  428:     </tr>
  429: 
  430:     <tr>
  431:              <td valign="top">abs(x), sgn(x)</td>
  432:              <td valign="top">&amp;abs($x), &amp;sgn($x)</td>
  433:              <td valign="top">Abs takes the absolute value of x while sgn(x) returns
  434:                  1, 0 or -1 depending on the value of x. For x>0, sgn(x) = 1, for x=0, sgn(x)
  435:                  = 0 and for x&lt;0, sgn(x) = -1. $x can be a pure number</td>
  436:              <td valign="top">&nbsp;</td>
  437:     </tr>
  438: 
  439:     <tr>
  440:              <td valign="top">erf(x), erfc(x)</td>
  441:              <td valign="top">&amp;erf($x), &amp;erfc($x)</td>
  442:              <td valign="top">Error function.&nbsp; erf = 2/sqrt(pi) integral (0,x) e<sup>t-sq</sup> and <i>                 erfx(x)</i> = 1.0 - <i>erf(x)</i>.&nbsp; $x can be a pure number</td>
  443:              <td valign="top">&nbsp;</td>
  444:     </tr>
  445: 
  446:     <tr>
  447:              <td valign="top">ceil(x), floor(x)</td>
  448:              <td valign="top">&amp;ceil($x), &amp;floor($x)</td>
  449:              <td valign="top">Ceil function returns an integer rounded up whereas
  450:                  floor function returns and integer rounded down. If x is an integer than
  451:                  it returns the value of the integer. $x can be a pure number</td>
  452:              <td valign="top">&nbsp;</td>
  453:     </tr>
  454: 
  455:     <tr>
  456:              <td valign="top">min(...), max(...)</td>
  457:              <td valign="top">&amp;min(...), &amp;max(...)</td>
  458:              <td valign="top">Returns the minimum/ maximum value of a list of
  459:                  arguments if the arguments are numbers. If the arguments are strings then
  460:                  it returns a string sorted according to the ASCII codes</td>
  461:              <td valign="top">&nbsp;</td>
  462:     </tr>
  463: 
  464:     <tr>
  465:              <td valign="top">factorial(n)</td>
  466:              <td valign="top">&amp;factorial($n)</td>
  467:              <td valign="top">Argument (n) must be an integer else it will round
  468:                  down. The largest value for n is 170. $n can be a pure number</td>
  469:              <td valign="top">&nbsp;</td>
  470:     </tr>
  471: 
  472:     <tr>
  473:              <td valign="top">N%M</td>
  474:              <td valign="top">$N%$M</td>
  475: 
  476:              <td valign="top">N and M are integers and returns the remainder (in
  477:                  integer) of N/M. $N and $M can be pure numbers</td>
  478:              <td valign="top">&nbsp;</td>
  479:     </tr>
  480: 
  481:     <tr>
  482:              <td valign="top">sinh(x), cosh(x), tanh(x)</td>
  483:              <td valign="top">&amp;sinh($x), &amp;cosh($x), &amp;tanh($x)</td>
  484:              <td valign="top">Hyperbolic functions. $x can be a pure number</td>
  485:              <td valign="top">&nbsp;</td>
  486:     </tr>
  487: 
  488:     <tr>
  489:              <td valign="top">asinh(x), acosh(x), atanh(x)</td>
  490:              <td valign="top">&amp;asinh($x), &amp;acosh($x), &amp;atanh($x)</td>
  491:              <td valign="top">Inverse hyperbolic functions. $x can be a pure number</td>
  492:              <td valign="top">&nbsp;</td>
  493:     </tr>
  494: 
  495:     <tr>
  496:              <td valign="top">/DIS($x,"nn")</td>
  497:              <td valign="top">&amp;format($x,"nn")</td>
  498:              <td valign="top">Display or format $x as nn where nn is nF or nE and n is an integer.</td>
  499:              <td valign="top">&nbsp;The difference is obvious.</td>
  500:     </tr>
  501: 
  502:     <tr>
  503:              <td valign="top">roundto(x,n)</td>
  504:              <td valign="top">&amp;roundto($x,$n)</td>
  505:              <td valign="top">Rounds a real number to n decimal points. $x and
  506:                  $n can be pure numbers</td>
  507:              <td valign="top">&nbsp;</td>
  508:     </tr>
  509: 
  510:     <tr>
  511:              <td valign="top">web("a","b","c") or web(a,b,c)</td>
  512:              <td valign="top">&amp;web("a","b","c") or &amp;web($a,$b,$c)</td>
  513:              <td valign="top">Returns either a, b or c depending on the output
  514:                  medium. a is for plain ASCII, b for tex output and c for html output</td>
  515:              <td valign="top">&nbsp</td>
  516:     </tr>
  517: 
  518:     <tr>
  519:              <td valign="top">html("a") or html(a)</td>
  520:              <td valign="top">&amp;html("a") or &amp;html($a)</td>
  521:              <td valign="top">Output only if the output mode chosen is in html
  522:                  format</td>
  523:              <td valign="top">&nbsp;</td>
  524:     </tr>
  525: 
  526:     <tr>
  527:              <td valign="top">jn(m,x)</td>
  528:              <td valign="top">&amp;j0($x), &amp;j1($x), &amp;jn($m,$x), &amp;jv($y,$x)</td>
  529:              <td valign="top">Bessel functions of the first kind with orders 0,
  530:                  1 and m respectively. For jn(m,x), m must be an integer whereas for jv(y,x),
  531:                  y is real. $x can be a pure number. $m must be an integer and can be a
  532:                  pure integer number. $y can be a pure real number</td>
  533:              <td valign="top">In CAPA, j0, j1 and jn are contained in one function,
  534:                  jn(m,x) where m takes the value of 0, 1 or 2. jv(y,x) is new to LON-CAPA.</td>
  535:     </tr>
  536: 
  537:     <tr>
  538:              <td valign="top">yn(m,x)</td>
  539:              <td valign="top">&amp;y0($x), &amp;y1($x), &amp;yn($m,$x), &amp;yv($y,$x)</td>
  540:              <td valign="top">Bessel functions of the second kind with orders
  541:                  0, 1 and m respectively. For yn(m,x), m must be an integer whereas for
  542:                  yv(y,x), y is real. $x can be a pure number. $m must be an integer and
  543:                  can be a pure integer number. $y can be a pure real number</td>
  544:              <td valign="top">In CAPA, y0, y1 and yn are contained in one function,
  545:                  yn(m,x) where m takes the value of 0, 1 or 2. yv(y,x) is new to LON-CAPA.</td>
  546:     </tr>
  547: 
  548:     <tr>
  549:              <td valign="top">random(l,u,d)</td>
  550:              <td valign="top">&amp;random($l,$u,$d)</td>
  551:              <td valign="top">Returns a uniformly distributed random number between
  552:                  the lower bound, l and upper bound, u in steps of d. $l, $u and $d can
  553:                  be pure numbers</td>
  554:              <td valign="top">In CAPA, all the 3 arguments must be of the same
  555:                  type. However, now you can mix the type</td>
  556:     </tr>
  557: 
  558:     <tr>
  559:              <td valign="top">choose(i,...)</td>
  560:              <td valign="top">&amp;choose($i,...)</td>
  561:              <td valign="top">Choose the ith item from the argument list. i must
  562:                  be an integer greater than 0 and the value of i should not exceed the number
  563:                  of items. $i can be a pure integer</td>
  564:              <td valign="top">&nbsp;</td>
  565:     </tr>
  566: 
  567:     <tr>
  568:              <td valign="top">/MAP(seed;w,x,y,z;a,b,c,d)</td>
  569:              <td valign="top">Option 1 - &amp;map($seed,[\$w,\$x,\$y,\$z],[$a,$b,$c,$d]) or <br> 
  570:                   Option 2 - &amp;map($seed,\@mappedArray,[$a,$b,$c,$d]) <br>
  571:                   Option 3 - @mappedArray = &amp;map($seed,[$a,$b,$c,$d]) <br>
  572:                   Option 4 - ($w,$x,$y,$z) = &amp;map($seed,\@a) <br>
  573:                   where $a='A'<br>
  574:                         $b='B'<br>
  575:                         $c='B'<br>
  576:                         $d='B'<br>
  577:                         $w, $x, $y, and $z are variables</td>
  578:              <td valign="top">Assigns to the variables $w, $x, $y and $z the values of the
  579:                   $a, $b, $c and $c (A, B, C and D). The precise value for $w .. depends
  580:                   on the seed. (Option 1 of calling map). 
  581:                   In option 2, the values of $a, $b .. are mapped into the array, @mappedArray. The two
  582:                   options illustrate the different grouping. Options 3 and 4 give a consistent 
  583:                   way (with other functions) of mapping the items. For each option, the group can
  584:                   be passed as an array, for example, [$a,$b,$c,$d] => \@a.</td>
  585:              <td valign="top">In CAPA, the arguments are divided into three groups separated
  586:                   by a semicolon ;. In LON-CAPA, the separation is done by using [] brackets or
  587:                   using an array @a. Note the backslash (\) before the arguments in the
  588:                   second and third groups.</td>
  589:     </tr>
  590: 
  591: 
  592:     <tr>
  593:              <td valign="top">rmap(seed;a,b,c,d;w,x,y,z)</td>
  594:              <td valign="top">Option 1 - &amp;rmap($seed,[\$w,\$x,\$y,\$z],[$a,$b,$c,$d]) or <br> 
  595:                   Option 2 - &amp;rmap($seed,\@rmappedArray,[$a,$b,$c,$d]) <br>
  596:                   Option 3 - @rmapped_array = &amp;rmap($seed,[$a,$b,$c,$d]) <br>
  597:                   Option 4 - ($w,$x,$y,$z) = &amp;rmap($seed,\@a) <br>
  598:                   where $a='A'<br>
  599:                         $b='B'<br>
  600:                         $c='B'<br>
  601:                         $d='B'<br>
  602:                         $w, $x, $y, and $z are variables</td>
  603:              <td valign="top">The rmap functions does the reverse action of map if the same seed
  604:                   is used in calling map and rmap. </td>
  605:              <td valign="top">In CAPA, the arguments are divided into
  606:              three groups separated by a semicolon ;. In LON-CAPA, the
  607:              separation is done by using [] brackets (with create an
  608:              unamed vector reference) or using an array @a. Note the
  609:              backslash (\) before the arguments in the second and
  610:              third groups (Which cause Perl to send to variable
  611:              locations rather than the variable values, similar to a C
  612:              pointer).</td>
  613:     </tr>
  614:       
  615:      <tr>
  616:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  617:              <td valign="top">$a=&amp;xmlparse($string) </td>
  618:              <td valign="top">Runs the internal parser over the
  619: 	  argument parsing for display. <b>Warning</b> This will
  620: 	  result in different strings in different targets. Don't use
  621: 	  the results of this function as an answer.</td>
  622:              <td valign="top">New to LON-CAPA</td>
  623:     </tr>
  624: 
  625:     <tr>
  626:              <td valign="top">tex(a,b), tex("a","b")</td>
  627:              <td valign="top">&amp;tex($a,$b), &amp;tex("a","b")</td>
  628:              <td valign="top">Returns a if the output mode is in tex otherwise
  629:                   returns b</td>
  630:              <td valign="top">&nbsp;</td>
  631:     </tr>
  632: 
  633:     <tr>
  634:              <td valign="top">var_in_tex(a)</td>
  635:              <td valign="top">&amp;var_in_tex($a)</td>
  636:              <td valign="top">Equivalent to tex("a","")</td>
  637:              <td valign="top">&nbsp;</td>
  638:     </tr>
  639: 
  640:     <tr>
  641:              <td valign="top">to_string(x), to_string(x,y)</td>
  642:              <td valign="top">&amp;to_string($x), &amp;to_string($x,$y)</td>
  643:              <td valign="top">If x is an integer, returns a string. If x is real
  644:                 than the output is a string with format given by y. For example, if x =
  645:                 12.3456, &amp;to_string(x,".3F") = 12.345 and &amp;to_string(x,".3E") =
  646:                 1.234E+01.</td>
  647:              <td valign="top">&nbsp;</td>
  648:     </tr>
  649: 
  650:     <tr>
  651:              <td valign="top">capa_id(), class(), section(), set(), problem()</td>
  652:              <td valign="top">&amp;class(), &amp;section()</td>
  653:              <td valign="top">Returns null string, class descriptive name, section
  654:                     number, set number and null string.</td>
  655:              <td valign="top">capa_id(), set() and problem() are no longer used.
  656:                     Currently, they return a null value.</td>
  657:     </tr>
  658: 
  659:     <tr>
  660:              <td valign="top">name(), student_number()</td>
  661:              <td valign="top">&amp;name(), &amp;student_number()</td>
  662:              <td valign="top">Return the full name in the following format: lastname,
  663:                     firstname initial. Student_number returns the student 9-alphanumeric string.
  664:                     If undefined, the functions return null.</td>
  665:              <td valign="top">&nbsp;</td>
  666:     </tr>
  667: 
  668:     <tr>
  669:              <td valign="top">open_date(), due_date(), answer_date()</td>
  670:              <td valign="top">&amp;open_date(), &amp;due_date(), &amp;answer_date()</td>
  671:              <td valign="top">Problem open date, due date and answer date. The
  672:                     time is also included in 24-hr format.</td>
  673:              <td valign="top">Output format for time is changed slightly. If pass
  674:                     noon, it displays ..pm else it displays ..am. So 23:59 is displayed as
  675:                     11:59 pm.</td>
  676:     </tr>
  677: 
  678:     <tr>
  679:              <td valign="top">get_seed(), set_seed()</td>
  680:              <td valign="top">Not implemented</td>
  681:              <td valign="top">Get and set the random seed.</td>
  682:              <td valign="top">&nbsp;</td>
  683:     </tr>
  684: 
  685:     <tr>
  686:              <td valign="top">sub_string(a,b,c)</td>
  687:              <td valign="top">&amp;sub_string($a,$b,$c) <br>perl&nbsp; substr function. 
  688:                  However, note the differences</td>
  689:              <td valign="top">Retrieve a portion of string a starting from b and
  690:                     length c. For example,&nbsp; $a = "Welcome to LON-CAPA"; 
  691:                     $result=&amp;sub_string($a,4,4); then $result is "come"</td>
  692:              <td valign="top">Perl intrinsic function, substr(string,b,c) starts
  693:                     counting from 0 (as opposed to 1). In the example to the left, substr($a,4,4)
  694:                     returns "ome ".</td>
  695:     </tr>
  696: 
  697:     <tr>
  698:              <td valign="top">array[xx]</td>
  699:              <td valign="top">@arrayname <br>Array is intrinsic in perl. 
  700:                  To access a specific element use $arrayname[$n] where $n 
  701:                  is the $n+1 element since the array count starts from 0</td>
  702:              <td valign="top">"xx" can be a variable or a calculation.</td>
  703:              <td valign="top">In LON-CAPA, an array is defined by @arrayname.
  704:                   It is not necessary to specify the dimension of the array.&nbsp;</td>
  705:     </tr>
  706: 
  707:     <tr>
  708:              <td valign="top">array_moments(B,A)</td>
  709:              <td valign="top">@B=&amp;array_moments(@A)</td>
  710:              <td valign="top">Evaluates the moments of an array A and place the
  711:                   result in array B[i] where i = 0 to 4. The contents of B are as follows:
  712:                   B[0] = number of elements, B[1] = mean, B[2] = variance, B[3] = skewness
  713:                   and B[4] = kurtosis.</td>
  714:              <td valign="top">In CAPA, the moments are passed as an array in the first argument whereas
  715:                   in LON-CAPA, the array containing the moments are set equal to the function.</td>
  716:     </tr>
  717: 
  718:     <tr>
  719:              <td valign="top">array_max(Name), array_min(Name)</td>
  720:              <td valign="top">&amp;min(@Name), &amp;max(@Name)</td>
  721:              <td valign="top">In LON-CAPA to find the maximum value of an array, use
  722:                    &amp;max(@arrayname)&nbsp; and to find the minimum value of an array, use
  723:                    &amp;min(@arrayname)</td>
  724:              <td valign="top">Combined with the min and max functions defined
  725:                 earlier.</td>
  726:     </tr>
  727: 
  728:     <tr>
  729:              <td valign="top">init_array(Name)</td>
  730:              <td valign="top">undef @name</td>
  731:              <td valign="top">To destroy the contents of an array, use</td>
  732:              <td valign="top">Use perl intrinsic undef function.</td>
  733:     </tr>
  734:      <tr>
  735:              <td valign="top">random_normal (return_array,item_cnt,seed,av,std_dev)</td>
  736:              <td valign="top">@return_array=&random_normal ($item_cnt,$seed,$av,$std_dev)</td>
  737:              <td valign="top">Generate $item_cnt deviates of normal distribution of average $av and
  738:                         standard deviation $std_dev. The distribution is generated from seed $seed</td>
  739:              <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA 
  740:                         the results are set equal to the function.</td>
  741:     </tr>
  742:      <tr>
  743:              <td valign="top">random_beta (return_array,item_cnt,seed,aa,bb)</td>
  744:              <td valign="top">@return_array=&random_beta ($item_cnt,$seed,$aa,$bb) <br>
  745:                         NOTE: Both $aa and $bb MUST be greater than 1.0E-37.</td>
  746:              <td valign="top">Generate $item_cnt deviates of beta distribution. 
  747:                         The density of beta is:
  748:                         X^($aa-1) *(1-X)^($bb-1) /B($aa,$bb) for 0&lt;X&lt;1.</td>
  749:              <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA 
  750:                         the results are set equal to the function.</td>
  751:     </tr>
  752:      <tr>
  753:              <td valign="top">random_gamma (return_array,item_cnt,seed,a,r)</td>
  754:              <td valign="top">@return_array=&random_gamma ($item_cnt,$seed,$a,$r) <br>
  755:                         NOTE: Both $a and $r MUST be positive.</td>
  756:              <td valign="top">Generate $item_cnt deviates of gamma distribution. 
  757:                         The density of gamma is:
  758:                         ($a**$r)/gamma($r) * X**($r-1) * exp(-$a*X).</td>
  759:              <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA 
  760:                         the results are set equal to the function.</td>
  761:     </tr>
  762:      <tr>
  763:              <td valign="top">random_exponential (return_array,item_cnt,seed,av)</td>
  764:              <td valign="top">@return_array=&random_exponential ($item_cnt,$seed,$av) <br>
  765:                         NOTE: $av MUST be non-negative.</td>
  766:              <td valign="top">Generate $item_cnt deviates of exponential distribution. </td>
  767:              <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA 
  768:                         the results are set equal to the function.</td>
  769:     </tr>
  770:      <tr>
  771:              <td valign="top">random_poisson (return_array,item_cnt,seed,mu)</td>
  772:              <td valign="top">@return_array=&random_poisson ($item_cnt,$seed,$mu) <br>
  773:                         NOTE: $mu MUST be non-negative.</td>
  774:              <td valign="top">Generate $item_cnt deviates of poisson distribution. </td>
  775:              <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA 
  776:                         the results are set equal to the function.</td>
  777:     </tr>
  778:      <tr>
  779:              <td valign="top">random_chi (return_array,item_cnt,seed,df)</td>
  780:              <td valign="top">@return_array=&random_chi ($item_cnt,$seed,$df) <br>
  781:                         NOTE: $df MUST be positive.</td>
  782:              <td valign="top">Generate $item_cnt deviates of chi_square distribution with $df 
  783:                         degrees of freedom. </td>
  784:              <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA 
  785:                         the results are set equal to the function.</td>
  786:     </tr>
  787:      <tr>
  788:              <td valign="top">random_noncentral_chi (return_array,item_cnt,seed,df,nonc)</td>
  789:              <td valign="top">@return_array=&random_noncentral_chi ($item_cnt,$seed,$df,$nonc) <br>
  790:                         NOTE: $df MUST be at least 1 and $nonc MUST be non-negative.</td>
  791:              <td valign="top">Generate $item_cnt deviates of noncentral_chi_square 
  792:                         distribution with $df 
  793:                         degrees of freedom and noncentrality parameter $nonc. </td>
  794:              <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA 
  795:                         the results are set equal to the function.</td>
  796:     </tr>
  797:      <tr>
  798:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  799:              <td valign="top">@return_array=&random_f ($item_cnt,$seed,$dfn,$dfd) <br>
  800:                         NOTE: Both $dfn and $dfd MUST be positive.</td>
  801:              <td valign="top">Generate $item_cnt deviates of F (variance ratio) distribution with  
  802:                         degrees of freedom $dfn (numerator) and $dfd (denominator). </td>
  803:              <td valign="top">New to LON-CAPA</td>
  804:     </tr>
  805:      <tr>
  806:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  807:              <td valign="top">@return_array=&random_noncentral_f ($item_cnt,$seed,$dfn,$dfd,$nonc) <br>
  808:                         NOTE: $dfn must be at least 1, $dfd MUST be positive, and $nonc must
  809:                         be non-negative.</td>
  810:              <td valign="top">Generate $item_cnt deviates of noncentral F (variance ratio) 
  811:                         distribution with degrees of freedom $dfn (numerator) and $dfd (denominator).
  812:                         $nonc is the noncentrality parameter. </td>
  813:              <td valign="top">New to LON-CAPA</td>
  814:     </tr>
  815:      <tr>
  816:              <td valign="top">NOT DOCUMENTED IN CAPA</td>
  817:              <td valign="top">@return_array=&random_multivariate_normal ($item_cnt,$seed,\@mean,\@covar) <br>
  818:                         NOTE: @mean should be of length p array of real numbers. @covar should be a length
  819:                         p array of references to length p arrays of real numbers (i.e. a p by p matrix.</td>
  820:              <td valign="top">Generate $item_cnt deviates of multivariate_normal distribution with  
  821:                         mean vector @mean and variance-covariance matrix. </td>
  822:              <td valign="top">Note the backslash before the @mean and @covar arrays.</td>
  823:     </tr>
  824:      <tr>
  825:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  826:              <td valign="top">@return_array=&random_multinomial ($item_cnt,$seed,@p) <br>
  827:                         NOTE: $item_cnt is rounded with int() and the result must be non-negative. 
  828:                         The number of elements in @p must be at least 2.</td>
  829:              <td valign="top">Returns single observation from multinomial distribution with  
  830:                         $item_cnt events classified into as many categories as the length of @p.
  831:                         The probability of an event being classified into category i is given by 
  832:                         ith element of @p. The observation is an array with length equal to @p, so
  833:                         when called in a scalar context it returns the length of @p. The sum of the
  834:                         elements of the obervation is equal to $item_cnt.</td>
  835:              <td valign="top">New to LON-CAPA</td>
  836:     </tr>
  837:      <tr>
  838:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  839:              <td valign="top">@return_array=&random_permutation ($item_cnt,@array) </td>
  840:              <td valign="top">Returns @array randomly permuted.</td>
  841:              <td valign="top">New to LON-CAPA</td>
  842:     </tr>
  843:      <tr>
  844:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  845:              <td valign="top">@return_array=&random_uniform ($item_cnt,$seed,$low,$high) <br>
  846:                         NOTE: $low must be less than or equal to $high.</td>
  847:              <td valign="top">Generate $item_cnt deviates from a uniform distribution. </td>
  848:              <td valign="top">New to LON-CAPA</td>
  849:     </tr>
  850:      <tr>
  851:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  852:              <td valign="top">@return_array=&random_uniform_integer ($item_cnt,$seed,$low,$high) <br>
  853:                         NOTE: $low and $high are both passed through int().
  854:                               $low must be less than or equal to $high.</td>
  855:              <td valign="top">Generate $item_cnt deviates from a uniform distribution in integers. </td>
  856:              <td valign="top">New to LON-CAPA</td>
  857:     </tr>
  858:      <tr>
  859:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  860:              <td valign="top">@return_array=&random_binomial ($item_cnt,$seed,$nt,$p) <br>
  861:                         NOTE: $nt is rounded using int() and the result must be non-negative. 
  862:                               $p must be between 0 and 1 inclusive.</td>
  863:              <td valign="top">Generate $item_cnt deviates from the binomial distribution with
  864:                         $nt trials and the probabilty of an event in each trial is $p. </td>
  865:              <td valign="top">New to LON-CAPA</td>
  866:     </tr>
  867:      <tr>
  868:              <td valign="top">NOT IMPLEMENTED IN CAPA</td>
  869:              <td valign="top">@return_array=&random_negative_binomial ($item_cnt,$seed,$ne,$p) <br>
  870:                         NOTE: $ne is rounded using int() and the result must be positive. 
  871:                               $p must be between 0 and 1 exclusive.</td>
  872:              <td valign="top">Generate an array of $item_cnt outcomes generated from 
  873:                         negative binomial distribution with
  874:                         $ne events and the probabilty of an event in each trial is $p. </td>
  875:              <td valign="top">New to LON-CAPA</td>
  876:     </tr>
  877:  </table>
  878: <!-- insertion ends -->
  879: 
  880:     <h2>&lt;script&gt; Variables</h2>
  881:     <ul>
  882:       <li>
  883: 	$external::target - set to the current target the xml parser
  884: 	is parsing for
  885:       </li>
  886:       <li>
  887: 	$external::part - set to the <i>id</i> of the current problem
  888: 	&lt;part&gt;; zero if there are now &lt;part&gt;
  889:       </li>
  890:       <li>
  891: 	$external::gradestatus - set to the value of the current
  892: 	resource.partid.solved value
  893:       </li>
  894:       <li>
  895: 	$external::datestatus - set to the current status of the clock
  896: 	either CLOSED, CAN_ANSWER, CANNOT_ANSWER, or SHOW_ANSWER
  897:       </li>
  898:       <li>
  899: 	$external::randomseed - set to the number that was used to
  900: 	seed the random number generator
  901:       </li>
  902:       <li>$pi - set to PI </li>
  903:       <li>$rad2deg - converts radians to degrees </li>
  904:       <li>$deg2rad - converts degrees to radians </li>
  905:     </ul>
  906:     
  907:     <hr>
  908:     <address><a href="mailto:albertel@marvin.lite.msu.edu">Guy Albertelli</a></address>
  909: <!-- Created: Thu May 17 15:05:35 EDT 2001 -->
  910: <!-- hhmts start -->
  911: Last modified: Thu Mar 28 17:59:42 EST 2002
  912: <!-- hhmts end -->
  913:   </body>
  914: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>