Annotation of doc/homework/homework5.html, revision 1.8

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

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