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

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

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