1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
2: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
3: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4: <!--
5: The LearningOnline Network with CAPA
6: Parameter Input Window
7: //
8: // $Id: parameter.html,v 1.71 2016/05/13 22:48:14 raeburn Exp $
9: //
10: // Copyright Michigan State University Board of Trustees
11: //
12: // This file is part of the LearningOnline Network with CAPA (LON-CAPA).
13: //
14: // LON-CAPA is free software; you can redistribute it and/or modify
15: // it under the terms of the GNU General Public License as published by
16: // the Free Software Foundation; either version 2 of the License, or
17: // (at your option) any later version.
18: //
19: // LON-CAPA is distributed in the hope that it will be useful,
20: // but WITHOUT ANY WARRANTY; without even the implied warranty of
21: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22: // GNU General Public License for more details.
23: //
24: // You should have received a copy of the GNU General Public License
25: // along with LON-CAPA; if not, write to the Free Software
26: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27: //
28: // /home/httpd/html/adm/gpl.txt
29: //
30: // http://www.lon-capa.org/
31: //
32: -->
33: <head>
34: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
35: <title>LON-CAPA</title>
36:
37: <script type="text/javascript">
38: // <![CDATA[
39:
40: var ptype='';
41: var pvalue='';
42: var pmodval='';
43: var pextraval='';
44: var pextravaltwo='';
45: var preturn='';
46: var pcode='';
47: var pscat='';
48: var pmarker='';
49: var pmodal='';
50: var pname='';
51:
52: var defhour=0;
53: var defmin=0;
54: var defsec=0;
55:
56: var svalue;
57: var stype;
58: var smarker;
59:
60: var vars=new Array();
61:
62: var cdate=new Date();
63:
64: var csec;
65: var cmin;
66: var chour;
67: var cday;
68:
69: var months=new Array();
70:
71:
72: function selwrite(text) {
73: this.window.selector.document.write(text);
74: }
75:
76: function choicestart() {
77: this.window.choices.document.open();
78: choicewrite('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
79: choicewrite('<html xmlns="http://www.w3.org/1999/xhtml">');
80: choicewrite('<head>');
81: choicewrite('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
82: choicewrite('<title>LON-CAPA</title>');
83: choicewrite('<style type="text/css">');
84: choicewrite('<!--');
85: choicewrite('body {');
86: choicewrite('font-family: Verdana,Arial,Helvetica,sans-serif;');
87: choicewrite('line-height:130%;');
88: choicewrite('font-size:0.83em;');
89: choicewrite('background: #FFFFFF;');
90: choicewrite('}');
91: choicewrite('table.LC_parmsel_table {font-size: 90%;}');
92: choicewrite('table.LC_parmsel_table tr td { padding: 5px; border: 1px solid #C8C8C8;}');
93: choicewrite('-->');
94: choicewrite('</style>');
95: choicewrite('</head>');
96: choicewrite('<body>');
97: }
98:
99: function choiceend() {
100: choicewrite('</body></html>');
101: this.window.choices.document.close();
102: }
103:
104: function choicewrite(text) {
105: this.window.choices.document.write(text);
106: }
107:
108: function tablestart(headtext) {
109: choicewrite('<table class="LC_parmsel_table"><tr bgcolor="#C5DB99"><th colspan="3">'+
110: headtext+'</th></tr>');
111: }
112:
113: function valline(text,id1,id2) {
114: choicewrite('<tr><td>'+text+
115: '</td><td><input type="text" size="4" name="val'+
116: id1+'" /></td><td>incl:<input type="checkbox" name="val'+
117: id2+'" /></td></tr>');
118: }
119:
120: function escapeHTML(text) {
121: text = text.replace(/&/g, '&');
122: text = text.replace(/"/g, '"');
123: text = text.replace(/</g, '<');
124: text = text.replace(/>/g, '>');
125: return text;
126: }
127:
128: function datecalc() {
129: var sform=choices.document.forms.sch;
130:
131: cdate.setHours(sform.hours.options[sform.hours.selectedIndex].value);
132: cdate.setMinutes(sform.minutes.options[sform.minutes.selectedIndex].value);
133: cdate.setSeconds(sform.minutes.options[sform.seconds.selectedIndex].value);
134: cdate.setDate(sform.date.options[sform.date.selectedIndex].value);
135: cdate.setMonth(sform.month.options[sform.month.selectedIndex].value);
136: cdate.setFullYear(sform.year.options[sform.year.selectedIndex].value);
137:
138: draw();
139: }
140:
141: function hour() {
142: var thishour=cdate.getHours();
143: var i; var j;
144: choicewrite('<select name="hours" onchange="parent.datecalc();">');
145: for (i=0;i<=23;i++) {
146: choicewrite('<option value="'+i+'"');
147: if (i==thishour) {
148: choicewrite(' selected="selected"');
149: }
150: choicewrite('>');
151: if (i==12) { choicewrite('noon'); } else {
152: if (i==0) { choicewrite('midnight') } else {
153:
154: if (i<12) { choicewrite(i+' am'); } else {
155: j=i-12; choicewrite(j+' pm');
156: }
157:
158: }
159: }
160: choicewrite('</option>');
161: }
162: choicewrite('</select>');
163: }
164:
165: function minute() {
166: var thisminutes=cdate.getMinutes();
167: var i;
168: choicewrite('<select name="minutes" onchange="parent.datecalc();">');
169: for (i=0;i<=59;i++) {
170: choicewrite('<option value="'+i+'"');
171: if (i==thisminutes) {
172: choicewrite(' selected="selected"');
173: }
174: choicewrite('>'+i+'</option>');
175: }
176: choicewrite('</select>');
177: }
178:
179: function second() {
180: var thisseconds=cdate.getSeconds();
181: var i;
182: choicewrite('<select name="seconds" onchange="parent.datecalc();">');
183: for (i=0;i<=59;i++) {
184: choicewrite('<option value="'+i+'"');
185: if (i==thisseconds) {
186: choicewrite(' selected="selected"');
187: }
188: choicewrite('>'+i+'</option>');
189: }
190: choicewrite('</select>');
191: }
192:
193:
194: function date() {
195: var thisdate=cdate.getDate();
196: var i;
197: choicewrite('<select name="date" onchange="parent.datecalc();">');
198: for (i=1;i<=31;i++) {
199: choicewrite('<option value="'+i+'"');
200: if (i==thisdate) {
201: choicewrite(' selected="selected"');
202: }
203: choicewrite('>'+i+'</option>');
204: }
205: choicewrite('</select>');
206: }
207:
208: function year() {
209: var thisyear=cdate.getFullYear();
210: var nowdate=new Date();
211: var nowyear=nowdate.getFullYear();
212: if ( !thisyear ) { thisyear=nowyear; }
213: var loweryear=thisyear-2;
214: var upperyear=thisyear+5;
215: if (thisyear>nowyear) { loweryear=nowyear-2; }
216: if (thisyear<nowyear) { upperyear=nowyear+5; }
217: var i;
218: choicewrite('<select name="year" onchange="parent.datecalc();">');
219: for (i=loweryear;i<=upperyear;i++) {
220: choicewrite('<option value="'+i+'"');
221: if (i==thisyear) {
222: choicewrite(' selected="selected"');
223: }
224: choicewrite('>'+i+'</option>');
225: }
226: choicewrite('</select>');
227: }
228:
229: function month() {
230: var thismonth=cdate.getMonth();
231: var i;
232: choicewrite('<select name="month" onchange="parent.datecalc();">');
233: for (i=0;i<=11;i++) {
234: choicewrite('<option value="'+i+'"');
235: if (i==thismonth) {
236: choicewrite(' selected="selected"');
237: }
238: choicewrite('>'+months[i]+'</option>');
239: }
240: choicewrite('</select>');
241: }
242:
243:
244: function intminute() {
245: var thisminutes=cmins;
246: var i;
247: var result = '';
248: result += '<select name="minutes" onchange="parent.intcalc();">';
249: for (i=0;i<=59;i++) {
250: result += '<option value="'+i+'"';
251: if (i==thisminutes) {
252: result += ' selected="selected"';
253: }
254: result += '>'+i+'</option>';
255: }
256: result += '</select>';
257: return result;
258: }
259:
260: function inthour() {
261: var thishours=chours;
262: var i;
263: var result = '';
264: result += '<select name="hours" onchange="parent.intcalc();">';
265: for (i=0;i<=23;i++) {
266: result += '<option value="'+i+'"';
267: if (i==thishours) {
268: result += ' selected="selected"';
269: }
270: result += '>'+i+'</option>';
271: }
272: result += '</select>';
273: return result;
274: }
275:
276: function intsecond() {
277: var thisseconds=csecs;
278: var i;
279: var result = '';
280: result += '<select name="seconds" onchange="parent.intcalc();">';
281: for (i=0;i<=59;i++) {
282: result += '<option value="'+i+'"';
283: if (i==thisseconds) {
284: result += ' selected="selected"';
285: }
286: result += '>'+i+'</option>';
287: }
288: result += '</select>';
289: return result;
290: }
291:
292:
293: function intday() {
294: var thisdate=cdays;
295: var i;
296: var result ='';
297: result += '<select name="date" onchange="parent.intcalc();">';
298: for (i=0;i<=31;i++) {
299: result += '<option value="'+i+'"';
300: if (i==thisdate) {
301: result += ' selected="selected"';
302: }
303: result += '>'+i+'</option>';
304: }
305: result += '</select>';
306: return result;
307: }
308:
309: function intcalc() {
310: var sform=choices.document.forms.sch;
311: svalue=((sform.date.options[sform.date.selectedIndex].value*24+
312: sform.hours.options[sform.hours.selectedIndex].value*1)*60+
313: sform.minutes.options[sform.minutes.selectedIndex].value*1)*60+
314: sform.seconds.options[sform.seconds.selectedIndex].value*1;
315: if ((ptype=='date') && (pscat=='interval')) {
316: var newpmodval = '';
317: var newpextraval = '';
318: var newpextravaltwo = 'Done';
319: if (sform.donebutton.length) {
320: for (var i=0; i<sform.donebutton.length; i++) {
321: if (sform.donebutton[i].checked) {
322: if (sform.donebutton[i].value == '_done') {
323: newpmodval = sform.donebutton[i].value;
324: newpextravaltwo = sform.donebutton_text.value;
325: } else {
326: if (sform.donebutton[i].value == '_done_proctor') {
327: newpmodval = sform.donebutton[i].value;
328: newpextraval = sform.donebutton_proctorkey.value;
329: newpextravaltwo = sform.donebutton_text.value;
330: newpextravaltwo = newpextravaltwo.replace(/:/g,'');
331: }
332: }
333: }
334: }
335: }
336: pmodval = newpmodval;
337: pextraval = newpextraval;
338: pextravaltwo = newpextravaltwo;
339: draw();
340: if (pmodval) {
341: var doneRegExp = /^(_done)(|_proctor)$/;
342: var donevals = pmodval.match(doneRegExp);
343: if (donevals.length == 3) {
344: svalue += donevals[1];
345: }
346: if (newpextravaltwo) {
347: if (newpextravaltwo != 'Done') {
348: svalue += ':'+newpextravaltwo+':';
349: }
350: }
351: if (donevals[2] != '') {
352: svalue += donevals[2];
353: if (pextraval != '') {
354: svalue += '_'+pextraval;
355: }
356: }
357: }
358: } else {
359: draw();
360: }
361: }
362:
363: function toggleSecret() {
364: var sform=choices.document.forms.sch;
365: if (sform.donebutton.length) {
366: for (var i=0; i<sform.donebutton.length; i++) {
367: if (sform.donebutton[i].checked) {
368: if (sform.donebutton[i].value == '') {
369: if (document.getElementById('donebuttontextdiv')) {
370: document.getElementById('donebuttontextdiv').style.display='none';
371: }
372: } else {
373: if (document.getElementById('donebuttontextdiv')) {
374: document.getElementById('donebuttontextdiv').style.display='block';
375: }
376: }
377: if (sform.donebutton[i].value == '_done_proctor') {
378: if (document.getElementById('done_proctorkey')) {
379: document.getElementById('done_proctorkey').type='text';
380: }
381: } else {
382: if (document.getElementById('done_proctorkey')) {
383: document.getElementById('done_proctorkey').type='hidden';
384: document.getElementById('done_proctorkey').value='';
385: }
386: }
387: }
388: }
389: }
390: }
391:
392: function validateInterval() {
393: var sform=choices.document.forms.sch;
394: if (sform.donebutton.length) {
395: for (var i=0; i<sform.donebutton.length; i++) {
396: if (sform.donebutton[i].checked) {
397: if (sform.donebutton[i].value == '_done_proctor') {
398: if ((sform.donebutton_proctorkey.value == '') ||
399: (sform.donebutton_proctorkey.value == null)) {
400: alert('Please provide a key for a proctor to enter when a student uses the "Done" button.');
401: return;
402: }
403: }
404: }
405: }
406: }
407: intcalc();
408: assemble();
409: }
410:
411: function integereval() {
412: svalue=choices.document.forms.sch.intval.value;
413: svalue=Math.round(svalue);
414: if (pscat=='zeropos') { svalue=Math.abs(svalue); }
415: if ((pscat=='pos') && (svalue==0)) {
416: svalue='';
417: }
418: if (pscat.indexOf('inrange')!=-1) {
419: var rangeparts=new Array;
420: rangeparts=split('_',pscat);
421: rangeparts=split(',',rangeparts[1]);
422: if (svalue<rangeparts[0]) { svalue=rangeparts[0]; }
423: if (svalue>rangeparts[1]) { svalue=rangeparts[1]; }
424: }
425: draw();
426: }
427:
428: function floateval() {
429: svalue=choices.document.forms.sch.floatval.value;
430: svalue=1.0*svalue;
431: if (pscat=='pos') { svalue=Math.abs(svalue); }
432: if ((pscat=='zeroone') && ((svalue<0) || (svalue>1))) {
433: svalue='';
434: }
435: draw();
436: }
437:
438: function stringeval() {
439: svalue=choices.document.forms.sch.stringval.value;
440: draw();
441: }
442:
443: function radiostringeval(newval) {
444: svalue=newval;
445: draw();
446: }
447:
448: function callradiostringeval(newval) {
449: return 'onclick="parent.radiostringeval(\''+newval+'\')"';
450: }
451:
452: function callintervalpmodval() {
453: return 'onclick="parent.intcalc();parent.toggleSecret()"';
454: }
455:
456: function intervaldis() {
457: csecs=svalue;
458: cdays=Math.floor(csecs/86400);
459: csecs-=cdays*86400;
460: chours=Math.floor(csecs/3600);
461: csecs-=chours*3600;
462: cmins=Math.floor(csecs/60);
463: csecs-=cmins*60;
464: return cdays+' days '+chours+' hours '+cmins+' mins '+csecs+' secs';
465: }
466:
467: function pickcolor(picked) {
468: svalue=picked;
469: draw();
470: }
471:
472: function colorfield(ir,ig,ib) {
473: var col=new Array;
474: col=["00","11","22","44","66","88","AA","CC","DD","EE","FF"];
475: var color='#'+col[ir]+col[ig]+col[ib];
476: var selection="<font color='"+color+"'>X</font>";
477: if (color==svalue) { selection="<font color='#"+col[10-ir]+col[10-ig]+col[10-ib]+"'>X</font>"; }
478: choicewrite('<td bgcolor="'+color+'"><a href="javascript:parent.pickcolor('+"'"+
479: color+"'"+')">'+selection+'</a></td>');
480:
481: }
482:
483: function draw() {
484: choicestart();
485: choicewrite('<form name="sch"');
486: if (ptype=='int') {
487: choicewrite(' action="javascript:integereval();"');
488: }
489: if (ptype=='float') {
490: choicewrite(' action="javascript:floateval();"');
491: }
492: if (ptype=='string') {
493: choicewrite(' action="javascript:stringeval();"');
494: }
495: if (ptype != 'int' && ptype != 'float' && ptype != 'string') {
496: choicewrite(' action=""');
497: }
498: choicewrite('>');
499: if (ptype=='tolerance') {
500: // 0: pscat
501: if (pscat=='default') {
502: tablestart('Use default value or algorithm of resource');
503: }
504: if (pscat=='relative_sym') {
505: // 2: percentage
506: // 3: open
507: tablestart('Percentage error, symmetric around value');
508: valline('Percentage',2,3);
509: if ((svalue!='') && (typeof(svalue)!="undefined")) {
510: choices.document.forms.sch.val2.value=parseInt(svalue);
511: if (svalue.indexOf('+')!=-1) {
512: choices.document.forms.sch.val3.checked=true;
513: }
514: }
515: }
516: if (pscat=='relative') {
517: // 2: left
518: // 3: open
519: // 4: right
520: // 5: open
521: tablestart('Percentage error, asymmetric around value');
522: valline('Upper percentage',2,3);
523: valline('Lower percentage',4,5);
524: var range1=new Array;
525: if ((svalue!='') && (typeof(svalue)!="undefined")) {
526: range1=svalue.split(',');
527: if (typeof(range1[1])=='undefined') { range1[1]=range1[0]; }
528: choices.document.forms.sch.val2.value=parseFloat(range1[0]);
529: if (range1[0].indexOf('+')!=-1) {
530: choices.document.forms.sch.val3.checked=true;
531: }
532: choices.document.forms.sch.val4.value=parseFloat(range1[1]);
533: if (range1[1].indexOf('+')!=-1) {
534: choices.document.forms.sch.val5.checked=true;
535: }
536: }
537: }
538: if (pscat=='absolute_sym') {
539: tablestart('Absolute error, symmetric around value');
540: valline('Value',2,3);
541: if ((svalue!='') && (typeof(svalue)!="undefined")) {
542: choices.document.forms.sch.val2.value=parseFloat(svalue);
543: if (svalue.indexOf('+')!=-1) {
544: choices.document.forms.sch.val3.checked=true;
545: }
546: }
547: }
548: if (pscat=='absolute') {
549: tablestart('Absolute error, asymmetric around value');
550: valline('Upper value',2,3);
551: valline('Lower value',4,5);
552: var range2=new Array;
553: if ((svalue!='') && (typeof(svalue)!="undefined")) {
554: range=svalue.split(',');
555: if (typeof(range2[1])=='undefined') { range2[1]=range2[0]; }
556: choices.document.forms.sch.val2.value=parseFloat(range2[0]);
557: if (range2[0].indexOf('+')!=-1) {
558: choices.document.forms.sch.val3.checked=true;
559: }
560: choices.document.forms.sch.val4.value=parseFloat(range2[1]);
561: if (range2[1].indexOf('+')!=-1) {
562: choices.document.forms.sch.val5.checked=true;
563: }
564: }
565: }
566: }
567:
568: if (ptype=='date') {
569: if (pscat=='default') {
570: tablestart('Default value or none');
571: choicewrite('</table>');
572: } else {
573: if (pscat=='start') {
574: tablestart('Date and time');
575: }
576: if (pscat=='end') {
577: tablestart('Date and time');
578: }
579: if (pscat=='interval') {
580: var proctorkeytype = 'hidden';
581: var donebuttontext = 'none';
582: if (pmodval == '_done_proctor') {
583: proctorkeytype = 'text';
584: donebuttontext = 'block';
585: }
586: if (pmodval == '_done') {
587: donebuttontext = 'block';
588: }
589: tablestart('Time interval');
590: choicewrite( [
591: '<tr><td colspan="3">'+intervaldis()+'</td></tr>',
592: '<tr><td>Time:</td><td colspan="2">',
593: '<span style="white-space:nowrap">'+intday()+' days </span>',
594: '<span style="white-space:nowrap">'+inthour()+' hours</span>',
595: '<span style="white-space:nowrap">'+intminute()+' mins</span>',
596: '<span style="white-space:nowrap">'+intsecond()+' secs</span>',
597: '</td></tr>',
598: '</table>',
599: '<br />',
600: ].join("\n"));
601: tablestart('Provide a "Done" button to students?');
602: choicewrite('<tr><td>Value:</td><td colspan="2">');
603: choicewrite('<label><input name="donebutton" value=""'+
604: ' type="radio" '+callintervalpmodval());
605: if (pmodval == '') { choicewrite(' checked="checked"'); }
606: choicewrite(' /> No</label><br />');
607: choicewrite('<label><input name="donebutton" value="_done"'+
608: ' type="radio" '+callintervalpmodval());
609: if (pmodval == '_done') { choicewrite(' checked="checked"'); }
610: choicewrite(' /> Yes</label><br />');
611: choicewrite('<span style="white-space:nowrap">'+
612: '<label><input name="donebutton" value="_done_proctor"'+
613: ' type="radio" '+callintervalpmodval());
614: if (pmodval == '_done_proctor') { choicewrite(' checked="checked"'); }
615: choicewrite(' /> Yes, with proctor key</label>');
616: choicewrite(' <input name="donebutton_proctorkey" value='+
617: '"'+escapeHTML(pextraval)+'" type="'+proctorkeytype+
618: '" id="done_proctorkey" size="10"'+
619: ' onblur="parent.intcalc();" /></span><br />'+
620: '<div id="donebuttontextdiv" style="display:'+donebuttontext+'">'+
621: '<br /><span style="white-space:nowrap">'+
622: 'Button text:'+
623: '<input name="donebutton_text" value='+
624: '"'+escapeHTML(pextravaltwo)+'" type="text" '+
625: 'size="10" onblur="parent.intcalc();" /></span></div>');
626: choicewrite('</td></tr></table>');
627: } else {
628: choicewrite('<tr><td colspan="3">'
629: +cdate.toString()+
630: '</td></tr><tr><td>Date:</td><td colspan="2">');
631: month();date();year();
632: choicewrite('</td></tr><tr><td>Time:'
633: +'</td><td colspan="2">');hour();choicewrite('h ');minute();
634: choicewrite('m ');second();
635: choicewrite('s</td></tr></table>');
636: }
637: }
638: }
639:
640: if (ptype=='int') {
641: var pscatparts=new Array;
642: pscatparts=pscat.split(',');
643: pscat=pscatparts[0];
644: if (pscat=='default') {
645: tablestart('Default value or none');
646: choicewrite('</table>');
647: } else {
648: if (pscat=='range') {
649: tablestart('Integer range');
650: choicewrite('<tr><td>Lower Value:'+
651: '</td><td colspan="2"><input type="text" size="4" name="val2'+
652: '" /></td></tr>');
653: choicewrite('<tr><td>Upper Value:'+
654: '</td><td colspan="2"><input type="text" size="4" name="val4'+
655: '" /></td></tr></table>');
656: var range=new Array;
657: if ((svalue!='') && (typeof(svalue)!="undefined")) {
658: range=svalue.split(',');
659: if (typeof(range[1])=='undefined') { range[1]=range[0]; }
660: choices.document.forms.sch.val2.value=parseInt(range[0]);
661: choices.document.forms.sch.val4.value=parseInt(range[1]);
662: }
663: } else {
664: if (pscat=='pos') {
665: tablestart('Positive (non-zero) integer');
666: }
667: if (pscat=='zeropos') {
668: tablestart('Positive integer or zero');
669: }
670: if (pscat.indexOf('inrange')!=-1) {
671: var rangeparts=new Array;
672: rangeparts=split(',',pscat);
673: tablestart('Integer in the range ['+rangeparts[1]+']');
674: }
675: if (pscat=='any') {
676: tablestart('Integer');
677: }
678: choicewrite('<tr><td>Value:</td><td colspan="2">');
679: choicewrite('<input name="intval" size="10" value="'+escapeHTML(svalue)+
680: '" onchange="parent.integereval()" />');
681: choicewrite('</td></tr></table>');
682: }
683: }
684: }
685:
686: if (ptype=='float') {
687: if (pscat=='default') {
688: tablestart('Default value or none');
689: choicewrite('</table>');
690: } else {
691: if (pscat=='pos') {
692: tablestart('Positive floating point number or zero');
693: }
694: if (pscat=='zeroone') {
695: tablestart('Floating point number between zero and one');
696: }
697: if (pscat=='any') {
698: tablestart('Floating point number');
699: }
700: choicewrite('<tr><td>Value:</td><td colspan="2">');
701: choicewrite('<input name="floatval" size="10" value="'+escapeHTML(svalue)+
702: '" onchange="parent.floateval()" />');
703: choicewrite('</td></tr></table>');
704: }
705: }
706:
707: if (ptype=='string') {
708: if ((pscat=='any') || (pscat=='') || (pscat=='default') ||
709: (typeof(pscat)=='undefined')) {
710: tablestart('Text');
711: choicewrite('<tr><td>Value:</td><td colspan="2">');
712: choicewrite('<input name="stringval" size="20" value="'+escapeHTML(svalue)+
713: '" type="text" onchange="parent.stringeval()" />');
714: }
715: if (pscat=='yesno') {
716: tablestart('Yes/No');
717: choicewrite('<tr><td>Value:</td><td colspan="2">');
718: choicewrite('<label><input name="stringval" value="yes"'+
719: ' type="radio" '+callradiostringeval('yes'));
720: if (svalue=='yes') { choicewrite(' checked="checked"'); }
721: choicewrite(' /> Yes</label><br />');
722: choicewrite('<label><input name="stringval" value="no"'+
723: ' type="radio" '+callradiostringeval('no'));
724: if (svalue=='no') { choicewrite(' checked="checked"'); }
725: choicewrite(' /> No</label><br />');
726: }
727: if (pscat=='problemstatus') {
728: tablestart('Problem Status');
729: choicewrite('<tr><td>Value:</td><td colspan="2">');
730: choicewrite('<label><input name="stringval" value="yes"'+
731: ' type="radio" '+callradiostringeval('yes'));
732: if (svalue=='yes') { choicewrite(' checked="checked"'); }
733: choicewrite(' /> Yes</label><br />');
734: choicewrite('<label><input name="stringval" value="answer"'+
735: ' type="radio" '+callradiostringeval('answer'));
736: if (svalue=='answer') { choicewrite(' checked="checked"'); }
737: choicewrite(' /> Yes, and show correct answer if they exceed the maximum number of tries.</label><br />');
738: choicewrite('<label><input name="stringval" value="no"'+
739: ' type="radio" '+callradiostringeval('no'));
740: if (svalue=='no') { choicewrite(' checked="checked"'); }
741: choicewrite(' /> No, don\'t show correct/incorrect feedback.</label><br />');
742: choicewrite('<label><input name="stringval" value="no_feedback_ever"'+
743: ' type="radio" '+callradiostringeval('no_feedback_ever'));
744: if (svalue=='no_feedback_ever') { choicewrite(' checked="checked"'); }
745: choicewrite(' /> No, show no feedback at all.</label><br />');
746: }
747: if (pscat=='examtype') {
748: tablestart('Exam Type');
749: choicewrite('<tr><td>Value:</td><td colspan="2">');
750: choicewrite('<label><input name="stringval" value="online"'+
751: ' type="radio" '+callradiostringeval('online'));
752: if (svalue=='online') { choicewrite(' checked="checked"'); }
753: choicewrite(' /> Online</label><br />');
754: choicewrite('<label><input name="stringval" value="checkout"'+
755: ' type="radio" '+callradiostringeval('checkout'));
756: if (svalue=='checkout') { choicewrite(' checked="checked"'); }
757: choicewrite(' /> Check out</label><br />');
758: }
759: if (pscat=='questiontype') {
760: tablestart('Question Type');
761: choicewrite('<tr><td>Value:</td><td colspan="2">');
762: choicewrite('<label><input name="stringval" value="problem"'+
763: ' type="radio" '+callradiostringeval('problem'));
764: if (svalue=='problem') { choicewrite(' checked="checked"'); }
765: choicewrite(' /> Standard Problem</label><br />');
766: // choicewrite('<label><input name="stringval" value="quiz"'+
767: // ' type="radio" '+callradiostringeval('quiz'));
768: // if (svalue=='quiz') { choicewrite(' checked="checked"'); }
769: // choicewrite(' /> Quiz</label><br />');
770: choicewrite('<label><input name="stringval" value="practice"'+
771: ' type="radio" '+callradiostringeval('practice'));
772: if (svalue=='practice') { choicewrite(' checked="checked"'); }
773: choicewrite(' /> Practice</label><br />');
774: choicewrite('<label><input name="stringval" value="exam"'+
775: ' type="radio" '+callradiostringeval('exam'));
776: if (svalue=='exam') { choicewrite(' checked="checked"'); }
777: choicewrite(' /> Bubblesheet Exam</label><br />');
778: // choicewrite('<label><input name="stringval" value="assess"'+
779: // ' type="radio" '+callradiostringeval('assess'));
780: // if (svalue=='assess') { choicewrite(' checked="checked"'); }
781: // choicewrite(' /> Assessment</label><br />');
782: choicewrite('<label><input name="stringval" value="survey"'+
783: ' type="radio" '+callradiostringeval('survey'));
784: if (svalue=='survey') { choicewrite(' checked="checked"'); }
785: choicewrite(' /> Survey</label><br />');
786: // choicewrite('<label><input name="stringval" value="form"'+
787: // ' type="radio" '+callradiostringeval('form'));
788: // if (svalue=='form') { choicewrite(' checked="checked"'); }
789: // choicewrite('> Input Form</label><br />');
790: choicewrite('<label><input name="stringval" value="surveycred"'+
791: ' type="radio" '+callradiostringeval('surveycred'));
792: if (svalue=='surveycred') { choicewrite(' checked="checked"'); }
793: choicewrite('> Survey (credit for submission)</label><br />');
794: choicewrite('<label><input name="stringval" value="anonsurvey"'+
795: ' type="radio" '+callradiostringeval('anonsurvey'));
796: if (svalue=='anonsurvey') { choicewrite(' checked="checked"'); }
797: choicewrite('> Anonymous Survey</label><br />');
798: choicewrite('<label><input name="stringval" value="anonsurveycred"'+
799: ' type="radio" '+callradiostringeval('anonsurveycred'));
800: if (svalue=='anonsurveycred') { choicewrite(' checked="checked"'); }
801: choicewrite('> Anonymous Survey (credit for submission)</label><br />');
802: choicewrite('<label><input name="stringval" value="randomizetry"'+
803: ' type="radio" '+callradiostringeval('randomizetry'));
804: if (svalue=='randomizetry') { choicewrite(' checked="checked"'); }
805: choicewrite('> New Randomization Each N Tries (default N=1)</label><br />');
806: choicewrite('<label><input name="stringval" value="library"'+
807: ' type="radio" '+callradiostringeval('library'));
808: if (svalue=='library') { choicewrite(' checked="checked"'); }
809: choicewrite(' /> Library</label><br />');
810: }
811: if (pscat=='lenient') {
812: tablestart('Lenient Grading (Partial Credit)');
813: choicewrite('<tr><td>Value:</td><td colspan="2">');
814: choicewrite('<label><input name="stringval" value="yes"'+
815: ' type="radio" '+callradiostringeval('yes'));
816: if (svalue=='yes') { choicewrite(' checked="checked"'); }
817: choicewrite(' /> Yes</label><br />');
818: choicewrite('<label><input name="stringval" value="no"'+
819: ' type="radio" '+callradiostringeval('no'));
820: if (svalue=='no') { choicewrite(' checked="checked"'); }
821: choicewrite(' /> No</label><br />');
822: choicewrite('<label><input name="stringval" value="default"'+
823: ' type="radio" '+callradiostringeval('default'));
824: if (svalue=='default') { choicewrite(' checked="checked"'); }
825: choicewrite(' /> Default (only bubblesheet grading is lenient)</label><br />');
826: }
827: if (pscat=='discussvote') {
828: tablestart('Discussion Voting');
829: choicewrite('<tr><td>Value:</td><td colspan="2">');
830: choicewrite('<label><input name="stringval" value="yes"'+
831: ' type="radio" '+callradiostringeval('yes'));
832: if (svalue=='yes') { choicewrite(' checked="checked"'); }
833: choicewrite(' /> Yes</label><br />');
834: choicewrite('<label><input name="stringval" value="notended"'+
835: ' type="radio" '+callradiostringeval('notended'));
836: if (svalue=='notended') { choicewrite(' checked="checked"'); }
837: choicewrite(' /> Yes, unless discussion ended</label><br />');
838: choicewrite('<label><input name="stringval" value="no"'+
839: ' type="radio" '+callradiostringeval('no'));
840: if (svalue=='no') { choicewrite(' checked="checked"'); }
841: choicewrite(' /> No</label><br />');
842: }
843: if (pscat=='ip') {
844: tablestart('IP Number/Name');
845: choicewrite('<tr><td>Value:</td><td colspan="2">');
846: choicewrite('<input name="stringval" size="20" value="'+escapeHTML(svalue)+
847: '" onchange="parent.stringeval()" />');
848: }
849: if (pscat=='fileext') {
850: tablestart('Allowed File Extensions');
851: choicewrite('<tr><td>Value:</td><td colspan="2">');
852: choicewrite('<label><input name="radstringval" value="txt"'+
853: ' type="radio" '+callradiostringeval('txt'));
854: if (svalue=='txt') { choicewrite(' checked="checked"'); }
855: choicewrite(' /> Plain Text</label><br />');
856: choicewrite('<label><input name="radstringval" value="png,jpg,jpeg,gif"'+
857: ' type="radio" '+callradiostringeval('png,jpg,jpeg,gif'));
858: if (svalue=='png,jpg,jpeg,gif') { choicewrite(' checked="checked"'); }
859: choicewrite(' /> Picture File</label><br />');
860: choicewrite('<label><input name="radstringval" value="doc,docx,xls,xlsx,ppt,pptx"'+
861: ' type="radio" '+callradiostringeval('doc,docx,xls,xlsx,ppt,pptx'));
862: if (svalue=='doc,docx,xls,xlsx,ppt,pptx') { choicewrite(' checked="checked"'); }
863: if (svalue=='doc,xls,ppt') { choicewrite(' checked="checked"'); }
864: choicewrite(' /> Office Document</label><br />');
865: choicewrite('<input name="stringval" size="20" value="'+escapeHTML(svalue)+
866: '" onchange="parent.stringeval()" />');
867: }
868: if (pscat=='useslots') {
869: tablestart('Slots control access');
870: choicewrite('<tr><td>Value:</td><td colspan="2">');
871: choicewrite('<label><input name="stringval" value="no"'+
872: ' type="radio" '+callradiostringeval('no'));
873: if (svalue=='no') { choicewrite(' checked="checked"'); }
874: choicewrite(' /> No</label><br />');
875: choicewrite('<label><input name="stringval" value="resource"'+
876: ' type="radio" '+callradiostringeval('resource'));
877: if (svalue=='resource') { choicewrite(' checked="checked"'); }
878: choicewrite(' /> Yes, and the scope of student selected slot is a single resource.</label><br />');
879: choicewrite('<label><input name="stringval" value="map"'+
880: ' type="radio" '+callradiostringeval('map'));
881: if (svalue=='map') { choicewrite(' checked="checked"'); }
882: choicewrite(' /> Yes, and the scope of student selected slot is the enclosing map/folder. When checking in, it applies to only one resource.</label><br />');
883: choicewrite('<label><input name="stringval" value="map_map"'+
884: ' type="radio" '+callradiostringeval('map_map'));
885: if (svalue=='map_map') { choicewrite(' checked="checked"'); }
886: choicewrite(' /> Yes, and the scope of student selected slot is the enclosing map/folder. When checking in, all resources in the map/folder are checked in.</label><br />');
887: choicewrite('</td></tr></table>');
888: }
889: }
890:
891: if (ptype=='color') {
892: tablestart('Choose a Color');
893: choicewrite('<table>');
894: if (svalue) {
895: choicewrite('<tr><td colspan="9">Current choice:</td><td bgcolor="'+
896: escapeHTML(svalue)+'" colspan="2"> </td></tr>');
897: }
898: for (var ir=0; ir<=10; ir++) {
899: for (var ig=0; ig<=10; ig++) {
900: choicewrite('<tr>');
901: for (var ib=0; ib<=10; ib++) {
902: colorfield(ir,ig,ib);
903: }
904: choicewrite('</tr>');
905: }
906: }
907: choicewrite('</table></td></table>');
908: }
909:
910: choicewrite('</form>');
911: choiceend();
912: }
913:
914: function sopt(va,text) {
915: selwrite('<option value="'+va+'"');
916: if (va==pscat) {
917: selwrite(' selected="selected"');
918: }
919: selwrite('>'+text+'</option>');
920: }
921:
922: function catchange() {
923: var sform=selector.document.forms.fsel.fcat;
924: pscat=sform.options[sform.selectedIndex].value;
925: draw();
926: }
927:
928: function assemble() {
929: if ((ptype=='date') && (pscat!='interval')) {
930: svalue=Math.floor(cdate.getTime()/1000);
931: }
932: if (ptype=='tolerance') {
933: if (pscat=='relative_sym') {
934: svalue=choices.document.forms.sch.val2.value+'%';
935: if (choices.document.forms.sch.val3.checked) {
936: svalue+='+';
937: }
938: }
939: if (pscat=='absolute_sym') {
940: svalue=choices.document.forms.sch.val2.value;
941: if (choices.document.forms.sch.val3.checked) {
942: svalue+='+';
943: }
944: }
945: if (pscat=='absolute') {
946: svalue=choices.document.forms.sch.val2.value;
947: if (choices.document.forms.sch.val3.checked) {
948: svalue+='+';
949: }
950: svalue+=','+choices.document.forms.sch.val4.value;
951: if (choices.document.forms.sch.val5.checked) {
952: svalue+='+';
953: }
954: }
955: if (pscat=='relative') {
956: svalue=choices.document.forms.sch.val2.value+'%';
957: if (choices.document.forms.sch.val3.checked) {
958: svalue+='+';
959: }
960: svalue+=','+choices.document.forms.sch.val4.value+'%';
961: if (choices.document.forms.sch.val5.checked) {
962: svalue+='+';
963: }
964: }
965: }
966: if ((ptype=='int') && (pscat=='range')) {
967: svalue=choices.document.forms.sch.val2.value+','+
968: choices.document.forms.sch.val4.value;
969: }
970: if (pscat=='default') { svalue=''; }
971: stype=ptype+'_'+pscat;
972: }
973:
974:
975: function init() {
976: var i;
977: var subs=new Array();
978: var doneRegExp = /_done(|\:[^\:]+\:)/;
979: var doneproctorRegExp = /_done(|\:[^\:]+\:)_proctor/;
980: var proctorkeyRegExp = /^(\d+)_(.+)$/;
981: var donetextRegExp = /\:([^\:]+)\:/;
982: var namevalue=this.window.location.search.split('&');
983: namevalue[0]=namevalue[0].substr(1,namevalue[0].length-1);
984:
985: for (i=0;i<namevalue.length;i++) {
986: var pair=namevalue[i].split('=');
987: pair[1]=unescape(pair[1]);
988: if (pair[0]=='value') { pvalue=pair[1]; }
989: if (pair[0]=='type') { subs=pair[1].split('_');
990: ptype=subs[0];
991: pscat=subs[1];
992: if (typeof(subs[2])!="undefined") {
993: pscat+='_'+subs[2];
994: }
995: if ((pscat=='') || (typeof(pscat)=="undefined")) {
996: pscat='default';
997: }
998: }
999: if (pair[0]=='return') { preturn=pair[1]; }
1000: if (pair[0]=='call') { pcode=pair[1]; }
1001: if (pair[0]=='marker') { pmarker=pair[1]; }
1002: if (pair[0]=='name') { pname=pair[1]; }
1003: if (pair[0]=='modal') { pmodal=pair[1]; }
1004: if (pair[0]=='defhour' && pair[1] >= 0 && pair[1] < 24 ) {
1005: defhour=pair[1];
1006: }
1007: if (pair[0]=='defmin' && pair[1] >= 0 && pair[1] < 60) { defmin=pair[1]; }
1008: if (pair[0]=='defsec' && pair[1] >= 0 && pair[1] < 60) { defsec=pair[1]; }
1009: }
1010:
1011: if (ptype=='date' && pscat == 'interval') {
1012: if (doneproctorRegExp.test(pvalue)) {
1013: var current = pvalue.match(doneproctorRegExp);
1014: if (current.length == 2) {
1015: var textstr = current[1];
1016: if (textstr != '') {
1017: var textvals = textstr.match(donetextRegExp);
1018: if (textvals.length == 2) {
1019: pextravaltwo = textvals[1];
1020: }
1021: }
1022: }
1023: var intervalwithkey = pvalue.replace(doneproctorRegExp,'');
1024: if (proctorkeyRegExp.test(intervalwithkey)) {
1025: var currvals = intervalwithkey.match(proctorkeyRegExp);
1026: if (currvals.length == 3) {
1027: pvalue = currvals[1];
1028: pextraval = currvals[2];
1029: pmodval = '_done_proctor';
1030: } else {
1031: pmodval = '';
1032: }
1033: }
1034: } else {
1035: if (doneRegExp.test(pvalue)) {
1036: var current = pvalue.match(doneRegExp);
1037: if (current.length == 2) {
1038: var textstr = current[1];
1039: if (textstr != '') {
1040: var textvals = textstr.match(donetextRegExp);
1041: if (textvals.length == 2) {
1042: pextravaltwo = textvals[1];
1043: }
1044: }
1045: }
1046: var pnumval = pvalue.replace(doneRegExp,'');
1047: pmodval = '_done';
1048: pvalue = pnumval;
1049: }
1050: }
1051: }
1052: svalue=pvalue;
1053: if (((ptype=='float') || (ptype=='string') || (ptype=='int')) &&
1054: (pscat=='default') &&
1055: (typeof(svalue)!="undefined") &&
1056: (svalue!=0) && (svalue!='')) { pscat='any'; }
1057:
1058: if (ptype=='tolerance') {
1059: var tperc=0;
1060: var trange=0;
1061: if (typeof(svalue)!='undefined') {
1062: if (svalue.indexOf('%')!=-1) { tperc=1; }
1063: if (svalue.indexOf(',')!=-1) { trange=1; }
1064: if (trange) {
1065: if (tperc) { pscat='relative'; } else { pscat='absolute'; }
1066: } else {
1067: if (tperc) { pscat='relative_sym'; } else { pscat='absolute_sym'; }
1068: }
1069: }
1070: }
1071:
1072: this.window.selector.document.open();
1073: selwrite('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
1074: selwrite('<html xmlns="http://www.w3.org/1999/xhtml">');
1075: selwrite('<head>');
1076: selwrite('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
1077: selwrite('<title>LON-CAPA</title>');
1078: selwrite('<style type="text/css">');
1079: selwrite('<!--');
1080: selwrite('body {');
1081: selwrite('font-family: Verdana,Arial,Helvetica,sans-serif;');
1082: selwrite('line-height:130%;');
1083: selwrite('font-size:0.83em;');
1084: selwrite('background: #FFFFFF;');
1085: selwrite('}');
1086: selwrite('-->');
1087: selwrite('</style>');
1088: selwrite('</head>');
1089: selwrite('<body>');
1090: selwrite('<form name="fsel" action=""><b>'+pname+'</b><br />');
1091: selwrite('Format of Value(s): <select name="fcat" onchange="parent.catchange();">');
1092:
1093: if (ptype=='tolerance') {
1094: sopt('default','Default');
1095: sopt('relative_sym','Relative Tolerance, Symmetric (percent)');
1096: sopt('relative','Relative Tolerance (percentages)');
1097: sopt('absolute_sym','Absolute Tolerance, Symmetric (value)');
1098: sopt('absolute','Absolute Tolerance (values)');
1099: }
1100:
1101: if (ptype=='date') {
1102: if (pscat != 'interval') {
1103: sopt('default','Default');
1104: sopt('start','Starting Date');
1105: sopt('end','Ending Date');
1106: } else {
1107: sopt('interval','Time Interval');
1108: }
1109:
1110: if ((pvalue!='') && (typeof(pvalue)!="undefined")) {
1111: cdate.setTime(pvalue*1000);
1112: } else {
1113: cdate.setSeconds(defsec);
1114: cdate.setMinutes(defmin);
1115: cdate.setHours(defhour);
1116: }
1117:
1118: months[0]='January';
1119: months[1]='February';
1120: months[2]='March';
1121: months[3]='April';
1122: months[4]='May';
1123: months[5]='June';
1124: months[6]='July';
1125: months[7]='August';
1126: months[8]='September';
1127: months[9]='October';
1128: months[10]='November';
1129: months[11]='December';
1130: }
1131:
1132: if (ptype=='int') {
1133: sopt('default','Default');
1134: sopt('pos','Positive Integer, Not Zero');
1135: sopt('zeropos','Positive Integer or Zero');
1136: sopt('inrange','Integer in Range');
1137: sopt('range','Range of Integers');
1138: sopt('any','Integer');
1139: }
1140:
1141: if (ptype=='float') {
1142: sopt('default','Default');
1143: sopt('zeroone','Floating Point between 0 and 1');
1144: sopt('pos','Positive Floating Point');
1145: sopt('any','Floating Point');
1146:
1147: }
1148:
1149: if (ptype=='string') {
1150: //sopt('default','Default');
1151: if (pscat == 'yesno') { sopt('yesno','Yes/No'); }
1152: else if (pscat == 'problemstatus'){ sopt('problemstatus','Problem Status'); }
1153: else if (pscat == 'examtype') { sopt('examtype','Exam Type'); }
1154: else if (pscat == 'questiontype') { sopt('questiontype','Question Type'); }
1155: else if (pscat == 'lenient') { sopt('lenient','Lenient Grading (Partial Credit)'); }
1156: else if (pscat == 'discussvote') { sopt('discussvote','Discussion Voting'); }
1157: else if (pscat == 'ip') { sopt('ip','IP Number/Name'); }
1158: else if (pscat == 'fileext') { sopt('fileext','File Extension'); }
1159: else if (pscat == 'useslots') { sopt('useslots','Slots control access'); }
1160: else { pscat = 'any'; }
1161: sopt('any','String Value');
1162: }
1163:
1164: if (ptype=='color') {
1165: sopt('default','Use Default Color');
1166: sopt('custom','Use Custom Color');
1167: }
1168:
1169: selwrite('</select></form>');
1170: var targ='parent.opener';
1171: if (pmodal==1) {
1172: targ='parent.parent';
1173: }
1174: if ((ptype=='date') && (pscat=='interval')) {
1175: selwrite('<a href="javascript:parent.validateInterval();');
1176: } else {
1177: selwrite('<a href="javascript:parent.assemble();');
1178: }
1179: if (preturn!='') {
1180: selwrite(targ+'.document.'+preturn+'_value.value=parent.window.svalue;');
1181: selwrite(targ+'.document.'+preturn+'_type.value=parent.window.stype;');
1182: }
1183: if (pmarker!='') {
1184: selwrite(targ+'.document.'+preturn+'_marker.value=parent.window.pmarker;');
1185: }
1186: if (pcode!='') {
1187: selwrite(targ+'.'+pcode+'();');
1188: }
1189: selwrite('">Save</a> ');
1190:
1191: selwrite('<a href="javascript:');
1192: selwrite(targ+'.document.'+preturn+'_value.value='+"'';");
1193: if (pmarker!='') {
1194: selwrite(
1195: targ+'.document.'+preturn+'_marker.value=parent.window.pmarker;');
1196: }
1197: if (pcode!='') {
1198: selwrite(targ+'.'+pcode+'();');
1199: }
1200: selwrite('">Delete</a> ');
1201:
1202: selwrite('</body></html>');
1203: this.window.selector.document.close();
1204: draw();
1205:
1206: }
1207:
1208: // ]]>
1209: </script>
1210: </head>
1211:
1212: <frameset rows="120,*" onload="init();">
1213: <frame name="selector" src="empty.html" />
1214: <frame name="choices" src="empty.html" />
1215: </frameset>
1216:
1217:
1218:
1219: </html>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>