Annotation of loncom/publisher/testbankimport.pm, revision 1.2
1.1 raeburn 1: package Apache::testbankimport;
2:
3: use strict;
4: use Apache::Constants qw(:common :http :methods);
5: use Apache::loncacc;
6: use Apache::loncommon();
7: use Apache::Log();
8: use Apache::lonnet;
9: use HTML::Entities();
10: use Apache::lonlocal;
11: use Apache::lonupload;
12: use File::Basename();
13:
14: # ---------------------------------------------------------------- Display Control
15: sub display_control {
16: # figure out what page we're on and where we're heading.
17: my $page = $ENV{'form.page'};
18: my $command = $ENV{'form.go'};
19: my $current_page = &calculate_page($page,$command);
20: return $current_page;
21: }
22:
23: # CALCULATE THE CURRENT PAGE
24: sub calculate_page($$) {
25: my ($prev,$dir) = @_;
26: return 0 if $prev eq ''; # start with first page
27: return $prev + 1 if $dir eq 'NextPage';
28: return $prev - 1 if $dir eq 'PreviousPage';
29: return $prev if $dir eq 'ExitPage';
30: return 0 if $dir eq 'BackToStart';
31: }
32:
33: # ---------------------------------------------------------------- Jscript One
34:
35: sub jscript_one {
36: my $jsref = shift;
37: $$jsref = <<"END_SCRIPT";
38: function verify() {
39: if ((document.forms.display.blocks.value == "") || (!document.forms.display.blocks.value) || (document.forms.display.blocks.value == "0")) {
40: alert("You must enter the number of blocks of questions of a given question type. This number must be 1 or more.")
41: return false
42: }
43: if (document.forms.display.qnumformat.options[document.forms.display.qnumformat.selectedIndex].value == "-1") {
44: alert("You must select the format used for the question number, e.g., (1), 1., (1, or 1).")
45: return false
46: }
47: return true
48: }
49: function nextPage() {
50: if (verify()) {
51: document.forms.display.go.value="NextPage"
52: document.forms.display.submit()
53: }
54: }
55: function backPage() {
56: document.forms.display.go.value="PreviousPage"
57: document.forms.display.submit()
58: }
59: function setElements() {
60: var iter = 0
61: var selParam = 0
62: END_SCRIPT
63: if (exists($ENV{'form.blocks'}) ) {
64: $$jsref .= qq|
65: document.forms.display.blocks.value = $ENV{'form.blocks'}\n|;
66: } elsif (exists($ENV{'form.qnumformat'}) ) {
67: $$jsref .= <<"TO_HERE";
68: for (iter=0; iter<document.forms.display.qnumformat.length; iter++) {
69: if(document.forms.display.qnumformat.options[iter].value == "$ENV{'form.qnumformat'}") {
70: selParam = iter
71: }
72: }
73: document.forms.display.qnumformat.selectedIndex = selParam
74: TO_HERE
75: }
76: $$jsref .= qq|
77: }
78: |;
79: }
80:
81: # ---------------------------------------------------------------- Jscript Two
82: sub jscript_two {
83: my ($jsref,$qcount) = @_;
84: my $blocks = 0;
85: if ( exists( $ENV{'form.blocks'}) ) {
86: $blocks = $ENV{'form.blocks'};
87: }
88: $$jsref = <<"END_SCRIPT";
89: function verify() {
90: var poolForm = document.forms.display
91: var curmax = 0
92: var curmin = 0
93: for (var i=0; i<$blocks; i++) {
94: var iter = i+1
95: if (poolForm.elements[5*i+3].options[poolForm.elements[5*i+3].selectedIndex].value == "MC") {
96: if (poolForm.elements[5*i+4].selectedIndex == 0) {
97: alert ("You must choose the foil labelling format in Multiple Choice questions")
98: return false
99: }
100: }
101: if (poolForm.elements[5*i+3].options[poolForm.elements[5*i+3].selectedIndex].value == "MA") {
102: if (poolForm.elements[5*i+4].selectedIndex == 0) {
103: alert ("You must choose the foil labelling format in Multiple Answer questions")
104: return false
105: }
106: if (poolForm.elements[5*i+5].selectedIndex == 0) {
107: alert ("You must choose the answer format in Multiple Answer questions")
108: return false
109: }
110: }
111: if (poolForm.elements[5*i+3].options[poolForm.elements[5*i+3].selectedIndex].value == "FIB") {
112: if (poolForm.elements[5*i+5].selectedIndex == 0) {
113: alert ("You must choose the answer format in Fill-in-the-blank questions")
114: return false
115: }
116: }
117: if (poolForm.elements[5*i+3].options[poolForm.elements[5*i+3].selectedIndex].value == "TF") {
118: if (poolForm.elements[5*i+5].selectedIndex == 0) {
119: alert ("You must choose the answer format in True/False questions")
120: return false
121: }
122: }
123: if (poolForm.elements[5*i+3].options[poolForm.elements[5*i+3].selectedIndex].value == "Ord") {
124: if (poolForm.elements[5*i+4].selectedIndex == 0) {
125: alert ("You must choose the foil labelling format in Ranking/ordering questions")
126: return false
127: }
128: if (poolForm.elements[5*i+5].selectedIndex == 0) {
129: alert ("You must choose the answer format in Ranking/ordering questions")
130: return false
131: }
132: }
133: if (poolForm.elements[5*i+3].options[poolForm.elements[5*i+3].selectedIndex].value == "-1") {
134: alert ("You must choose the question type for block "+iter)
135: return false
136: }
137: if ((poolForm.elements[5*i+1].value == "") || !(poolForm.elements[5*i+1].value)) {
138: alert ("You must choose the start number for block "+iter)
139: return false
140: }
141: if ((poolForm.elements[5*i+2].value == "") || !(poolForm.elements[5*i+2].value)) {
142: alert ("You must choose the end number for block "+iter)
143: return false
144: }
145: if (poolForm.elements[5*i+2].value - poolForm.elements[5*i+1].value < 0) {
146: alert ("In block: "+iter+" the end number must be the same or greater than the start number")
147: return false
148: }
149: if (i == 0) {
150: curmin = parseInt(poolForm.elements[5*i+1].value)
151: curmax = parseInt(poolForm.elements[5*i+2].value)
152: }
153: else {
154: if (parseInt(poolForm.elements[5*i+1].value) < curmin) {
155: if (parseInt(poolForm.elements[5*i+2].value) >= curmin ) {
156: alert("The question number range for block "+iter+" overlaps with the question number range for one of the previous blocks - this is not permitted.")
157: return false
158: }
159: }
160: else {
161: if (parseInt(poolForm.elements[5*i+1].value) <= curmax) {
162: for (var j=parseInt(poolForm.elements[5*i+1].value); j<=parseInt(poolForm.elements[5*i+2].value); j++) {
163: for (var k=0; k<i; k++) {
164: if ((j >= parseInt(poolForm.elements[5*k+1].value)) && (j <= parseInt(poolForm.elements[5*k+2].value))) {
165: var overlap = k+1
166: alert("The question number range for block "+iter+" overlaps with the question number range for block "+overlap+" - this is not permitted.")
167: return false
168: }
169: }
170: }
171: }
172: }
173: if (parseInt(poolForm.elements[5*i+1].value) < curmin) {
174: curmin = parseInt(poolForm.elements[5*i+1].value)
175: }
176: if (parseInt(poolForm.elements[5*i+2].value) > curmax) {
177: curmax = parseInt(poolForm.elements[5*i+2].value)
178: }
179: }
180: }
181: if (curmax >$qcount+curmin) {
182: alert("The last # for one or more of the blocks is too large - the last number of the last block can not be greater than $qcount: the total number of questions in the uploaded file.")
183: return false
184: }
185: var endpt = $qcount + curmin
186: for (var n=curmin; n<endpt; n++) {
187: var warnFlag = true
188: for (var m=0; m<$blocks; m++) {
189: if ((n >= parseInt(poolForm.elements[5*m+1].value)) && (n <= parseInt(poolForm.elements[5*m+2].value))) {
190: warnFlag = false
191: }
192: }
193: if (warnFlag) {
194: alert("The question type for question "+n+" could not be identified because it does not fall within the number ranges you have provided for any of the $blocks block(s)")
195: return false
196: }
197: }
198: return true
199: }
200:
201: function nextPage() {
202: if (verify()) {
203: document.forms.display.go.value="NextPage"
204: document.forms.display.submit()
205: }
206: }
207: function backPage() {
208: document.forms.display.go.value="PreviousPage"
209: document.forms.display.submit()
210: }
211: function colSet(caller) {
212: var poolForm = document.forms.display
213: var curVal = poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value
214: poolForm.elements[caller*5+4].length = 0
215: if (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "-1") {
216: poolForm.elements[caller*5+4].options[0] = new Option("<--- Set type ","-1",true,true)
217: }
218: else {
219: if ((poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "MC") || (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "MA") || (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "Ord")) {
220: poolForm.elements[caller*5+4].options[0] = new Option("Please Select","-1",true,true)
221: poolForm.elements[caller*5+4].options[1] = new Option("a.","lcperiod",false,false)
222: poolForm.elements[caller*5+4].options[2] = new Option("A.","ucperiod",false,false)
223: poolForm.elements[caller*5+4].options[3] = new Option("(a)","lcparen",false,false)
224: poolForm.elements[caller*5+4].options[4] = new Option("(A)","ucparen",false,false)
225: poolForm.elements[caller*5+4].options[5] = new Option("(i)","romparen",false,false)
226: poolForm.elements[caller*5+4].options[6] = new Option("i.","romperiod",false,false)
227: poolForm.elements[caller*5+4].selectedIndex = 0
228: }
229: else {
230: poolForm.elements[caller*5+4].options[0] = new Option("Not required","0",true,true)
231: }
232: }
233: poolForm.elements[caller*5+5].length = 0
234: if (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "-1") {
235: poolForm.elements[caller*5+5].options[0] = new Option("<--- Set type ","-1",true,true)
236: }
237: else {
238: if ((poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "MA") || (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "FIB")) {
239: poolForm.elements[caller*5+5].options[0] = new Option("Please Select","-1",true,true)
240: poolForm.elements[caller*5+5].options[1] = new Option("single answer","single",false,false)
241: poolForm.elements[caller*5+5].options[2] = new Option("comma","comma",false,false)
242: poolForm.elements[caller*5+5].options[3] = new Option("space","space",false,false)
243: poolForm.elements[caller*5+5].options[4] = new Option("new line","line",false,false)
244: poolForm.elements[caller*5+5].options[5] = new Option("tab","tab",false,false)
245: }
246: else {
247: if (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "Ord") {
248: poolForm.elements[caller*5+5].options[0] = new Option("Please Select","-1",true,true)
249: poolForm.elements[caller*5+5].options[1] = new Option("comma","comma",false,false)
250: poolForm.elements[caller*5+5].options[2] = new Option("space","space",false,false)
251: poolForm.elements[caller*5+5].options[3] = new Option("new line","line",false,false)
252: poolForm.elements[caller*5+5].options[4] = new Option("tab","tab",false,false)
253: }
254: else {
255: if (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "TF") {
256: poolForm.elements[caller*5+5].options[0] = new Option("Please Select","-1",true,true)
257: poolForm.elements[caller*5+5].options[1] = new Option("True or False","word",false,false)
258: poolForm.elements[caller*5+5].options[2] = new Option("T or F","lett",false,false)
259: }
260: else {
261: poolForm.elements[caller*5+5].options[0] = new Option("Not required","0",true,true)
262: }
263: }
264: }
265: }
266: }
267:
268: function setElements() {
269: var iter = 0
270: var selParam = 0
271: END_SCRIPT
272: my @names = ("start_","end_","qtype_","foilformat_","ansr_");
273: for (my $x=0; $x<$blocks; $x++) {
274: foreach my $name (@names) {
275: my $parname = $name.$x;
276: my $value = $ENV{"form.$parname"};
277: if ($value ne "") {
278: if (($name eq "start_") || ($name eq "end_")) {
279: $$jsref .= qq|
280: document.forms.display.$parname.value = $value\n|;
281: } elsif ($name eq "qtype_") {
282: $$jsref .= qq|
283: for (iter=0; iter<document.forms.display.$parname.length; iter++) {
284: if (document.forms.display.$parname.options[iter].value == "$value") {
285: selParam = iter
286: }
287: }
288: document.forms.display.$parname.selectedIndex = selParam
289: colSet($x)
290: |;
291: } elsif (($name eq "foilformat_") || ($name eq "ansr_")) {
292: $$jsref .= <<"TO_HERE";
293: for (iter=0; iter<document.forms.display.$parname.length; iter++) {
294: if (document.forms.display.$parname.options[iter].value == "$value") {
295: selParam = iter
296: }
297: }
298: document.forms.display.$parname.selectedIndex = selParam
299: TO_HERE
300: }
301: }
302: }
303: }
304: $$jsref .= qq|
305: }
306: |;
307: }
308: # ---------------------------------------------------------------- Jscript Three
309:
310: sub jscript_three {
311: my ($fullpath,$jsref) = @_;
312: my $source = '';
313: if (exists($ENV{'form.go'}) ) {
314: $source = $ENV{'form.go'};
315: }
316: $$jsref = <<"END_OF_ONE";
317: function verify() {
318: if ((document.forms.dataForm.newdir.value == '') || (!document.forms.dataForm.newdir.value)) {
319: alert("Step 4: You must choose a destination directory for the import")
320: return false
321: }
322: return true
323: }
324:
325: function nextPage() {
326: if (verify()) {
327: document.forms.dataForm.go.value="NextPage"
328: document.forms.dataForm.submit()
329: }
330: }
331: function backPage() {
332: document.forms.dataForm.go.value="PreviousPage"
333: document.forms.dataForm.submit()
334: }
335:
336: function createWin() {
337: document.dataForm.newdir.value = "";
338: newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes")
339: newWindow.document.open()
340: newWindow.document.write("<html><head><title>Create Testbank directory</title><meta http-equiv='pragma' content='no-cache'>\\n")
341: newWindow.document.write("</head><body bgcolor='#CCFFDD' topmargin='0' leftmargin='0' marginheight='0'marginwidth='0' rightmargin='0'>\\n")
342: newWindow.document.write("<img border='0' src='/adm/lonInterFace/author.jpg' alt='[Author Header]'>\\n")
343: newWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='430' bgcolor='#CCFFDD'>\\n")
344: newWindow.document.write("<tr><td width='2'> </td><td width='3'> </td>\\n")
345: newWindow.document.write("<td><h3>Location: <tt>$fullpath</tt></h3><h3>New Directory</h3></td></tr>\\n")
346: newWindow.document.write("<tr><td width='2'> </td><td width='3'> </td>\\n")
347: newWindow.document.write("<td><form name='fileaction' action='/adm/cfile' method='post'>\\n")
348: newWindow.document.write("<font face='arial,helvetica,sans-serif'>Enter the name of the new directory where you will store the converted testbank questions<br /><br />")
349: newWindow.document.write("<input type='hidden' name='filename' value='$fullpath'>")
350: newWindow.document.write("<input type='hidden' name='action' value='newdir'>")
351: newWindow.document.write("<input type='hidden' name='callingmode' value='testbank'>")
352: newWindow.document.write("$fullpath<input type='text' name='newfilename' value=''/>")
353: newWindow.document.write("<input type='button' value='Go' onClick='document.fileaction.submit();' />")
354: newWindow.document.write("</td></tr>\\n")
355: newWindow.document.write("</table></body></html>")
356: newWindow.document.close()
357: newWindow.focus()
358: }
359: END_OF_ONE
360: if ($source eq "PreviousPage") {
361: $$jsref .= qq|
362: function setElements() {
363: var iter = 0
364: var selParam = 0
365: |;
366: foreach my $item (keys %ENV) {
367: if ($item =~ m/^form\.(\w+)$/) {
368: my $name = $1;
369: my $value = $ENV{"form.$name"};
370: unless ($value eq "") {
371: if ($name eq "newdir") {
372: $$jsref .= qq( document.forms.dataForm.$name.value = "$value"\n);
373: }
374: }
375: }
376: }
377: $$jsref .= "}";
378: }
379: }
380:
381:
382: # ---------------------------------------------------------------- Jscript Four
383: sub jscript_four {
384: my ($jsref,$fullpath) = @_;
385: $$jsref = qq|
386: function backtoStart() {
387: document.location.href="$fullpath"
388: }
389: function backpage() {
390: document.forms.verify.go.value="PreviousPage"
391: document.forms.verify.submit()
392: }
393: |;
394: }
395:
396: # ---------------------------------------------------------------- Display Zero
397: sub display_zero {
398: my ($r,$uname,$fn,$page,$fullpath) = @_;
399: $r->print(qq|
400: <table border='0' cellspacing='0' cellpadding='0' width='100%'>
401: <tr>
402: <td> </td>
403: <td colspan='2'><font face='arial,helvetica,sans-serif'>
404: The <b>Testbank Upload</b> utility can be used by LON-CAPA authors to convert <i>multiple choice</i>, <i>multiple answer correct</i>, <i>fill-in-the-blank</i>, <i>ordering/ranking</i>, <i>true/false</i> and <i>essay</i> questions from a plain text testbank file to LON-CAPA problem files. Five requirements must be met to ensure that you will succeed in converting your plain text file of testbank questions to functioning LON-CAPA problems.
405: <ol>
406: <li>The questions and answers you upload must be in plain text format. Any header lines should occur before the text containing the questions and answers.</li>
407: <li>All questions (including question text and all foils) must occur before any of the answers. Each question should begin on a new line, and should start with the question number. Questions should be numbered sequentially using a number followed immediately by a space, a period, or enclosed in parentheses, i.e., 1 , 1., (1), 1), or (1 .</li>
408: <li><i>Multiple choice</i> and <i>multiple answer correct</i> questions should consist of: (i) the question number followed by (ii) the question text beginning on the same line and (iii) two or more foils, with each foil beginning on a new line and prefixed by a unique letter, or Roman numeral, listed in alphabetic or numeric order, beginning at a (alphabetic) or i (Roman numeral), followed by a period, or enclosed in parentheses, i.e., a., (a), i., or (i).</li>
409: <li>One or more correct answers should be provided for all questions (although blank answers may be provided for <i>essay</i> questions). Answers should be numbered sequentially, using the same scheme as used for the questions, and must occur after <b>all</b> the questions.
410: <li>If <i>fill-in-the-blank</i> or <i>multiple answer</i> questions have more than one correct answer, each answer should appear in a comma-, tab-, space-, or new line-delimited list. For a <i>ranking/ordering</i> question, the "answer" should contain the foil identifiers correctly ordered in a similarly delimited list.</li>
411: </ol>
412: Five steps are involved in the import process.
413: <ol>
414: <li>Upload your text file to the server.|);
415:
416: if ($fn eq '') {
417: $r->print("<b>Incomplete</b>. Please return to the <a href='$fullpath'>construction space menu<a> to upload a file");
418: } else {
419: $r->print(" <b>Completed</b> - successful upload of <i>$fn</i>");
420: }
421: $r->print(qq|</li>
422: <li>Provide information about the question format - i.e., question numbering style, and the number of blocks of questions of each question type.</li>
423: <li>Provide information about the questions in each block, including question type, start and end question numbers for each block, and foil labelling style and answer format where required.</li>
424: <li>Create a new directory where you will store the converted testbank questions.</li>
425: <li>Complete the import of questions to the selected pool.</li>
426: </ol>
427: </font>
428: </td>
429: </tr>
430: </table>
431: <br />
432: <br />
433: <form name="info" method="post">
434: <input type="hidden" name="uploaduname" value="$uname">
435: <input type="hidden" name="filename" value="$fn">
436: <input type="hidden" name="page" value="$page">
437: <input type="hidden" name="phase" value="three">
438: <input type="hidden" name="go" value="NextPage">
439: <table border="0" width="100%">
440: <tr>
441: <td align='left'>
442: <input type="button" name="goback" value="Exit Now" onClick="javascript:location.href='$fullpath'">
443: </td>
444: <td align='right'>
445: <input type="button" name="nextpage" value="Continue to step 2" onClick="javascript:submit()">
446: </td>
447: </tr>
448: </table>
449: </form>
450: |);
451: }
452:
453:
454: # ---------------------------------------------------------------- Display One
455:
456: sub display_one {
457: my ($r,$uname,$fn,$page,$textref) = @_;
458: $r->print(qq|
459: <form method='post' name='display'>
460: <table border='0' cellspacing='0' cellpadding='3' width='100%'>
461: <tr bgcolor='#ccddaa'>
462: <td> </td>
463: <td align='left'>
464: <h3><font face='arial,helvetica,sans-serif'>Step 2: Identification of blocks of questions</b> </font></h3>
465: </td>
466: </tr>
467: <tr>
468: <td colspan='2'> </td>
469: </tr>
470: <tr>
471: <td colspan='2'>
472: <table border="0" cellspacing="0" cellpadding="2">
473: <tr>
474: <td> </td>
475: <td colspan='2'>
476: <font face='arial,helvetica,sans-serif'><b>Testbank data uploaded to the server:</b></font>
477: </td>
478: </tr>
479: <tr>
480: <td colspan='3'> </td>
481: </tr>
482: <tr>
483: <td> </td>
484: <td colspan='2'>
485: <textarea name="rawdata" cols="70" rows="6" wrap="virtual" align="center">
486: |);
487: foreach my $line (@{$textref}) {
488: $line =~ s/\n//g;
489: $r->print("$line\n");
490: }
491: $r->print(qq|
492: </textarea>
493: </td>
494: </tr>
495: <tr>
496: <td colspan='3'> </td>
497: </tr>
498: <tr>
499: <tr>
500: <td colspan='3'> </td>
501: </tr>
502: <tr bgcolor='#ccddaa'>
503: <td> </td>
504: <td align='left' valign='middle'><img src="/res/adm/pages/bl_step1.gif">
505: </td>
506: <td>
507: <font face='arial,helvetica,sans-serif'><b>
508: Select the format of the question number</b> [e.g., 1, 1., 1), (1 or (1)].
509: <select name="qnumformat">
510: <option value = "-1" selected>Please Select
511: <option value="number">1
512: <option value="period">1.
513: <option value="paren">(1)
514: <option value="leadparen">(1
515: <option value="trailparen">1)
516: </select>
517: </font>
518: </td>
519: </tr>
520: <tr>
521: <td colspan='3'> </td>
522: </tr>
523: <tr>
524: <td> </td>
525: <td colspan='2'><font face='arial,helvetica,sans-serif'>
526: A number in the specified format should appear at the start of each question. For multiple choice questions, the question number must begin the line that contains the question text; foils (starting (a), (i) etc.) should occur on subsequent lines. Correct answers should be numbered in the same way as the questions and should appear after <b>all</b> the questions (including question text and possible foils for all questions). Each numbered question must have a corresponding numbered answer, although the answer itself may be blank for essay questions.</td>
527: </tr>
528: <tr>
529: <td colspan="3"> </td>
530: </tr>
531: <tr>
532: <td> </td>
533: <td colspan='2'>
534: <font face='arial,helvetica,sans-serif'>
535: For example, you would select <b>1.</b> if your text file contained the following questions:<br><br>
536: 1. The capital of the USA is ..<br />
537: (a) Washington D.C.<br />
538: (b) New York<br />
539: (c) Los Angeles<br />
540: <br />
541: 2. The capital of Canada is ..<br />
542: (a) Toronto<br />
543: (b) Vancouver<br />
544: (c) Ottawa<br />
545: <br />
546: 3. Describe an experiment you could conduct to measure c, the speed of light in a vacuum. <br /><br />
547: 1. (a)<br />
548: 2. (c)<br />
549: 3. <br />
550: </td>
551: <tr>
552: <td colspan="3"> </td>
553: </tr>
554: <tr bgcolor='#ccddaa'>
555: <td> </td>
556: <td><img src='/res/adm/pages/bl_step2.gif' align='left' valign='middle'>
557: </td>
558: <td>
559: <font face='arial,helvetica,sans-serif'><b>
560: Please indicate the number of blocks of different question types in the text file.</b>
561: <input type="text" name="blocks" value="" size="5">
562: </td>
563: </tr>
564: <tr>
565: <td colspan="3"> </td>
566: </tr>
567: <tr>
568: <td> </td>
569: <td colspan='2'>
570: <font face='arial,helvetica,sans-serif'>
571: For example, you would enter <b>6</b> if your text file contained the following sequence of questions:<br><br>
572: 10 multiple choice questions<br>
573: 5 essay questions<br>
574: 5 fill-in-the-blank questions<br>
575: 5 multiple answer questions<br>
576: 4 multiple choice questions<br>
577: 3 essay questions<br>
578: </font>
579: </td>
580: </tr>
581: <tr>
582: <td colspan='3'> </td>
583: </tr>
584: <tr>
585: <td> </td>
586: <td colspan='2'><font face='arial,helvetica,sans-serif'>You will indicate the question type and the question number range for each of the blocks on the next page.</font></td>
587: </tr>
588: <tr>
589: <td colspan='3'> </td>
590: </tr>
591: <tr>
592: <td colspan='3'>
593: <table border='0' width="100%" cellspacing='0' cellpadding='2'>
594: <tr>
595: <td align='left'>
596: <input type="button" name="backpage" value="Go back to step 1" onClick="javascript:backPage()">
597: </td>
598: <td align='right'>
599: <input type="button" name="nextpage" value="Continue to step 3" onClick="javascript:nextPage()">
600: </td>
601: </tr>
602: </table>
603: <input type="hidden" name="page" value ="$page">
604: <input type="hidden" name="go" value="">
605: <input type="hidden" name="uploaduname" value="$uname">
606: <input type="hidden" name="filename" value="$fn">
607: <input type="hidden" name="phase" value="three">
608: </td>
609: </tr>
610: </table>
611: </td>
612: </tr>
613: </table>
614: </form>
615: |);
616: }
617:
618: # ---------------------------------------------------------------- Display Two
619:
620: sub display_two {
621: my ($r,$uname,$fn,$page,$textref,$qcount) = @_;
622: my $blocks = $ENV{'form.blocks'};
623: my $qnumformat = $ENV{'form.qnumformat'};
624: my @types = ("MC","MA","TF","Ess","FIB","Ord");
625: my %typenames = (
626: MC => "Multiple Choice",
627: TF => "True/False",
628: MA => "Multiple Answer",
629: Ess => "Essay",
630: FIB => "Fill-in-the-blank",
631: Ord => "Ranking/ordering",
632: );
633: my %qnumtypes = (
634: number => "1",
635: period => "1.",
636: paren => "(1)",
637: leadparen => "(1",
638: trailparen => "1)",
639: );
640: my @bgcolors = ('#ffffff','#eeeeee');
641: my $bl1st = '';
642: my $bl1end = '';
643: if ($blocks == 1) {
644: $bl1st = '1';
645: $bl1end = $qcount;
646: }
647: $r->print(<<"END_OF_FUNC");
648: <h3><font face='arial,helvetica,sans-serif'>Step 3: Classification of blocks</b> </font></h3>
649: <form method='post' name='display'>
650: <table border='0' cellspacing='0' cellpadding ='0'>
651: <tr>
652: <td colspan='2'> </td>
653: </tr>
654: <tr>
655: <td colspan='2'>
656: <table border="0" cellspacing="0" cellpadding="0">
657: <tr>
658: <td> </td>
659: <td><font face='arial,helvetica,sans-serif'>
660: You indicated that <b>all</b> questions (and the corresponding answer(s) for each question) begin with a number in the following format: <b>$qnumtypes{$qnumformat}</b>.<br><br>A total of <b>$qcount</b> questions and <b>$qcount</b> corresponding answers were found in the file you uploaded. If this questions total does not match the number you expect, please examine your original text file to verify that each question <i>and</i> each answer begins with a number in the specified format. If necessary use a text editor to edit your text file of questions, and click "Return to step 2" on this page and the "Return to Step 1" on the preceding page, so you can upload your text file again.<br><br>
661: You also indicated that the <b>$qcount</b> questions can be divided into <b>$blocks</b> blocks of questions of a particular question type.</font>
662: </td>
663: </tr>
664: <tr>
665: <td colpsan='2'> </td>
666: </tr>
667: <tr>
668: <td> </td>
669: <td><font face='arial,helvetica,sans-serif'>
670: Please provide additional information below ,about the types of questions you have uploaded, and, if applicable, the format of answers and "foils" for specific types of questions.
671: </td>
672: </tr>
673: <tr>
674: <td colpsan='2'> </td>
675: </tr>
676: <tr>
677: <td> </td>
678: <td>
679: <font face='arial,helvetica,sans-serif'>The following data were uploaded to the server</font><br>
680: <textarea name="rawdata" cols="70" rows="6" wrap="virtual" align="center">
681: END_OF_FUNC
682: foreach my $line (@{$textref}) {
683: $line =~ s/\n//g;
684: $r->print("$line\n");
685: }
686: $r->print(qq|
687: </textarea>
688: </td>
689: </tr>
690: <tr>
691: <td colspan='2'> </td>
692: </tr>
693: <tr bgcolor='#ccddaa'>
694: <td><img src='/res/adm/pages/bl_step3.gif' align='left' valign='middle'>
695: </td>
696: <td width='100%' align='left'>
697: <font size='+1' face='arial,helvetica,sans-serif'><b>Information about question types and formats in each block.</b></font>
698: </td>
699: </tr>
700: <tr>
701: <td colspan='2'> </td>
702: </tr>
703: <tr>
704: <td> </td>
705: <td><font face='arial,helvetica,sans-serif'>For <i>each</i> of the <b>$blocks</b> question blocks, please specify the question numbers of the first and last questions in the block (e.g., 1 and 10), and the question type of the questions in the block. Please provide additional information about foil formats and answer formats if required for the question type you selected.</font>
706: </td>
707: </tr>
708: <tr>
709: <td colspan='2'> </td>
710: </tr>
711: <tr>
712: <td> </td>
713: <td>
714: <table border="0" cellspacing="0" cellpadding="0" bgcolor="#000000" align="left">
715: <tr>
716: <td>
717: <table border="1" valign="top" align="center" width='100%'>
718: <tr bgcolor="#eef6f6" align="left">
719: <td>
720: <table border='0' cellspacing='1' cellpadding='1' align='left' width='100%'>
721: <tr bgcolor='#CCDDAA' align='center' valign='middle'>
722: <td align="center" valign="middle" height='10'><font face='arial,helvetica,sans-serif'>
723: <b>Block</b> </font>
724: </td>
725: <td align="center" valign="middle" height='10'><font face='arial,helvetica,sans-serif'>
726: <b>First number</b> </font>
727: </td>
728: <td align="center" valign="middle" height='10'><font face='arial,helvetica,sans-serif'>
729: <b>Last number</b> </font>
730: </td>
731: <td align="center" valign="middle" height='10'><font face='arial,helvetica,sans-serif'>
732: <b>Question type</b> </font>
733: </td>
734: <td align="center" valign="middle" height='10'><font face='arial,helvetica,sans-serif'>
735: <b>Foil format</b> </font>
736: </td>
737: <td align="center" valign="middle" height='10'><font face='arial,helvetica,sans-serif'>
738: <b>Answer format</b> </font>
739: </td>
740: </tr>
741: |);
742: for (my $i=0; $i<$blocks; $i++) {
743: my $iter = $i+1;
744: my $rowcol = $i%2;
745: $r->print(qq|
746: <tr bgcolor="$bgcolors[$rowcol]">
747: <td align="left">
748: <font face='arial,helvetica,sans-serif'> $iter.</font>
749: </td>
750: <td align="left">
751: <input type="text" name="start_$i" value="$bl1st" size="5">
752: </td>
753: <td align="left">
754: <input type="text" name="end_$i" value="$bl1end" size="5">
755: </td>
756: <td align="left">
757: <font face='arial,helvetica,sans-serif'>
758: <select name="qtype_$i" onChange="colSet($i)">
759: <option value= "-1" selected>Please Select
760: |);
761: foreach my $qtype (@types) {
762: $r->print(qq|<option value="$qtype">$typenames{$qtype}|);
763: }
764: $r->print(qq|
765: </select>
766: </font>
767: </td>
768: <td align="left">
769: <select name="foilformat_$i">
770: <option value="-1"><--- Set type
771: </select>
772: </td>
773: <td align="left">
774: <select name="ansr_$i">
775: <option value="-1"><--- Set type
776: </select>
777: </td>
778: </tr>
779: |);
780: }
781: $r->print(qq|
782: </table>
783: </td>
784: </tr>
785: </table>
786: </td>
787: </tr>
788: </table>
789: </td>
790: </tr>
791: <tr>
792: <td colspan="2"> </td>
793: </tr>
794: <tr>
795: <td> </td>
796: <td>
797: <font face='arial,helvetica,sans-serif'>For <i>multiple choice</i>, <i>multiple correct answer</i> and <i>ranking</i> type questions, you must use the <b>Foil format</b> column to choose the format of the identifier used for each of the possible answers (e.g., (a), a, a., i, (i) etc.) provided for a given question stem. For <i>multiple correct answer</i> and <i>fill-in-the-blank</i> questions with more than one correct answer you must use the <b>Answer format</b> column to choose the separator used between the answers, e.g., if the correct answers for question 28. were listed as: 28. (a),(d),(e) you would choose "comma", or if they were listed as:</font><br><table border='0'><tr><td><font face='arial,helvetica,sans-serif'>28. </font></td><td><font face='arial,helvetica,sans-serif'>(a)</font></td></tr><tr><td> </td><td><font face='arial,helvetica,sans-serif'>(d)</font></td></tr><tr><td> </td><td><font face='arial,helvetica,sans-serif'>(e)</font></td></tr></table>
798: <font face='arial,helvetica,sans-serif'>you would choose "new line". For <i>true/false</i> questions you must use the <b>Answer format</b> column to choose how the correct answer - True or False, is displayed in the text file (e.g., T or F, true or false etc.). For <i>ranking</i> questions you must use the <b>Answer format</b> column to choose the separator used between the (ranked) answers.</font><br><br>
799: </td>
800: </tr>
801: <tr>
802: <td colspan='2'> </td>
803: </tr>
804: <tr>
805: <td colspan='2'>
806: <input type="hidden" name="blocks" value="$blocks">
807: <input type="hidden" name="qnumformat" value="$qnumformat">
808: <table border='0' width="100%" cellspacing='0' cellpadding='2'>
809: <tr>
810: <td align='left'>
811: <input type="button" name="backpage" value="Go back to step 2" onClick="javascript:backPage()">
812: </td>
813: <td align='right'>
814: <input type="button" name="nextpage" value="Continue to step 4" onClick="javascript:nextPage()">
815: </td>
816: </tr>
817: </table>
818: <input type="hidden" name="page" value ="$page">
819: <input type="hidden" name="go" value="">
820: <input type="hidden" name="uploaduname" value="$uname">
821: <input type="hidden" name="filename" value="$fn">
822: <input type="hidden" name="phase" value="three">
823: </form>
824: </td>
825: </tr>
826: </table>
827: </td>
828: </tr>
829: </table>
830: |);
831: }
832: # ---------------------------------------------------------------- Display Three
833: sub display_three {
834: my ($r,$uname,$fn,$page,$textref,$qcount) = @_;
835: my $qnumformat = $ENV{'form.qnumformat'};
836: my $filename = $ENV{'form.filename'};
837: my $source = $ENV{'form.go'};
838: my $blocks = $ENV{'form.blocks'};
839: my @items = ();
840: my @bgcolors = ('#ffffff','#eeeeee');
841: my @types = ("MC","MA","TF","Ess","FIB","Ord");
842: my @alphabet = ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
843: my @romans = ("i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii","xiii","xiv","xv","xvi","xvii","xviii","xix","xx","xxi","xxii","xxiii","xxiv","xxv","xxvi");
844: my @start = ();
845: my @end = ();
846: my @nums = ();
847: my @qtype = ();
848: my @foilformats = ();
849: my @ansrtypes = ();
850: my %multparts = ();
851: my $numitems = 0;
852: for (my $i=0; $i<$blocks; $i++) {
853: if (($ENV{"form.start_$i"} ne '') && ($ENV{"form.end_$i"} ne '')) {
854: $start[$i] = $ENV{"form.start_$i"};
855: $end[$i] = $ENV{"form.end_$i"};
856: $nums[$i] = $end[$i]-$start[$i] +1;
857: $qtype[$i] = $ENV{"form.qtype_$i"};
858: if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA") || ($qtype[$i] eq "Ord")) {
859: $foilformats[$i] = $ENV{"form.foilformat_$i"};
860: } else {
861: $foilformats[$i] = '';
862: }
863: if (($qtype[$i] eq "MA") || ($qtype[$i] eq "FIB") || ($qtype[$i] eq "TF") || ($qtype[$i] eq "Ord")) {
864: $ansrtypes[$i] = $ENV{"form.ansr_$i"};
865: } else {
866: $ansrtypes[$i] = '';
867: }
868: } else {
869: $nums[$i] = 0;
870: }
871: $numitems += $nums[$i];
872: }
873:
874: my $import = join//,@{$textref};
875: @items = &file_split(\@start,\@end,\@nums,$qnumformat,\@foilformats,$textref,\%multparts,$numitems,\@qtype,$blocks);
876: $r->print(<<"END_OF_ONE");
877: <h3><font face='arial,helvetica,sans-serif'>Step 4: Review and selection of destination directory</b> </font></h3>
878: <form name="dataForm" method="post">
879: <table border='0' bgcolor='#CCFFDD' cellspacing='0' cellpadding ='0'>
880: <tr>
881: <td colspan='2'>
882: <table border='0' cellspacing='0' cellpadding='0'>
883: <tr>
884: <td colspan='2'> </td>
885: </tr>
886: <tr>
887: <td> </td>
888: <td><font face='arial,helvetica,sans-serif'><b>
889: Based on your previous responses your data have been split into a total of $numitems questions.</b>
890: </td>
891: </tr>
892: <tr>
893: <td colspan='2'> </td>
894: </tr>
895: <tr>
896: <td> </td>
897: <td width="80%" bgcolor="#000000" align="left">
898: <table width="100%" border="0" cellpadding="1" cellspacing="0">
899: <tr>
900: <td width="100%" bgcolor="#000000">
901: <table border="0" cellspacing="0" cellpadding="1" width="100%">
902: <tr>
903: <td width="100%" bgcolor="#000000">
904: <table border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff" width="100%">
905: <tr>
906: <td bgcolor="#CCFFDD" width="100%">
907: <table border='0' cellspacing='1' cellpadding='2' align='left' width= '100%'>
908: <tr><td bgcolor="#CCDDAA" align="center" width='3%'><font face='arial,helvetica,sans-serif'><b>#</b></font></td><td bgcolor="#CCDDAA" align="center" width='5%'><font face='arial,helvetica,sans-serif'><b>Type</b></font></td><td bgcolor="#CCDDAA" align="center" width='60%'><font face='arial,helvetica,sans-serif'><b>Question</b></font></td><td bgcolor="#CCDDAA" align="center" width='32%'><font face='arial,helvetica,sans-serif'><b>Answer</b></font></td></tr>
909: END_OF_ONE
910: for (my $j=0; $j<$numitems; $j++) {
911: my $qnum = $j+1;
912: my $rowcol = $j%2;
913: $rowcol = @bgcolors[$rowcol];
914: for (my $i=0; $i<$blocks; $i++) {
915: if ($nums[$i] > 0) {
916: if (($j+1 >= $start[$i]) && ($j+1 <= $end[$i])) {
917: if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA")) {
918: for (my $k=0; $k<@{$multparts{$j}}; $k++) {
919: if ($k == 0) {
920: $r->print(qq|<tr><td bgcolor="$rowcol" valign='top'><font face='arial,helvetica,sans-serif'>$qnum.</font></td><td bgcolor="$rowcol" valign='top'><font face='arial,helvetica,sans-serif'><b>$qtype[$i]</b></font></td><td bgcolor="$rowcol" valign='top'><font face='arial,helvetica,sans-serif'>$multparts{$j}[$k]<br><br>\n|);
921: } else {
922: my $foiltag = '';
923: if ($foilformats[$i] eq "lcperiod") {
924: $foiltag = $alphabet[$k-1].'.';
925: } elsif ($foilformats[$i] eq "lcparen") {
926: $foiltag = '('.$alphabet[$k-1].')';
927: } elsif ($foilformats[$i] eq "ucperiod") {
928: $foiltag = $alphabet[$k-1].'.';
929: $foiltag =~ tr/a-z/A-Z/;
930: } elsif ($foilformats[$i] eq "ucparen") {
931: $foiltag = '('.$alphabet[$k-1].')';
932: $foiltag =~ tr/a-z/A-Z/;
933: } elsif ($foilformats[$i] eq "romperiod") {
934: $foiltag = $romans[$k-1].'.';
935: } elsif ($foilformats[$i] eq "romparen") {
936: $foiltag = '('.$romans[$k-1].')';
937: }
938: $r->print(qq|$foiltag $multparts{$j}[$k]<br>\n|);
939: }
940: }
941: $r->print(qq|<br></font></td><td bgcolor="$rowcol" valign='top'><font face='arial,helvetica,sans-serif'>$items[$j+$numitems]</font></td></tr>|);
942: } else {
943: $r->print(qq|<tr><td bgcolor="$rowcol" valign="top"><font face='arial,helvetica,sans-serif'>$qnum.</font></td><td bgcolor="$rowcol" valign="top"><font face='arial,helvetica,sans-serif'><b>$qtype[$i]</b></font></td><td bgcolor="$rowcol" valign="top"><font face='arial,helvetica,sans-serif'>$items[$j]</font></td><td bgcolor="$rowcol" valign="top"><font face='arial,helvetica,sans-serif'>$items[$j+$numitems]</font></td></tr>|);
944: }
945: last;
946: }
947: }
948: }
949: }
950: $r->print(qq|
951: </table>
952: </td>
953: </tr>
954: </table>
955: </td>
956: </tr>
957: </table>
958: </td>
959: </tr>
960: </table>
961: </td>
962: </tr>
963: <tr>
964: <td colspan='2'> </td>
965: </tr>
966: <tr bgcolor='#ccddaa'>
967: <td width='30' align='top'><img src='/res/adm/pages/bl_step4.gif'>
968: </td>
969: <td width='100%' align='left'>
970: <font size='+1' face='arial,helvetica,sans-serif'><b>Create a directory to store your testbank questions.</b></font>
971: </td>
972: </tr>
973: <tr>
974: <td colspan='2'> </td>
975: </tr>
976: <tr>
977: <td> </td>
978: <td>
979: <font face='Arial,Helvetica,sans-serif'>
980: Please choose a destination LON-CAPA directory in which to store your uploaded questions.
981: <input type="button" name="createdir" value="Create Directory" onClick="javascript:createWin()"><input type="hidden" name="newdir" value=""></font></td>
982: </tr>
983: <tr>
984: <td colspan='2'> </td>
985: </tr>
986: <tr>
987: <td> </td>
988: <td><font face='arial,helvetica,sans-serif'>If you are satisfied with the questions and answers extracted from your uploaded text file, as shown above, and you have created a destination directory click the "Continue to step 5" button to convert the questions in your testbank to LON-CAPA problem files.</font></td>
989: </tr>
990: <tr>
991: <td colspan='2'>
992: <input type='hidden' name="go" value="">
993: <input type='hidden' name="qnumformat" value="$qnumformat">
994: <input type='hidden' name="blocks" value="$blocks">
995: <input type="hidden" name="uploaduname" value="$uname">
996: <input type="hidden" name="filename" value="$fn">
997: <input type='hidden' name="page" value="$page">
998: <input type="hidden" name="phase" value="three">
999: |);
1000: for (my $i=0; $i<$blocks; $i++) {
1001: $r->print(qq|
1002: <input type='hidden' name="start_$i" value="$start[$i]">
1003: <input type='hidden' name="end_$i" value="$end[$i]">
1004: <input type='hidden' name="qtype_$i" value="$qtype[$i]">
1005: |);
1006: if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA") || ($qtype[$i] eq "Ord")) {
1007: $r->print(qq|
1008: <input type='hidden' name="foilformat_$i" value="$foilformats[$i]">
1009: |);
1010: }
1011: if (($qtype[$i] eq "MA") || ($qtype[$i] eq "FIB") || ($qtype[$i] eq "TF") || ($qtype[$i] eq "Ord")) {
1012: $r->print(qq|
1013: <input type='hidden' name="ansr_$i" value="$ansrtypes[$i]">
1014: |);
1015: }
1016: }
1017: $r->print(qq|
1018: </td>
1019: </tr>
1020: <tr>
1021: <td colspan='2'> <br /><br /></td>
1022: </tr>
1023: <tr>
1024: <td colspan='2'>
1025: <table border='0' cellspacing='0' cellpadding='0' width="100%">
1026: <tr>
1027: <td align='left'>
1028: <input type="button" name="backpage" value="Go back to step 3" onClick="javascript:backPage()">
1029: </td>
1030: <td align='right'>
1031: <input type="button" name="nextpage" value="Continue to step 5" onClick="javascript:nextPage()">
1032: </td>
1033: </tr>
1034: </table>
1035: </td>
1036: </tr>
1037: </table>
1038: </td>
1039: </tr>
1040: </table>
1041: </form>
1042: |);
1043: }
1044:
1045: # ---------------------------------------------------------------- Final Display
1046: sub final_display {
1047: my ($r,$uname,$fn,$page,$textref) = @_;
1048: my $qnumformat = $ENV{'form.qnumformat'};
1049: my $blocks = $ENV{'form.blocks'};
1050: my $newdir = $ENV{'form.newdir'};
1051: my $linkdir = $newdir;
1052: if ($linkdir =~ m#^/home/$uname/public_html/(.+)$#) {
1053: $linkdir = '/priv/'.$uname.'/'.$1;
1054: }
1055: my $question_id = '';
1056: my @question_title = ();
1057: my @question_status = ();
1058: my @qtype = ();
1059: my @start = ();
1060: my @nums = ();
1061: my @end = ();
1062: my @foilformats = ();
1063: my @ansrtypes = ();
1064: my %multparts = ();
1065: my $numitems = 0;
1066: for (my $i=0; $i<$blocks; $i++) {
1067: $start[$i] = $ENV{"form.start_$i"};
1068: $end[$i] = $ENV{"form.end_$i"};
1069: if (($end[$i] - $start[$i]) >= 0) {
1070: $nums[$i] = $end[$i] - $start[$i]+1;
1071: } else {
1072: $nums[$i] = 0;
1073: }
1074: $qtype[$i] = $ENV{"form.qtype_$i"};
1075: if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA") || ($qtype[$i] eq "Ord")) {
1076: $foilformats[$i] = $ENV{"form.foilformat_$i"};
1077: } else {
1078: $foilformats[$i] = '';
1079: }
1080: if (($qtype[$i] eq "MA") || ($qtype[$i] eq "FIB") || ($qtype[$i] eq "TF") || ($qtype[$i] eq "Ord")) {
1081: $ansrtypes[$i] = $ENV{"form.ansr_$i"};
1082: }
1083: $numitems += $nums[$i];
1084: }
1085:
1086: my @bgcolors = ('#ffffff','#eeeeee');
1087:
1088: my $import = join/'\s'/,@{$textref};
1089: my %answers = ();
1090: my @items = &file_split(\@start,\@end,\@nums,$qnumformat,\@foilformats,$textref,\%multparts,$numitems,\@qtype,$blocks);
1091:
1092: # Converting MC and MA answer to number, and splitting answers for FIB, and ordering for Ord.
1093: my @alphabet = ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
1094: my @romans = ("i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii","xiii","xiv","xv","xvi","xvii","xviii","xix","xx","xxi","xxii","xxiii","xxiv","xxv","xxvi");
1095: my %patterns = (
1096: comma => ',',
1097: space => '\s+',
1098: line => '[\r\n\f]+',
1099: tab => '\t+',
1100: );
1101: for (my $i=0; $i<$blocks; $i++) {
1102: if ($nums[$i] > 0) {
1103: if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA") || ($qtype[$i] eq "FIB") || ($qtype[$i] eq "Ord")) {
1104: for (my $k=$numitems+$start[$i]-1; $k<$numitems+$end[$i]; $k++) {
1105: @{$answers{$k}} = ();
1106: if ($qtype[$i] eq "MC") {
1107: lc $items[$k];
1108: $items[$k] =~ s/\W//g;
1109: if ($foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod") {
1110: for (my $j=0; $j<@alphabet; $j++) {
1111: if ($alphabet[$j] eq $items[$k]) {
1112: push @{$answers{$k}}, $j;
1113: last;
1114: }
1115: }
1116: } elsif (($foilformats[$i] eq "romparen") || ($foilformats[$i] eq "romperiod")) {
1117: for (my $j=0; $j<@romans; $j++) {
1118: if ($romans[$j] eq $items[$k]) {
1119: push @{$answers{$k}}, $j;
1120: last;
1121: }
1122: }
1123: }
1124: } elsif (($qtype[$i] eq "MA") || ($qtype[$i] eq "Ord")) {
1125: lc $items[$k];
1126: my @corrects = split/$patterns{$ansrtypes[$i]}/,$items[$k];
1127: foreach my $correct (@corrects) {
1128: $correct =~s/\W//g;
1129: if ($foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod") {
1130: for (my $j=0; $j<@alphabet; $j++) {
1131: if ($alphabet[$j] eq $correct) {
1132: push @{$answers{$k}}, $j;
1133: last;
1134: }
1135: }
1136: } elsif (($foilformats[$i] eq "romparen") || ($foilformats[$i] eq "romperiod")) {
1137: for (my $j=0; $j<@romans; $j++) {
1138: if ($romans[$j] eq $correct) {
1139: push @{$answers{$k}}, $j;
1140: last;
1141: }
1142: }
1143: }
1144: }
1145: } elsif ($qtype[$i] eq "FIB") {
1146: @{$answers{$k}} = split/$patterns{$ansrtypes[$i]}/,$items[$k];
1147: for (my $j=0; $j<@{$answers{$k}}; $j++) {
1148: $answers{$k}[$j] =~ s/^\s+//;
1149: $answers{$k}[$j] =~ s/\s+$//;
1150: }
1151: }
1152: }
1153: }
1154: }
1155: }
1156: my $pooltarget = '';
1157: my $pooldesc = '';
1158: my @newquestions = ();
1159: my $numquestions = 0;
1160: my %qtype = ();
1161: my %qtext = ();
1162: my %qflag = ();
1163:
1164: $r->print(<<"END_OF_BLOCK");
1165: <form name="verify" method="post">
1166: <table border='0' cellspacing='0' cellpadding='0' width="100%">
1167: <tr>
1168: <td colspan='2' align='left'>
1169: </td>
1170: </tr>
1171: <tr bgcolor='#ccddaa'>
1172: <td align='top'>
1173: </td>
1174: <td valign='middle'><img src='/res/adm/pages/bl_step5.gif'>
1175: <font size='+1' face='arial,helvetica,sans-serif'> <b>Result of conversion of tesbank questions to LON-CAPA problems.</b></font>
1176: </td>
1177: </tr>
1178: <tr>
1179: <td colspan='2'> </td>
1180: </tr>
1181: END_OF_BLOCK
1182: if ($newdir ne "") {
1183: my @qn_file = ();
1184: my $qcount = 0;
1185: for (my $i=0; $i<$blocks; $i++) {
1186: if ($nums[$i] > 0) {
1187: if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA") || ($qtype[$i] eq "FIB") || ($qtype[$i] eq "Ord")) {
1188: for (my $j=$start[$i]-1; $j<$end[$i]; $j++) {
1189: my $answer = $j + $numitems;
1190: my $numans = scalar(@{$answers{$answer}});
1191: my $foilcount = 0;
1192: if (($qtype[$i] eq "MC") || ($qtype[$i] eq "MA") || ($qtype[$i] eq "Ord")) {
1193: $foilcount = @{$multparts{$j}};
1194: $foilcount --;
1195: }
1196: $qn_file[$qcount] = &create_mcq($newdir,\@{$multparts{$j}},\@{$answers{$answer}},$qtype[$i],$j);
1197: $qcount ++;
1198: push @newquestions, $question_id;
1199: }
1200: } elsif ($qtype[$i] eq "TF") {
1201: for (my $j=$start[$i]-1; $j<$end[$i]; $j++) {
1202: my $answer = $j + $numitems;
1203: $items[$answer] =~ s/^\s+//;
1204: $items[$answer] =~ s/\s+$//;
1205: $items[$answer] =~ s/\W//g;
1206: $items[$answer] =~ tr/A-Z/a-z/;
1207: my $answer_id = '';
1208: if ($ansrtypes[$i] eq 'word' ) {
1209: if ($items[$answer] =~ m/true/) {
1210: $answer_id = 0;
1211: } else {
1212: $answer_id = 1;
1213: }
1214: } elsif ($ansrtypes[$i] eq 'lett') {
1215: if ($items[$answer] =~ m/^t/) {
1216: $answer_id = 0;
1217: } else {
1218: $answer_id = 1;
1219: }
1220: }
1221: $qn_file[$qcount] = create_ess($newdir,$answer_id,$items[$j],$items[$answer],$qtype[$i],$j);
1222: push @newquestions, $question_id;
1223: $qcount ++;
1224: }
1225: } elsif ($qtype[$i] eq "Ess") {
1226: for (my $j=$start[$i]-1; $j<$end[$i]; $j++) {
1227: my $answer = $j + $numitems;
1228: my $answer_id = '';
1229: $qn_file[$qcount] = create_ess($newdir,$answer_id,$items[$j],$items[$answer],$qtype[$i],$j);
1230: push @newquestions, $question_id;
1231: $qcount ++;
1232: }
1233: }
1234: }
1235: }
1236: $r->print(qq|<tr><tr><td> </td><td><font face='arial,helvetica,sans-serif'>Individual problem files have been created from the problems included in the textbank file:
1237: <ul>|);
1238: for (my $i=0; $i<@qn_file; $i++) {
1239: my $display = $i+1;
1240: $r->print(qq|
1241: <li><b><a href="$linkdir/$qn_file[$i]">Problem $display file</a></b></li>
1242: |);
1243: }
1244: $r->print(qq|
1245: </ul></font></td></tr>
1246: <tr><td> </td>
1247: <td><font face='arial,helvetica,sans-serif'>The problems must be published before they can be used in a course.</font></td>
1248: |);
1249: } else {
1250: $r->print(qq|
1251: <tr>
1252: <td> </td>
1253: <td><font face='arial,helvetica,sans-serif'>No destination file was selected or created, so import of your questions could not proceed.
1254: Please return to the previous page and select a valid file into which to import the questions. </font>
1255: <input type="hidden" name="go" value="">
1256: <input type="hidden" name="page" value="$page">
1257: <input type="hidden" name="uploaduname" value="$uname">
1258: <input type="hidden" name="filename" value="$fn">
1259: <input type='hidden' name="page" value="$page">
1260: <input type="hidden" name="phase" value="three">
1261: <input type="hidden" name="qnumformat" value="$qnumformat">
1262: <input type="hidden" name="newdir" value="$newdir">
1263: |);
1264: for (my $i=0; $i<$blocks; $i++) {
1265: $r->print(qq|
1266: <input type="hidden" name="start_$i" value="$start[$i]">
1267: <input type="hidden" name="end_$i" value="$end[$i]">
1268: <input type="hidden" name="qtype_$i" value="$qtype[$i]">
1269: <input type="hidden" name="foilformat_$i" value="$foilformats[$i]">
1270: <input type="hidden" name="ansr_$i" value="$ansrtypes[$i]">
1271: |);
1272: }
1273: $r->print(<<"END_OF_FAIL");
1274: </td>
1275: </tr>
1276: <tr>
1277: <td colspan='2'>
1278: <table border='0' width='100%'>
1279: <tr>
1280: <td align='right'>
1281: <input type="button" name="backpage" value="Return to step 3" onClick="javascript:backPage()">
1282: </td>
1283: </tr>
1284: </table>
1285: </td>
1286: </tr>
1287: </table>
1288: </td>
1289: </tr>
1290: </table>
1291: </td>
1292: </tr>
1293: </table>
1294: </form>
1295: </body>
1296: </html>
1297: END_OF_FAIL
1298: return;
1299: }
1300: $r->print(<<"END_OF_BODY");
1301: </table>
1302: </td>
1303: </tr>
1304: </table>
1305: </td>
1306: </tr>
1307: <tr>
1308: <td colspan='2'>
1309: <input type="hidden" name="go" value="">
1310: <input type="hidden" name="page" value="$page">
1311: <input type="hidden" name="uploaduname" value="$uname">
1312: <input type="hidden" name="filename" value="$fn">
1313: <input type='hidden' name="page" value="$page">
1314: <input type="hidden" name="phase" value="one">
1315: <input type="hidden" name="qnumformat" value="$qnumformat">
1316: <input type="hidden" name="newdir" value="$newdir">
1317: </td>
1318: </tr>
1319: <tr>
1320: <td colspan='2'>
1321: <table border='0' width='100%'>
1322: <tr>
1323: <td align='left'>
1324: <input type='button' name='backtostart' value='Back to start page' onClick='javascript:backtoStart()'>
1325: </td>
1326: </tr>
1327: </table>
1328: </td>
1329: </tr>
1330: </table>
1331: </td>
1332: </tr>
1333: </table>
1334: </td>
1335: </tr>
1336: </table>
1337: </form>
1338: END_OF_BODY
1339: }
1340:
1341: sub question_count {
1342: my ($qnumformat,$textref) = @_;
1343: my $text_in = join "\n", @{$textref};
1344: $text_in = "\n ".$text_in;
1345: my $qpattern ='';
1346: if ($qnumformat eq "period") {
1347: $qpattern = '\d{1,}\.';
1348: } elsif ($qnumformat eq "paren") {
1349: $qpattern = '\(\d{1,}\)';
1350: } elsif ($qnumformat eq "number") {
1351: $qpattern = '\d{1,}';
1352: } elsif ($qnumformat eq "leadparen") {
1353: $qpattern = '\(\d{1,}';
1354: } elsif ($qnumformat eq "trailparen") {
1355: $qpattern = '\d{1,}\)';
1356: }
1357: my @questions = split/[\r\n\f]+\s?$qpattern\s?/,$text_in;
1358: my $qcount = scalar(@questions);
1359: $qcount = $qcount/2;
1360: $qcount = int($qcount);
1361: return $qcount;
1362: }
1363:
1364: sub file_split {
1365: my ($startsref,$endsref,$numsref,$qnumformat,$foilsref,$textref,$multpartsref,$numitems,$qtyperef,$blocks) = @_;
1366: my $text_in = join "\n", @{$textref};
1367: $text_in = "\n ".$text_in;
1368: my $dignum = length($numitems);
1369: my $numpat;
1370: if ($dignum > 1) {
1371: $numpat = ','.$dignum.'}';
1372: } else {
1373: $numpat = '}';
1374: }
1375: my $qpattern ='';
1376: if ($qnumformat eq "period") {
1377: $qpattern = '\d{1'.$numpat.'\.';
1378: } elsif ($qnumformat eq "paren") {
1379: $qpattern = '\(\d{1'.$numpat.'\)';
1380: } elsif ($qnumformat eq "number") {
1381: $qpattern = '\d{1'.$numpat;
1382: } elsif ($qnumformat eq "leadparen") {
1383: $qpattern = '\(\d{1'.$numpat;
1384: } elsif ($qnumformat eq "trailparen") {
1385: $qpattern = '\d{1'.$numpat.'\)';
1386: }
1387: my @questions = split/[\r\n\f]+\s?$qpattern\s?/,$text_in;
1388: # my @questions = split/\n\s\d{1,3}\.\s/,$text_in;
1389: shift @questions;
1390: my %multparts = ();
1391: for (my $i=0; $i<$blocks; $i++) {
1392: if (${$numsref}[$i] > 0) {
1393: if ((${$qtyperef}[$i] eq "MC") || (${$qtyperef}[$i] eq "MA")) {
1394: my $splitstr = '';
1395: if (${$foilsref}[$i] eq "lcperiod") {
1396: $splitstr = '[a-z]\.';
1397: } elsif (${$foilsref}[$i] eq "lcparen") {
1398: $splitstr = '\([a-z]\)';
1399: } elsif (${$foilsref}[$i] eq "ucperiod") {
1400: $splitstr = '[A-Z]\.';
1401: } elsif (${$foilsref}[$i] eq "ucparen") {
1402: $splitstr = '\([A-Z]\)';
1403: } elsif (${$foilsref}[$i] eq "romperiod") {
1404: $splitstr = '[ivx]+\.';
1405: } elsif (${$foilsref}[$i] eq "romparen") {
1406: $splitstr = '\([ivx]+\)';
1407: }
1408: for (my $j=${$startsref}[$i]-1; $j<${$endsref}[$i]; $j++) {
1409: @{$multparts{$j}} = split/[\r\n\f]+\s?$splitstr\s?/,$questions[$j];
1410: chomp(@{$multparts{$j}});
1411: foreach my $foil (@{$multparts{$j}}) {
1412: }
1413: }
1414: } elsif (${$qtyperef}[$i] eq "FIB") {
1415: for (my $j=${$startsref}[$i]-1; $j<${$endsref}[$i]; $j++) {
1416: @{$multparts{$j}} = ("$questions[$j]");
1417: }
1418: }
1419: }
1420: }
1421: %{$multpartsref} = %multparts;
1422: return @questions;
1423: }
1424:
1425: # create_mcq builds an MC, MA, Ord or FIB question
1426:
1427: sub create_mcq {
1428: my ($newdir,$qstnref,$answerref,$qtype,$qnum) = @_;
1429: $qnum ++;
1430: if (length($qnum) == 1) {
1431: $qnum = "00".$qnum;
1432: } elsif (length($qnum) == 2) {
1433: $qnum = "0".$qnum;
1434: }
1435: my $qstn = ${$qstnref}[0];
1436: my $numfoils = scalar(@{$qstnref}) - 1;
1437: my $datestamp = localtime;
1438: my $timestamp = time;
1439: my $libfile = 'question_'.$qnum;
1440: $libfile .= '.problem';
1441: my $numansrs = scalar(@{$answerref});
1442: my $output = qq|<problem>
1443: <startouttext />$qstn<endouttext />
1444: |;
1445:
1446: if ($qtype eq "MA") {
1447: $output .= qq|
1448: <optionresponse max="$numfoils" randomize="yes">
1449: <foilgroup options="('True','False')">
1450: |;
1451: for (my $k=0; $k<@{$qstnref}-1; $k++) {
1452: $output .= " <foil name=\"foil".$k."\" value=\"";
1453: if (grep/^$k$/,@{$answerref}) {
1454: $output .= "True\" location=\"random\"";
1455: } else {
1456: $output .= "False\" location=\"random\"";
1457: }
1458: $output .= "\><startouttext />".${$qstnref}[$k+1]."<endouttext /></foil>\n";
1459: }
1460: chomp($output);
1461: $output .= qq|
1462: </foilgroup>
1463: </optionresponse>
1464: </problem>
1465: |;
1466: }
1467: if ($qtype eq "MC") {
1468: $output .= qq|
1469: <radiobuttonresponse max="$numfoils" randomize="yes">
1470: <foilgroup>
1471: |;
1472: for (my $k=0; $k<@{$qstnref}-1; $k++) {
1473: $output .= " <foil name=\"foil".$k."\" value=\"";
1474: if (grep/^$k$/,@{$answerref}) {
1475: $output .= "true\" location=\"";
1476: } else {
1477: $output .= "false\" location=\"";
1478: }
1479: if (lc (${$qstnref}[$k+1]) =~ m/^\s?([Aa]ll)|([Nn]one)\sof\sthe\sabove\.?/) {
1480: $output .= "bottom\"";
1481: } else {
1482: $output .= "random\"";
1483: }
1484: $output .= "\><startouttext />".${$qstnref}[$k+1]."<endouttext /></foil>\n";
1485: }
1486: chomp($output);
1487: $output .= qq|
1488: </foilgroup>
1489: </radiobuttonresponse>
1490: </problem>
1491: |;
1492: }
1493:
1494: if ($qtype eq "Ord") {
1495: $output .= qq|
1496: <rankresponse max="$numfoils" randomize="yes">
1497: <foilgroup>
1498: |;
1499: for (my $k=0; $k<@{$qstnref}-1; $k++) {
1500: $output .= " <foil location=\"random\" name=\"foil".$k."\" value=\"".$$answerref[$k]."\><startouttext />".${$qstnref}[$k+1]."<endouttext /></foil>\n";
1501: }
1502: chomp($output);
1503: $output .= qq|
1504: </foilgroup>
1505: </rankresponse>
1506: </problem>
1507: |;
1508: }
1509:
1510: if ($qtype eq "FIB") {
1511: my $numerical = 1;
1512: for (my $i=0; $i<@{$answerref}; $i++) {
1513: if (${$answerref}[$i] =~ m/([^\d\.]|\.\.)/) {
1514: $numerical = 0;
1515: }
1516: }
1517: if ($numerical) {
1518: my $numans;
1519: my $tol;
1520: if (@{$answerref} == 1) {
1521: $tol = 5;
1522: $numans = $$answerref[0];
1523: } else {
1.2 ! raeburn 1524: my $min = $$answerref[0];
! 1525: my $max = $$answerref[0];
! 1526: for (my $i=1; $i<@{$answerref}; $i++) {
! 1527: if ($$answerref[$i]<=$min) {
1.1 raeburn 1528: $min = $$answerref[$i];
1.2 ! raeburn 1529: } elsif ($$answerref[$i] >= $max) {
1.1 raeburn 1530: $max = $$answerref[$i];
1531: }
1532: }
1533: $numans = ($max + $min)/2;
1534: $tol = 100*($max - $min)/($numans*2);
1535: }
1536: $output .= qq|
1537: <numericalresponse answer="$numans">
1538: <responseparam type="tolerance" default="$tol%" name="tol" description="Numerical Tolerance" />
1539: <responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures" />
1540: <textline />
1541: </numericalresponse>
1542: </problem>
1543: |;
1544: } else {
1545: if (@{$answerref} == 1) {
1546: $output .= qq|
1547: <stringresponse answer="$$answerref[0]" type="ci">
1548: <textline>
1549: </textline>
1550: </stringresponse>
1551: </problem>
1552: |;
1553: } else {
1554: for (my $i=0; $i<@{$answerref}; $i++) {
1555: ${$answerref}[$i] =~ s/\|/\|/g;
1556: }
1557: my $regexpans = join('|',@{$answerref});
1558: $regexpans = '/('.$regexpans.')/';
1559: $output .= qq|
1560: <stringresponse answer="$regexpans" type="re">
1561: <textline>
1562: </textline>
1563: </stringresponse>
1564: </problem>
1565: |;
1566: }
1567: }
1568: }
1569: open(PROB,">$newdir/$libfile");
1570: print PROB $output;
1571: close PROB;
1572: return $libfile;
1573: }
1574:
1575: # create_ess builds an essay or True/False question
1576:
1577: sub create_ess {
1578: my ($newdir,$answer_id,$qstn,$answertxt,$qtype,$qnum) = @_;
1579: $qnum ++;
1580: if (length($qnum) == 1) {
1581: $qnum = "00".$qnum;
1582: } elsif (length($qnum) == 2) {
1583: $qnum = "0".$qnum;
1584: }
1585: my $libfile = 'question_'.$qnum;
1586: $libfile .= '.problem';
1587: my $output = qq|<problem>
1588: <startouttext />$qstn<endouttext />|;
1589:
1590: my $answer = '';
1591: my $answerlog = '';
1592: if ($qtype eq "Ess") {
1593: $output .= qq|
1594: <essayresponse>
1595: <textfield></textfield>
1596: </essayresponse>
1597: <postanswerdate>
1598: $answertxt
1599: </postanswerdate>
1600: </problem>|;
1601: } elsif ($qtype eq "TF") {
1602: $answer = $answer_id;
1603: $output .= qq|
1604: <radiobuttonresponse max="2" randomize="yes">
1605: <foilgroup>
1606: |;
1607: $output .= " <foil name=\"foil0\" value=\"true\" location=\"random\"><startouttext />";
1608: if ($answer_id) {
1609: $output .= "False";
1610: } else {
1611: $output .= "True";
1612: }
1613: $output .= "<endouttext /></foil>\n";
1614: $output .= " <foil name=\"foil1\" value=\"false\" location=\"random\"><startouttext />";
1615: if ($answer_id) {
1616: $output .= "True";
1617: } else {
1618: $output .= "False";
1619: }
1620: $output .= qq|<endouttext /></foil>
1621: </foilgroup>
1622: </radiobuttonresponse>
1623: </problem>|;
1624: }
1625: open(PROB,">$newdir/$libfile");
1626: print PROB $output;
1627: close PROB;
1628: return $libfile;
1629: }
1630:
1631: sub file_error {
1632: my ($r,$uname,$fn,$current_page);
1633: $r->print("No data here");
1634: }
1635:
1636: # ---------------------------------------------------------------- Main Handler
1637: sub handler {
1638: my $r=shift;
1639: my $uname;
1640: my $udom;
1641: my $javascript = '';
1642: my $page_name = '';
1643: my $current_page = '';
1644: my $loadentries = '';
1645: my $qcount = '';
1646: #
1647: # phase two: re-attach user
1648: #
1649: if ($ENV{'form.uploaduname'}) {
1650: $ENV{'form.filename'}='/priv/'.$ENV{'form.uploaduname'}.'/'.
1651: $ENV{'form.filename'};
1652: }
1653: ($uname,$udom)=
1654: &Apache::loncacc::constructaccess($ENV{'form.filename'},
1655: $r->dir_config('lonDefDomain'));
1656: unless (($uname) && ($udom)) {
1657: $r->log_reason($uname.' at '.$udom.
1658: ' trying to publish file '.$ENV{'form.filename'}.
1659: ' - not authorized',
1660: $r->filename);
1661: return HTTP_NOT_ACCEPTABLE;
1662: }
1663:
1664: my $fn;
1665: my $badfile = 0;
1666: if ($ENV{'form.filename'}) {
1667: $fn=$ENV{'form.filename'};
1668: $fn=~s/^http\:\/\/[^\/]+\///;
1669: $fn=~s/^\///;
1670: $fn=~s/(\~|priv\/)(\w+)//;
1671: $fn=~s/\/+/\//g;
1672: } else {
1673: $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
1674: ' unspecified filename for upload', $r->filename);
1675: return HTTP_NOT_FOUND;
1676: }
1677: my $pathname = &File::Basename::dirname($fn);
1678: my $fullpath = '/priv/'.$uname.$pathname;
1679: unless ($pathname eq '/') {
1680: $fullpath .= '/';
1681: }
1682:
1683: my $dirpath = '/home/'.$uname.'/public_html';
1684:
1685: my @text = ();
1686: my $loadentries = '';
1687: if ($ENV{'form.phase'} eq 'three') {
1688: if (-e "$dirpath$fn") {
1689: open(TESTBANK,"<$dirpath$fn");
1690: @text = <TESTBANK>;
1691: close(TESTBANK);
1692: } else {
1693: $badfile = 1;
1694: }
1695: }
1696:
1697: # ----------------------------------------------------------- Start page output
1698: &Apache::loncommon::content_type($r,'text/html');
1699: $r->send_http_header;
1700:
1701: if ($ENV{'form.phase'} eq 'three') {
1702: $current_page = &display_control();
1703: my @PAGES = ('Welcome','Blocks','Format','Target','Confirmation');
1704: $page_name = $PAGES[$current_page];
1705:
1706: if ($page_name eq 'Blocks') {
1707: $loadentries = 'onLoad= "setElements()"';
1708: &jscript_one(\$javascript);
1709: } elsif ($page_name eq 'Format') {
1710: $qcount = question_count($ENV{'form.qnumformat'},\@text);
1711: &jscript_two(\$javascript,$qcount);
1712: } elsif ($page_name eq 'Target') {
1713: if ($ENV{'form.go'} eq "PreviousPage") {
1714: $loadentries = 'onLoad = "setElements()"';
1715: }
1716: &jscript_three($fullpath,\$javascript);
1717: } elsif ($page_name eq 'Confirmation') {
1718: &jscript_four(\$javascript,$fullpath);
1719: }
1720: }
1721:
1722: $r->print("<html><head><title>LON-CAPA Construction Space</title><script type=\"text/javascript\">\n//<!--\n$javascript\n// --></script>\n</head>");
1723:
1724: $r->print(&Apache::loncommon::bodytag('Upload testbank questions to Construction Space',undef,$loadentries));
1725:
1726: if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
1727: $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.
1728: &mt(' at ').$udom.'</font></h3>');
1729: }
1730:
1731: if ($ENV{'form.phase'} eq 'three') {
1732: if ($badfile) {
1733: &file_error($r,$uname,$fn,$current_page);
1734: } else {
1735: &display_zero ($r,$uname,$fn,$current_page,$fullpath) if $page_name eq 'Welcome';
1736: &display_one ($r,$uname,$fn,$current_page,\@text) if $page_name eq 'Blocks';
1737: &display_two ($r,$uname,$fn,$current_page,\@text,$qcount) if $page_name eq 'Format';
1738: &display_three ($r,$uname,$fn,$current_page,\@text,$qcount) if $page_name eq 'Target';
1739: &final_display ($r,$uname,$fn,$current_page,\@text) if $page_name eq 'Confirmation';
1740: }
1741: } elsif ($ENV{'form.phase'} eq 'two') {
1742: my $flag = &Apache::lonupload::phasetwo($r,$fn,$uname,$udom,'testbank');
1743: if ($flag eq 'ok') {
1744: my $current_page = 0;
1745: &display_zero($r,$uname,$fn,$current_page,$fullpath);
1746: }
1747: } else {
1748: &Apache::lonupload::phaseone($r,$fn,$uname,$udom,'testbank');
1749: }
1750: $r->print('</body></html>');
1751: return OK;
1752: }
1753: 1;
1754: __END__
1755:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>