Annotation of doc/homework/homework5.html, revision 1.20
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><responseparam></b> if it appears it should be
35: inside of a <*response> 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.16 albertel 60: <b><parameter></b> exactly the same as
61: <responseparam> currently, but should not appear
62: inside of a <*response>
63: </li>
64: <li>
1.1 albertel 65: <b><numericalresponse></b> implements a numerical
66: answer, it needs an internal <b><textline></b> for
67: the response to go in. It checks all styles of numerical
68: supported in CAPA. Possible args are:
69: <ul>
1.8 albertel 70: <li><i>answer</i> required, specifies the correct answer, may be either a perl list or scalar</li>
1.1 albertel 71: <li><i>units</i> optional, specifies unit of correct answer, CAPA style</li>
72: </ul>
73: </li>
74: <li>
1.8 albertel 75: <b><stringresponse></b> implements a string answer,
76: it needs an internal <b><textline></b> for the
77: response to go in. It can check the string for either case
78: or order.
79: <ul>
80: <li><i>answer</i> required, specifies the correct answer, may be either a perl list or scalar</li>
81: <li><i>type</i> optional, CAPA style str args, cs/ci/mc
82: <ul>
83: <li>cs - case senesitive, order important</li>
84: <li>ci - case insenesitive, order important</li>
85: <li>mc - case insenesitive, order unimportant</li>
86: </ul>
87: </li>
88: </ul>
89: <li>
1.1 albertel 90: <b><essayresponse></b> implements a ungraded large
1.17 albertel 91: text response, it need an internal <b><textfield></b>
1.1 albertel 92: for the response to go in.
93: </li>
94: <li>
95: <b><imageresponse></b> implements a image click
96: style image submission, uses the foil structure tags <a
97: href="#foil">below</a>. Additional tags that should appear
98: in a <foil> are:
99: <ul>
100: <li><b><image></b> required, the contained text
101: specifies a published graphical resource that is the
102: image used, should only appear once per foil</li>
103: <li><b><rectangle></b> required, the contained text
104: specifies a rectangular area that is correct, should
105: look like (1,2)-(3,4), at least 1 required</li>
106: <li><b><text></b> required, the contained text is
107: printed on top of the image.</li>
108: </ul>
109: </li>
110: <li>
111: <b><optionresponse></b> implements a "select from
112: these choices" style question, the choices are specified
113: by the instructor, it uses the foil structure tags <a
114: href="#foil">below</a> with this additional args:
115: <ul>
116: <li>
117: <b><foilgroup></b> is required to have
118: <i>options</i> which should be a perl list of possible
119: options for the student.
120: </li>
121: </ul>
122: </li>
123: <li>
124: <b><radiobuttonresponse></b> implements a true / false
125: style question with 1 correct answer.it uses the foil
126: structure tags <a href="#foil">below</a> but the
127: <i>value</i> of a <foil>can only be "true" or
128: "false" or "unused"
129: </li>
1.10 albertel 130: <li>
131: <b><dataresponse></b> implements a straight data
132: storage entry idea, needs and interveing input tag like
133: <textline> to work correctly.<br>
134: Arguments:
135: <ul>
136: <li>
137: <i>name</i> internal name for the value, it will have
138: the part id and respose id added on to it
139: </li>
140: <li>
141: <i>type</i> type of data stored in this response
142: field, should be one of the types supported by
143: parameter.html
144: </li>
145: <li>
146: <i>display</i> a string that will be used to describe
147: the field when interfacing with humans
148: </li>
149: </ul>
1.15 albertel 150: </li>
1.10 albertel 151: <li>
1.15 albertel 152: <p>
153: <b><externalresponse></b> implements the ability to have
154: an external program grade a response, expects either a
155: <textline> or <textfield> inside the tag. <br />
156: </p>
157: Arguments:
158: <ul>
159: <li>
160: <i>url</i> the url to submit the answer and form to,
161: does not need to be a LON-CAPA machine.
162: </li>
163: <li>
164: <i>answer</i> a string or scalar variable that can
165: encode something that should encode the correct
166: answer, in some cases this may be nothing.
167: </li>
168: <li>
169: <i>form</i> a hash variable name that will be
170: submitted to the remote site as a HTTP form.
171: </li>
172: </ul>
173: <p>
174: The response of the remote server needs to be in XML as follows.
175: </p>
176: <pre>
177: <loncapagrade>
178: <awardetail>
179: CORRECT
180: </awardetail>
181: <message>
182: A message to be shown to the students
183: </message>
184: </loncapagrade>
185: </pre>
186: <ul>
187: <li>
188: <b><loncapagrade></b> no arguments but must
189: surround the response.
190: </li>
191: <li>
192: <b><awardetail></b> required inner tag, the
193: response inside must be one of the detailed responses
194: that appears in the data storage documentation
195: (CVS:loncapa/doce/homework/datastorage)
196: </li>
197: <li>
198: <b><message></b> optional message to have shown
199: to the student
200: </li>
201: </ul>
202: </li>
1.1 albertel 203: </ul>
204: <li>
205: <a name="foil">Foil Structure Tags</a>
206: <p>
207: All tags that implement a foil structure have an optional
208: arg of <i>max</i> that controls the maximum number of total
209: foils to show.
210: </p>
211: <ul>
212: <li>
213: <b><foilgroup></b> required, must be the tag that
214: surrounds all foil definitions
215: </li>
216: <li>
217: <b><foil></b> required, all data inside is a possible foil
218: </li>
219: <li>
220: <b><conceptgroup></b> optional, surrounds a
221: collection of <foil>, when a problem is displayed
222: only one of the contained <foil>is selected for
223: display. It receives one required argument
224: <i>concept</i>.
225: </li>
226: </ul>
227: </li>
228: <li>
229: Hint structure
230: <p>
231: All of these tags must appear inside a <b><*response></b> tag.
232: </p>
233: <ul>
234: <li>
235: <b><hintgroup></b> Tag that surrounds all of a hint.
236: </li>
237: <li>
238: <b><hintpart></b> required, Tag to implement
239: conditional hints. It has a required argument
240: <i>on</i>. When a <*hint> tag named the same as the
241: value the </i>on</i> attribute evaluates to be correct the
242: <hintpart> will show. If no other <hintpart>
243: are to show then all hintparts with a <i>on</i> of
244: "default" will show
245: </li>
246: <li>
247: <b><numericalhint></b> has all the arguments that
248: <numericalresponse>, does and the required attribute
249: <i>name</i> which should be set to the value of which
250: <hintpart> will be shown.
251: </li>
252: </ul>
253: </li>
254: <li>
255: Input Tags
256: <p>
257: This group of tags implement a mechanism for getting data
258: for students, they will usually be used by a
259: <*response>.
260: </p>
261: <ul>
262: <li>
1.17 albertel 263: <b><textfield></b> creates a Large text input box, If
1.1 albertel 264: data appears between the start and end tags, the data will
1.17 albertel 265: appear in the textfield if the student has not yet made a
1.1 albertel 266: submission. Additionally it takes two arguments <i>rows</i>
267: and <i>cols</i> which control the height and width of the
268: area respectively. It defaults to 10 and 80.
269: </li>
270: <li>
271: <b><textline></b> creates a single line of input
272: element, it accepts 1 argument <i>size</i> which controls
273: the width on the textline, it defaults to 20.
274: </li>
275: </ul>
276: </li>
277: <li>
278: Output Tags
279: <p>
280: This group of tags generate useful pieces of output.
281: </p>
282: <ul>
283: <li>
1.15 albertel 284: <b><standalone></b> everything in between the start
285: and end tag is shown only on the web, and only if the
286: resource is not part of a course.
287: </li>
288: <li>
1.1 albertel 289: <b><displayduedate></b> this will insert the current
290: duedate if one is set into the document. It is generated
291: to be inside a table of 1x1 elements
292: </li>
293: <li>
294: <b><displaytitle></b> this will insert the title of
295: the problem from the metadata of the problem
296: </li>
297: <li>
298: <b><window></b> the text in between is put in a
299: popup javascript window
300: </li>
1.12 albertel 301: <li>
302: <b><m></b> the inside text is LaTeX, and is
303: converted to HTML (or MathML) on the fly, if the argument
304: <i>eval</i> is set to "on" the intervening text will have
305: a perl var expansion done to it before being converted.
306: </li>
1.15 albertel 307: <li>
308: <b><randomlabel></b> shows a specified image with
309: images or text labels randomly assigned to a set of
310: specific locations, those locations may also have values
311: assigned to them. There is a hash generated conating the
312: mapping of labels to locations, labels to values, and
313: locations to values. Example:
314: <pre>
315: <randomlabel bgimg="URL" width="12" height="45" texwidth="50">
316: <labelgroup name="GroupOne" type="image">
317: <location x="123" y="456" value="10" />
318: <location x="321" y="654" value="20" />
319: <location x="213" y="546" value="13" />
320: <label description="TEXT-1">IMG-URL</label>
321: <label description="TEXT-2">IMG-URL</label>
322: <label description="TEXT-3">IMG-URL</label>
323: </labelgroup>
324: <labelgroup name="GroupTwo" type="text">
325: <location x="12" y="45" />
326: <location x="32" y="65" />
327: <location x="21" y="54" />
328: <label>TEXT-1</label>
329: <label>TEXT-2</label>
330: <label>TEXT-3</label>
331: </labelgroup>
332: </randomlabel>
333: </pre>
334: Arguments:
335: <ul>
336: <li>
337: <i>bgimg</i> either a fully qualified URL for an
338: external image, or a loncapa resource, it supports
339: relative references (../images/apicture.gif), the
340: image must either be a GIF or JPEG
341: </li>
342: <li>
343: <i>width</i> the width of the image in pixels
344: </li>
345: <li>
346: <i>height</i> the height of the image in pixels
347: </li>
348: <li>
349: <i>texwidth</i> the width of the image in millimeters
350: </li>
351: </ul>
352: Internal tags:
353: <ul>
354: <li>
355: <b><labelgroup></b> 1 required, multiple
356: allowed. Declares a group of locations and labels
357: associated with them. <br />Arguments:
358: <ul>
359: <li>
360: <i>name</i> this is the name of the group, a hash
361: with this name will be generated holding the
362: mappings for later use in the problem. For each
363: location a value will be set for which label is
364: there, (EX. $hash{'1'}="TEXT-2"). For locations
365: with values the hash will contain 2 items, a
366: location to value mapping ($hash{'value_1'}=10),
367: and a label to value mapping
368: ($hash{'labelvalue_2'}=10). For all image style of
369: labels there will also be a label description to
370: label URL mapping ($hash{'image_2'}=IMG-URL). Also
371: the entry 'numlocations will be set to the total
372: number of locations that exist.
373: (Note that locations and labels start counting from 1.)
374: </li>
375: <li>
376: <i>type</i> the type of labels in this group,
377: either 'image' or 'text'
378: </li>
379: </ul>
380: </li>
381: <li>
382: <b><location></b> declares a location on the
383: image that a label should appear at <br />Arguments:
384: <ul>
385: <li>
386: <i>x</i> the x value of the location in pixels
387: </li>
388: <li>
389: <i>y</i> the y value of the location in pixels
390: </li>
391: <li>
392: <i>value</i> a scalar value to associate at this
393: location (optional)
394: </li>
395: </ul>
396: </li>
397: <li>
398: <b><label></b> declaration of a label, if this
399: is a text type labelgroup the internal text should be
400: the text of the label (HTML is not currently
401: supported), if this is an image type of label the
402: internal text must be a LON-CAPA resource
403: specification, and the description filed must be set.
404: <br />Arguments:
405: <ul>
406: <li>
407: <i>description</i> a required field for image
408: labels, it will be used when setting values in the
409: hash.
410: </li>
411: </ul>
412: </li>
413: </ul>
414: </li>
1.1 albertel 415: </ul>
416: </li>
417: <li>
418: Scripting
1.15 albertel 419: <p>
420: These tags allow the document to behave programatically
421: </p>
422: <ul>
423: <li>
1.1 albertel 424: <b><display></b> the intervening perl script is
425: evaluated in the safe space and the return value of the
426: script replaces the entire tag
427: </li>
428: <li>
429: <b><import></b> causes the parse to read in the file
430: named in the body of the tag and parse it as if the entire
431: text of the file had existed at location of the tag
432: </li>
433: <li>
434: <b><parserlib></b> the enclosed filename contains
435: definitions for new tags
436: </li>
437: <li>
438: <b><script></b> if the argument <i>type</i> is set
439: to "loncapa/perl" the enclosed data is a perl script which
440: is evaluated inside the perl Safe space. The return value
441: of the script is ignored.
442: </li>
443: <li>
444: <b><scriptlib></b> the enclosed filename contains
445: perl code to run in the safe space
446: </li>
447: <li>
448: <b><block></b> has a required argument
449: <i>condition</i> that is evaluated, it the condition is
450: true everything inside the tag is evaluated, if it is false
451: everything inside the block tag is skipped
452: </li>
453: <li>
454: <b><notsolved></b> everything inside the tag is
455: skipped if the problem is "solved"
456: </li>
457: <li>
458: <b><postanswerdate></b> everything inside the tag is
459: skipped if the problem is before the answer date
460: </li>
461: <li>
462: <b><preduedate></b> everything inside the tag is
463: skipped if the problem is after the due date
464: </li>
465: <li>
466: <b><randomlist></b> the enclosed tags are parsed in
1.13 albertel 467: a stable random order, optional argument <i>show</i>
468: restricts the number of tags indie that are actually
469: parsed the no more than <i>show</i>.
1.1 albertel 470: </li>
471: <li>
472: <b><solved></b> everything inside the tag is
473: skipped if the problem is "not solved"
474: </li>
475: <li>
476: <b><while></b> implements a while loop, required
477: argument <i>condition</i> is a perl scriptlet that when
478: evaluated results in a true or false value, on true the
479: entirety of the text between the whiles is parsed. The
480: condition is tested again, etc. If false it goes to the
481: next node in the parse.
482: </li>
483: </ul>
484: </li>
485: <li>
486: Structure Tags
487: <p>
488: These tags give the problem a structure and take care of the
489: recording of data and giving the student messages.
490: </p>
491: <ul>
492: <li>
493: <b><problem></b> must be the first tag in the file,
494: this tag sets up the header of the webpage and generates
495: the submit buttons, it also handles due dates properly
496: </li>
497: <li>
498: <b><part></b> must be below <problem> if it is
499: going to be used. It does many of the same tasks as
500: <problem> but allows multiple separate problems to
501: exist in a single file.
502: </li>
503: <li>
504: <b><startouttext></b><b><endouttext></b> these
505: tags are somewhat special, they must have no internal text
506: and occur in pairs. Their use is to mark up the problem so
507: the web editor knows what sections should be edited in a
508: plain text block on the web.
509: </li>
1.18 albertel 510: <li>
511: <b><comment></b> Allows one to comment out sections
512: of code in a balanced manner, or to provide a comment
513: description of how a problem works. Only shows up for the
514: edit target, stripped out for all other targets.
515: </li>
1.1 albertel 516: </ul>
517: </li>
518: </ul>
519: <h2><script> Functions</h2>
520: <p>
521: A list of functions that have been written that are available in
1.5 ng 522: the Safe space scripting environment inside a problem.
1.1 albertel 523: </p>
524: <ul>
1.3 ng 525: <li>sin(x), cos(x), tan(x)</li>
526: <li>asin(x), acos(x), atan(x), atan2(y,x)</li>
527: <li>log(x), log10(x)</li>
528: <li>exp(), pow(x,y), sqrt(x)</li>
529: <li>abs(x), sgn(x)</li>
530: <li>erf(x), erfc(x)</li>
531: <li>ceil(x), floor(x)</li>
532: <li>min(...), max(...)</li>
533: <li>factorial(n)</li>
534: <li>N%M</li>
535: <li>sinh(x), cosh(x), tanh(x)</li>
536: <li>asinh(x), acosh(x), atanh(x)</li>
537: <li>roundto(x,n)</li>
538: <li>web("a","b","c") or web(a,b,c)</li>
539: <li>html("a") or html(a)</li>
540: <li>j0(x), j1(x), jn(n,x), jv(y,x)</li>
541: <li>y0(x), y1(x), yn(n,x), yv(y,x)</li>
1.1 albertel 542: <li>random</li>
543: <li>choose</li>
1.3 ng 544: <li>tex("a","b") or tex(a,b)</li>
545: <li>var_in_tex(a)</li>
546: <li>to_string(x), to_string(x,y)</li>
547: <li>class(), section()</li>
548: <li>name(), student_number()</li>
549: <li>open_date(), due_date(), answer_date()</li>
550: <li>sub_string()</li>
551: <li>array_moments(array)</li>
1.15 albertel 552: <li>format(x,y),prettyprint(x,y)</li>
1.3 ng 553: <li>map(...)</li>
1.1 albertel 554: <li>caparesponse_check</li>
555: <li>caparesponse_check_list</li>
556: </ul>
1.5 ng 557: <!-- Table inserted by H. K. Ng
558: 06/01/2001
559: 06/12/2001
560: -->
561: <p>
562: Detailed descriptions of each function and comparison with CAPA.
563: </p>
1.4 ng 564:
565: <table border=1>
566: <tr>
567: <td valign="top"><b>CAPA Functions</b</td>
568: <td valign="top"><b>LON-CAPA</b</td>
569: <td valign="top"><b>Descriptions</b</td>
570: <td valign="top"><b>Differences (if any)</b</td>
571: </tr>
572:
573: <tr>
574: <td valign="top">sin(x), cos(x), tan(x)</td>
575: <td valign="top">&sin($x), &cos($x), &tan($x)</td>
576: <td valign="top">Trigonometric functions where x is in radians. $x
577: can be a pure number, i.e., you can call &sin(3.1415)</td>
578: <td valign="top"> </td>
579: </tr>
580:
581: <tr>
582: <td valign="top">asin(x), acos(x), atan(x), atan2(y,x)</td>
583: <td valign="top">&asin($x), &acos($x), &atan($x), &atan2($y,$x)</td>
584: <td valign="top">Inverse trigonometric functions. Return value is
585: in radians. For asin and acos the value of x must be between -1 and 1.
586: The atan2 returns a value between -pi and pi the sign of which is determined
587: by y. $x and $y can be pure numbers</td>
588: <td valign="top"> </td>
589: </tr>
590:
591: <tr>
592: <td valign="top">log(x), log10(x)</td>
593: <td valign="top">&log($x), &log10($x)</td>
594: <td valign="top">Natural and base-10 logarithm. $x can be a pure number</td>
595: <td valign="top"> </td>
596: </tr>
597:
598: <tr>
599: <td valign="top">exp(x), pow(x,y), sqrt(x)</td>
600: <td valign="top">&exp($x), &pow($x,$y), &sqrt($x)</td>
601: <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>
602:
603: <td valign="top"> </td>
604: </tr>
605:
606: <tr>
607: <td valign="top">abs(x), sgn(x)</td>
608: <td valign="top">&abs($x), &sgn($x)</td>
609: <td valign="top">Abs takes the absolute value of x while sgn(x) returns
610: 1, 0 or -1 depending on the value of x. For x>0, sgn(x) = 1, for x=0, sgn(x)
611: = 0 and for x<0, sgn(x) = -1. $x can be a pure number</td>
612: <td valign="top"> </td>
613: </tr>
614:
615: <tr>
616: <td valign="top">erf(x), erfc(x)</td>
617: <td valign="top">&erf($x), &erfc($x)</td>
618: <td valign="top">Error function. erf = 2/sqrt(pi) integral (0,x) e<sup>t-sq</sup> and <i> erfx(x)</i> = 1.0 - <i>erf(x)</i>. $x can be a pure number</td>
619: <td valign="top"> </td>
620: </tr>
621:
622: <tr>
623: <td valign="top">ceil(x), floor(x)</td>
624: <td valign="top">&ceil($x), &floor($x)</td>
625: <td valign="top">Ceil function returns an integer rounded up whereas
626: floor function returns and integer rounded down. If x is an integer than
627: it returns the value of the integer. $x can be a pure number</td>
628: <td valign="top"> </td>
629: </tr>
630:
631: <tr>
632: <td valign="top">min(...), max(...)</td>
633: <td valign="top">&min(...), &max(...)</td>
634: <td valign="top">Returns the minimum/ maximum value of a list of
635: arguments if the arguments are numbers. If the arguments are strings then
636: it returns a string sorted according to the ASCII codes</td>
637: <td valign="top"> </td>
638: </tr>
639:
640: <tr>
641: <td valign="top">factorial(n)</td>
642: <td valign="top">&factorial($n)</td>
643: <td valign="top">Argument (n) must be an integer else it will round
644: down. The largest value for n is 170. $n can be a pure number</td>
645: <td valign="top"> </td>
646: </tr>
647:
648: <tr>
649: <td valign="top">N%M</td>
650: <td valign="top">$N%$M</td>
651:
652: <td valign="top">N and M are integers and returns the remainder (in
653: integer) of N/M. $N and $M can be pure numbers</td>
654: <td valign="top"> </td>
655: </tr>
656:
657: <tr>
658: <td valign="top">sinh(x), cosh(x), tanh(x)</td>
659: <td valign="top">&sinh($x), &cosh($x), &tanh($x)</td>
660: <td valign="top">Hyperbolic functions. $x can be a pure number</td>
661: <td valign="top"> </td>
662: </tr>
663:
664: <tr>
665: <td valign="top">asinh(x), acosh(x), atanh(x)</td>
666: <td valign="top">&asinh($x), &acosh($x), &atanh($x)</td>
667: <td valign="top">Inverse hyperbolic functions. $x can be a pure number</td>
668: <td valign="top"> </td>
669: </tr>
670:
671: <tr>
1.9 ng 672: <td valign="top">/DIS($x,"nn")</td>
673: <td valign="top">&format($x,"nn")</td>
1.19 albertel 674: <td valign="top">Display or format $x as nn where nn is nF or nE and n is an integer. Also supports the first character being a $, it thjen will format the result with a call to &dollarformat() described below.</td>
1.9 ng 675: <td valign="top"> The difference is obvious.</td>
676: </tr>
677:
678: <tr>
1.15 albertel 679: <td valign="top">Not in CAPA</td>
680: <td valign="top">&prettyprint($x,"nn")</td>
1.19 albertel 681: <td valign="top">Display or format $x as nn where nn is nF or nE and n is an integer. Also supports the first character being a $, it then will format the result with a a call to &dollarformat() described below. In E mode it will attempt to generate a pretty x10^3 rather than a E3 following the number</td>
1.15 albertel 682: <td valign="top"> </td>
683: </tr>
684:
685: <tr>
1.19 albertel 686: <td valign="top">Not in CAPA</td>
687: <td valign="top">&dollarformat($x</td>
688: <td valign="top">Reformats $x to have a $ (or \$ if in tex mode) and to have , grouping thousands.</td>
689: <td valign="top"> </td>
690: </tr>
691: <tr>
1.4 ng 692: <td valign="top">roundto(x,n)</td>
693: <td valign="top">&roundto($x,$n)</td>
694: <td valign="top">Rounds a real number to n decimal points. $x and
695: $n can be pure numbers</td>
696: <td valign="top"> </td>
697: </tr>
698:
699: <tr>
700: <td valign="top">web("a","b","c") or web(a,b,c)</td>
701: <td valign="top">&web("a","b","c") or &web($a,$b,$c)</td>
702: <td valign="top">Returns either a, b or c depending on the output
703: medium. a is for plain ASCII, b for tex output and c for html output</td>
704: <td valign="top"> </td>
705: </tr>
706:
707: <tr>
708: <td valign="top">html("a") or html(a)</td>
709: <td valign="top">&html("a") or &html($a)</td>
710: <td valign="top">Output only if the output mode chosen is in html
711: format</td>
712: <td valign="top"> </td>
713: </tr>
714:
715: <tr>
716: <td valign="top">jn(m,x)</td>
717: <td valign="top">&j0($x), &j1($x), &jn($m,$x), &jv($y,$x)</td>
718: <td valign="top">Bessel functions of the first kind with orders 0,
719: 1 and m respectively. For jn(m,x), m must be an integer whereas for jv(y,x),
720: y is real. $x can be a pure number. $m must be an integer and can be a
721: pure integer number. $y can be a pure real number</td>
722: <td valign="top">In CAPA, j0, j1 and jn are contained in one function,
1.5 ng 723: 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 724: </tr>
725:
726: <tr>
727: <td valign="top">yn(m,x)</td>
728: <td valign="top">&y0($x), &y1($x), &yn($m,$x), &yv($y,$x)</td>
729: <td valign="top">Bessel functions of the second kind with orders
730: 0, 1 and m respectively. For yn(m,x), m must be an integer whereas for
731: yv(y,x), y is real. $x can be a pure number. $m must be an integer and
732: can be a pure integer number. $y can be a pure real number</td>
733: <td valign="top">In CAPA, y0, y1 and yn are contained in one function,
1.5 ng 734: 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 735: </tr>
736:
737: <tr>
738: <td valign="top">random(l,u,d)</td>
739: <td valign="top">&random($l,$u,$d)</td>
740: <td valign="top">Returns a uniformly distributed random number between
741: the lower bound, l and upper bound, u in steps of d. $l, $u and $d can
742: be pure numbers</td>
743: <td valign="top">In CAPA, all the 3 arguments must be of the same
744: type. However, now you can mix the type</td>
745: </tr>
746:
747: <tr>
748: <td valign="top">choose(i,...)</td>
749: <td valign="top">&choose($i,...)</td>
750: <td valign="top">Choose the ith item from the argument list. i must
751: be an integer greater than 0 and the value of i should not exceed the number
752: of items. $i can be a pure integer</td>
753: <td valign="top"> </td>
754: </tr>
755:
756: <tr>
1.11 albertel 757: <td valign="top">/MAP(seed;w,x,y,z;a,b,c,d)</td>
1.7 ng 758: <td valign="top">Option 1 - &map($seed,[\$w,\$x,\$y,\$z],[$a,$b,$c,$d]) or <br>
759: Option 2 - &map($seed,\@mappedArray,[$a,$b,$c,$d]) <br>
760: Option 3 - @mappedArray = &map($seed,[$a,$b,$c,$d]) <br>
761: Option 4 - ($w,$x,$y,$z) = &map($seed,\@a) <br>
762: where $a='A'<br>
763: $b='B'<br>
764: $c='B'<br>
765: $d='B'<br>
766: $w, $x, $y, and $z are variables</td>
1.6 ng 767: <td valign="top">Assigns to the variables $w, $x, $y and $z the values of the
1.7 ng 768: $a, $b, $c and $c (A, B, C and D). The precise value for $w .. depends
769: on the seed. (Option 1 of calling map).
770: In option 2, the values of $a, $b .. are mapped into the array, @mappedArray. The two
771: options illustrate the different grouping. Options 3 and 4 give a consistent
772: way (with other functions) of mapping the items. For each option, the group can
773: be passed as an array, for example, [$a,$b,$c,$d] => \@a.</td>
1.6 ng 774: <td valign="top">In CAPA, the arguments are divided into three groups separated
775: by a semicolon ;. In LON-CAPA, the separation is done by using [] brackets or
776: using an array @a. Note the backslash (\) before the arguments in the
777: second and third groups.</td>
778: </tr>
779:
780:
781: <tr>
782: <td valign="top">rmap(seed;a,b,c,d;w,x,y,z)</td>
1.7 ng 783: <td valign="top">Option 1 - &rmap($seed,[\$w,\$x,\$y,\$z],[$a,$b,$c,$d]) or <br>
784: Option 2 - &rmap($seed,\@rmappedArray,[$a,$b,$c,$d]) <br>
785: Option 3 - @rmapped_array = &rmap($seed,[$a,$b,$c,$d]) <br>
786: Option 4 - ($w,$x,$y,$z) = &rmap($seed,\@a) <br>
787: where $a='A'<br>
788: $b='B'<br>
789: $c='B'<br>
790: $d='B'<br>
791: $w, $x, $y, and $z are variables</td>
1.6 ng 792: <td valign="top">The rmap functions does the reverse action of map if the same seed
793: is used in calling map and rmap. </td>
1.11 albertel 794: <td valign="top">In CAPA, the arguments are divided into
795: three groups separated by a semicolon ;. In LON-CAPA, the
796: separation is done by using [] brackets (with create an
797: unamed vector reference) or using an array @a. Note the
798: backslash (\) before the arguments in the second and
799: third groups (Which cause Perl to send to variable
800: locations rather than the variable values, similar to a C
801: pointer).</td>
1.6 ng 802: </tr>
1.8 albertel 803:
804: <tr>
805: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
806: <td valign="top">$a=&xmlparse($string) </td>
807: <td valign="top">Runs the internal parser over the
808: argument parsing for display. <b>Warning</b> This will
809: result in different strings in different targets. Don't use
810: the results of this function as an answer.</td>
811: <td valign="top">New to LON-CAPA</td>
812: </tr>
1.6 ng 813:
814: <tr>
1.4 ng 815: <td valign="top">tex(a,b), tex("a","b")</td>
816: <td valign="top">&tex($a,$b), &tex("a","b")</td>
817: <td valign="top">Returns a if the output mode is in tex otherwise
818: returns b</td>
819: <td valign="top"> </td>
820: </tr>
821:
822: <tr>
823: <td valign="top">var_in_tex(a)</td>
824: <td valign="top">&var_in_tex($a)</td>
825: <td valign="top">Equivalent to tex("a","")</td>
826: <td valign="top"> </td>
827: </tr>
828:
829: <tr>
830: <td valign="top">to_string(x), to_string(x,y)</td>
831: <td valign="top">&to_string($x), &to_string($x,$y)</td>
832: <td valign="top">If x is an integer, returns a string. If x is real
833: than the output is a string with format given by y. For example, if x =
834: 12.3456, &to_string(x,".3F") = 12.345 and &to_string(x,".3E") =
835: 1.234E+01.</td>
836: <td valign="top"> </td>
837: </tr>
838:
839: <tr>
840: <td valign="top">capa_id(), class(), section(), set(), problem()</td>
841: <td valign="top">&class(), &section()</td>
842: <td valign="top">Returns null string, class descriptive name, section
843: number, set number and null string.</td>
844: <td valign="top">capa_id(), set() and problem() are no longer used.
845: Currently, they return a null value.</td>
846: </tr>
847:
848: <tr>
849: <td valign="top">name(), student_number()</td>
850: <td valign="top">&name(), &student_number()</td>
851: <td valign="top">Return the full name in the following format: lastname,
852: firstname initial. Student_number returns the student 9-alphanumeric string.
853: If undefined, the functions return null.</td>
854: <td valign="top"> </td>
855: </tr>
856:
857: <tr>
858: <td valign="top">open_date(), due_date(), answer_date()</td>
859: <td valign="top">&open_date(), &due_date(), &answer_date()</td>
860: <td valign="top">Problem open date, due date and answer date. The
861: time is also included in 24-hr format.</td>
862: <td valign="top">Output format for time is changed slightly. If pass
863: noon, it displays ..pm else it displays ..am. So 23:59 is displayed as
864: 11:59 pm.</td>
865: </tr>
866:
867: <tr>
868: <td valign="top">get_seed(), set_seed()</td>
869: <td valign="top">Not implemented</td>
870: <td valign="top">Get and set the random seed.</td>
871: <td valign="top"> </td>
872: </tr>
873:
874: <tr>
875: <td valign="top">sub_string(a,b,c)</td>
876: <td valign="top">&sub_string($a,$b,$c) <br>perl substr function.
877: However, note the differences</td>
878: <td valign="top">Retrieve a portion of string a starting from b and
879: length c. For example, $a = "Welcome to LON-CAPA";
880: $result=&sub_string($a,4,4); then $result is "come"</td>
881: <td valign="top">Perl intrinsic function, substr(string,b,c) starts
882: counting from 0 (as opposed to 1). In the example to the left, substr($a,4,4)
883: returns "ome ".</td>
884: </tr>
885:
886: <tr>
887: <td valign="top">array[xx]</td>
888: <td valign="top">@arrayname <br>Array is intrinsic in perl.
889: To access a specific element use $arrayname[$n] where $n
890: is the $n+1 element since the array count starts from 0</td>
891: <td valign="top">"xx" can be a variable or a calculation.</td>
892: <td valign="top">In LON-CAPA, an array is defined by @arrayname.
893: It is not necessary to specify the dimension of the array. </td>
894: </tr>
895:
896: <tr>
897: <td valign="top">array_moments(B,A)</td>
898: <td valign="top">@B=&array_moments(@A)</td>
899: <td valign="top">Evaluates the moments of an array A and place the
900: result in array B[i] where i = 0 to 4. The contents of B are as follows:
901: B[0] = number of elements, B[1] = mean, B[2] = variance, B[3] = skewness
902: and B[4] = kurtosis.</td>
1.5 ng 903: <td valign="top">In CAPA, the moments are passed as an array in the first argument whereas
904: in LON-CAPA, the array containing the moments are set equal to the function.</td>
1.4 ng 905: </tr>
906:
907: <tr>
908: <td valign="top">array_max(Name), array_min(Name)</td>
909: <td valign="top">&min(@Name), &max(@Name)</td>
910: <td valign="top">In LON-CAPA to find the maximum value of an array, use
911: &max(@arrayname) and to find the minimum value of an array, use
912: &min(@arrayname)</td>
913: <td valign="top">Combined with the min and max functions defined
914: earlier.</td>
915: </tr>
916:
917: <tr>
918: <td valign="top">init_array(Name)</td>
919: <td valign="top">undef @name</td>
920: <td valign="top">To destroy the contents of an array, use</td>
921: <td valign="top">Use perl intrinsic undef function.</td>
922: </tr>
1.5 ng 923: <tr>
924: <td valign="top">random_normal (return_array,item_cnt,seed,av,std_dev)</td>
925: <td valign="top">@return_array=&random_normal ($item_cnt,$seed,$av,$std_dev)</td>
926: <td valign="top">Generate $item_cnt deviates of normal distribution of average $av and
927: standard deviation $std_dev. The distribution is generated from seed $seed</td>
928: <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA
929: the results are set equal to the function.</td>
930: </tr>
931: <tr>
932: <td valign="top">random_beta (return_array,item_cnt,seed,aa,bb)</td>
933: <td valign="top">@return_array=&random_beta ($item_cnt,$seed,$aa,$bb) <br>
934: NOTE: Both $aa and $bb MUST be greater than 1.0E-37.</td>
935: <td valign="top">Generate $item_cnt deviates of beta distribution.
936: The density of beta is:
937: X^($aa-1) *(1-X)^($bb-1) /B($aa,$bb) for 0<X<1.</td>
938: <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA
939: the results are set equal to the function.</td>
940: </tr>
941: <tr>
942: <td valign="top">random_gamma (return_array,item_cnt,seed,a,r)</td>
943: <td valign="top">@return_array=&random_gamma ($item_cnt,$seed,$a,$r) <br>
944: NOTE: Both $a and $r MUST be positive.</td>
945: <td valign="top">Generate $item_cnt deviates of gamma distribution.
946: The density of gamma is:
947: ($a**$r)/gamma($r) * X**($r-1) * exp(-$a*X).</td>
948: <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA
949: the results are set equal to the function.</td>
950: </tr>
951: <tr>
952: <td valign="top">random_exponential (return_array,item_cnt,seed,av)</td>
953: <td valign="top">@return_array=&random_exponential ($item_cnt,$seed,$av) <br>
954: NOTE: $av MUST be non-negative.</td>
955: <td valign="top">Generate $item_cnt deviates of exponential distribution. </td>
956: <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA
957: the results are set equal to the function.</td>
958: </tr>
959: <tr>
960: <td valign="top">random_poisson (return_array,item_cnt,seed,mu)</td>
961: <td valign="top">@return_array=&random_poisson ($item_cnt,$seed,$mu) <br>
962: NOTE: $mu MUST be non-negative.</td>
963: <td valign="top">Generate $item_cnt deviates of poisson distribution. </td>
964: <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA
965: the results are set equal to the function.</td>
966: </tr>
967: <tr>
968: <td valign="top">random_chi (return_array,item_cnt,seed,df)</td>
969: <td valign="top">@return_array=&random_chi ($item_cnt,$seed,$df) <br>
970: NOTE: $df MUST be positive.</td>
971: <td valign="top">Generate $item_cnt deviates of chi_square distribution with $df
972: degrees of freedom. </td>
973: <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA
974: the results are set equal to the function.</td>
975: </tr>
976: <tr>
977: <td valign="top">random_noncentral_chi (return_array,item_cnt,seed,df,nonc)</td>
978: <td valign="top">@return_array=&random_noncentral_chi ($item_cnt,$seed,$df,$nonc) <br>
979: NOTE: $df MUST be at least 1 and $nonc MUST be non-negative.</td>
980: <td valign="top">Generate $item_cnt deviates of noncentral_chi_square
981: distribution with $df
982: degrees of freedom and noncentrality parameter $nonc. </td>
983: <td valign="top">In CAPA the results are passed as the first argument whereas in LON-CAPA
984: the results are set equal to the function.</td>
985: </tr>
986: <tr>
987: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
988: <td valign="top">@return_array=&random_f ($item_cnt,$seed,$dfn,$dfd) <br>
989: NOTE: Both $dfn and $dfd MUST be positive.</td>
990: <td valign="top">Generate $item_cnt deviates of F (variance ratio) distribution with
991: degrees of freedom $dfn (numerator) and $dfd (denominator). </td>
992: <td valign="top">New to LON-CAPA</td>
993: </tr>
994: <tr>
995: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
996: <td valign="top">@return_array=&random_noncentral_f ($item_cnt,$seed,$dfn,$dfd,$nonc) <br>
997: NOTE: $dfn must be at least 1, $dfd MUST be positive, and $nonc must
998: be non-negative.</td>
999: <td valign="top">Generate $item_cnt deviates of noncentral F (variance ratio)
1000: distribution with degrees of freedom $dfn (numerator) and $dfd (denominator).
1001: $nonc is the noncentrality parameter. </td>
1002: <td valign="top">New to LON-CAPA</td>
1003: </tr>
1004: <tr>
1.9 ng 1005: <td valign="top">NOT DOCUMENTED IN CAPA</td>
1006: <td valign="top">@return_array=&random_multivariate_normal ($item_cnt,$seed,\@mean,\@covar) <br>
1007: NOTE: @mean should be of length p array of real numbers. @covar should be a length
1008: p array of references to length p arrays of real numbers (i.e. a p by p matrix.</td>
1.5 ng 1009: <td valign="top">Generate $item_cnt deviates of multivariate_normal distribution with
1010: mean vector @mean and variance-covariance matrix. </td>
1.9 ng 1011: <td valign="top">Note the backslash before the @mean and @covar arrays.</td>
1.5 ng 1012: </tr>
1013: <tr>
1014: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
1015: <td valign="top">@return_array=&random_multinomial ($item_cnt,$seed,@p) <br>
1016: NOTE: $item_cnt is rounded with int() and the result must be non-negative.
1017: The number of elements in @p must be at least 2.</td>
1018: <td valign="top">Returns single observation from multinomial distribution with
1019: $item_cnt events classified into as many categories as the length of @p.
1020: The probability of an event being classified into category i is given by
1021: ith element of @p. The observation is an array with length equal to @p, so
1022: when called in a scalar context it returns the length of @p. The sum of the
1023: elements of the obervation is equal to $item_cnt.</td>
1024: <td valign="top">New to LON-CAPA</td>
1025: </tr>
1026: <tr>
1027: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
1.20 ! albertel 1028: <td valign="top">@return_array=&random_permutation ($seed,@array) </td>
1.5 ng 1029: <td valign="top">Returns @array randomly permuted.</td>
1030: <td valign="top">New to LON-CAPA</td>
1031: </tr>
1032: <tr>
1033: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
1034: <td valign="top">@return_array=&random_uniform ($item_cnt,$seed,$low,$high) <br>
1035: NOTE: $low must be less than or equal to $high.</td>
1036: <td valign="top">Generate $item_cnt deviates from a uniform distribution. </td>
1037: <td valign="top">New to LON-CAPA</td>
1038: </tr>
1039: <tr>
1040: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
1041: <td valign="top">@return_array=&random_uniform_integer ($item_cnt,$seed,$low,$high) <br>
1042: NOTE: $low and $high are both passed through int().
1043: $low must be less than or equal to $high.</td>
1044: <td valign="top">Generate $item_cnt deviates from a uniform distribution in integers. </td>
1045: <td valign="top">New to LON-CAPA</td>
1046: </tr>
1047: <tr>
1048: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
1049: <td valign="top">@return_array=&random_binomial ($item_cnt,$seed,$nt,$p) <br>
1050: NOTE: $nt is rounded using int() and the result must be non-negative.
1051: $p must be between 0 and 1 inclusive.</td>
1052: <td valign="top">Generate $item_cnt deviates from the binomial distribution with
1053: $nt trials and the probabilty of an event in each trial is $p. </td>
1054: <td valign="top">New to LON-CAPA</td>
1055: </tr>
1056: <tr>
1057: <td valign="top">NOT IMPLEMENTED IN CAPA</td>
1058: <td valign="top">@return_array=&random_negative_binomial ($item_cnt,$seed,$ne,$p) <br>
1059: NOTE: $ne is rounded using int() and the result must be positive.
1060: $p must be between 0 and 1 exclusive.</td>
1061: <td valign="top">Generate an array of $item_cnt outcomes generated from
1062: negative binomial distribution with
1063: $ne events and the probabilty of an event in each trial is $p. </td>
1064: <td valign="top">New to LON-CAPA</td>
1.4 ng 1065: </tr>
1.5 ng 1066: </table>
1067: <!-- insertion ends -->
1.4 ng 1068:
1.1 albertel 1069: <h2><script> Variables</h2>
1070: <ul>
1071: <li>
1072: $external::target - set to the current target the xml parser
1073: is parsing for
1074: </li>
1075: <li>
1076: $external::part - set to the <i>id</i> of the current problem
1.14 albertel 1077: <part>; zero if there are no <part>
1.1 albertel 1078: </li>
1079: <li>
1080: $external::gradestatus - set to the value of the current
1081: resource.partid.solved value
1082: </li>
1083: <li>
1084: $external::datestatus - set to the current status of the clock
1.14 albertel 1085: either CLOSED, CAN_ANSWER, CANNOT_ANSWER, SHOW_ANSWER, or UNCHECKEDOUT
1.1 albertel 1086: </li>
1087: <li>
1088: $external::randomseed - set to the number that was used to
1089: seed the random number generator
1090: </li>
1091: <li>$pi - set to PI </li>
1.3 ng 1092: <li>$rad2deg - converts radians to degrees </li>
1093: <li>$deg2rad - converts degrees to radians </li>
1.1 albertel 1094: </ul>
1.14 albertel 1095:
1096: <h2> Form internals </h2>
1097: <p> Form elements used for homework editing/response </p>
1098: <p> the form is named lonhomework </p>
1099: <h3> Viewing a problem (either CSTR or RES space)</h3>
1100: <ul>
1101: <li>
1102: grade_target, grade_username, grade_domain, grade_symb - the
1103: vaules take precedence over the the normal ENV settings of
1104: these, use &Apache::lonxml::whichuser() to get back the
1105: correct vaues of the items
1106: </li>
1107: <li>
1108: HWVAL_response:number - the name of the input elements for each response. The response is the response's ID, and the :number part exists only for response with multiple foils, and is a unique number in order of the submission
1109: </li>
1110: <li>
1111: changerandseed - the 'Change' button, only exists right after
1112: the Change button is clicked
1113: </li>
1114: <li>
1115: problemmode - in CSTR, it is either 'View','Edit','EditXML' or
1116: 'Analyze' depending on the desired view
1117: </li>
1118: <li>
1119: rndseed - the currently requested random seed
1120: </li>
1121: <li>
1122: showallfoils - if it exists, and we are in CSTR space, the
1123: problem should ignore <conceptgroup> and the response's
1124: max setting and show all possible foils
1125: </li>
1126: <li>
1127: submit - the name of the Submit button
1128: </li>
1129: <li>
1130: submitted - a hidden form parameter that can be used to tell
1131: if the student has submitted answers or not, if it is set,
1132: there should be answers to grade.
1133: </li>
1134: </ul>
1135: <h3> Editing a problem (Edit mode)</h3>
1136: <p> tagdepth referes to the current value of the xmlparsers tagdepth couter ($Apache::lonxml::currentdepth)</p>
1137: <p> Note: the file edit.pm has many helper functions for creating the standard elements for editing a tag and it's attributes, all of those functions follow these conventions </p>
1138: <ul>
1139: <li>
1140: tagdepth_argname - I.E. 1_3.max, a parameter editing value,
1141: max is the name of the parameter and it is for the third tag
1142: inside the first tag
1143: </li>
1144: <li>
1145: delete_tagdepth - if set to yes, delete tag tagdepth and all
1146: tags inside of it
1147: </li>
1148: <li>
1149: homework_edit_tagdepth - used by both &Apache::edit::editline
1150: and &Apache::edit::editfield for the <textarea> and
1151: <input> form elements they create
1152: </li>
1153: <li>
1154: insert_tagdepth - used to request an tag insert, it is set to
1155: the id number of the requested tag in the
1156: %Apache::lonxml::insertlist
1157: </ul>
1.1 albertel 1158: <hr>
1159: <address><a href="mailto:albertel@marvin.lite.msu.edu">Guy Albertelli</a></address>
1160: <!-- Created: Thu May 17 15:05:35 EDT 2001 -->
1161: <!-- hhmts start -->
1.20 ! albertel 1162: Last modified: Fri Oct 4 18:01:02 EDT 2002
1.1 albertel 1163: <!-- hhmts end -->
1164: </body>
1165: </html>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>