[LON-CAPA-cvs] cvs: loncom /publisher testbankimport.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 05 Aug 2004 21:08:24 -0000


This is a MIME encoded message

--raeburn1091740104
Content-Type: text/plain

raeburn		Thu Aug  5 17:08:24 2004 EDT

  Modified files:              
    /loncom/publisher	testbankimport.pm 
  Log:
  Fix bugs 3272, 3273, 3275. Support for more formats and multiple spaces between foil identifiers and foils in testbank file.
  
  
--raeburn1091740104
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040805170824.txt"

Index: loncom/publisher/testbankimport.pm
diff -u loncom/publisher/testbankimport.pm:1.4 loncom/publisher/testbankimport.pm:1.5
--- loncom/publisher/testbankimport.pm:1.4	Fri Apr 23 18:42:05 2004
+++ loncom/publisher/testbankimport.pm	Thu Aug  5 17:08:24 2004
@@ -1,5 +1,5 @@
 # Handler for parsing text upload problem descriptions into .problems
-# $Id: testbankimport.pm,v 1.4 2004/04/23 22:42:05 raeburn Exp $
+# $Id: testbankimport.pm,v 1.5 2004/08/05 21:08:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -248,8 +248,14 @@
             poolForm.elements[caller*5+4].options[2] = new Option("A.","ucperiod",false,false)
             poolForm.elements[caller*5+4].options[3] = new Option("(a)","lcparen",false,false)
             poolForm.elements[caller*5+4].options[4] = new Option("(A)","ucparen",false,false)
-            poolForm.elements[caller*5+4].options[5] = new Option("(i)","romparen",false,false)
-            poolForm.elements[caller*5+4].options[6] = new Option("i.","romperiod",false,false)
+            poolForm.elements[caller*5+4].options[5] = new Option("a)","lconeparen",false,false)
+            poolForm.elements[caller*5+4].options[6] = new Option("A)","uconeparen",false,false)
+            poolForm.elements[caller*5+4].options[7] = new Option("a.)","lcdotparen",false,false)
+            poolForm.elements[caller*5+4].options[8] = new Option("A.)","ucdotparen",false,false)
+            poolForm.elements[caller*5+4].options[9] = new Option("(i)","romparen",false,false)
+            poolForm.elements[caller*5+4].options[10] = new Option("i)","romoneparen",false,false)
+            poolForm.elements[caller*5+4].options[11] = new Option("i.)","romdotparen",false,false)
+            poolForm.elements[caller*5+4].options[12] = new Option("i.","romperiod",false,false)
             poolForm.elements[caller*5+4].selectedIndex = 0
         }
         else {
@@ -281,7 +287,10 @@
                 if (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "TF") {
                     poolForm.elements[caller*5+5].options[0] = new Option("Please Select","-1",true,true)
                     poolForm.elements[caller*5+5].options[1] = new Option("True or False","word",false,false)
-                    poolForm.elements[caller*5+5].options[2] = new Option("T or F","lett",false,false)
+                    poolForm.elements[caller*5+5].options[2] = new Option("true or false","word",false,false)
+                    poolForm.elements[caller*5+5].options[3] = new Option("TRUE or FALSE","word",false,false)
+                    poolForm.elements[caller*5+5].options[4] = new Option("T or F","lett",false,false)
+                    poolForm.elements[caller*5+5].options[5] = new Option("t or f","lett",false,false)
                 }
                 else {
                     poolForm.elements[caller*5+5].options[0] = new Option("Not required","0",true,true)
@@ -950,17 +959,31 @@
                                     $foiltag = $alphabet[$k-1].'.'; 
                                 } elsif ($foilformats[$i] eq "lcparen") {
                                     $foiltag = '('.$alphabet[$k-1].')';
+                                } elsif ($foilformats[$i] eq "lconeparen") {
+                                    $foiltag = $alphabet[$k-1].')';
+                                } elsif ($foilformats[$i] eq "lcdotparen") {
+                                    $foiltag = $alphabet[$k-1].'.)';
                                 } elsif ($foilformats[$i] eq "ucperiod") {
                                     $foiltag = $alphabet[$k-1].'.';
                                     $foiltag =~ tr/a-z/A-Z/;
                                 } elsif ($foilformats[$i] eq "ucparen") {
                                     $foiltag = '('.$alphabet[$k-1].')';
                                     $foiltag =~ tr/a-z/A-Z/;
+                                } elsif ($foilformats[$i] eq "uconeparen") {
+                                    $foiltag = $alphabet[$k-1].')';
+                                    $foiltag =~ tr/a-z/A-Z/;
+                                } elsif ($foilformats[$i] eq "ucdotparen") {
+                                    $foiltag = $alphabet[$k-1].'.)';
+                                    $foiltag =~ tr/a-z/A-Z/;
                                 } elsif ($foilformats[$i] eq "romperiod") {
                                     $foiltag = $romans[$k-1].'.';
                                 } elsif ($foilformats[$i] eq "romparen") {
                                     $foiltag = '('.$romans[$k-1].')';
-                                }
+                                } elsif ($foilformats[$i] eq "romoneparen") {
+                                    $foiltag = $romans[$k-1].')';
+                                } elsif ($foilformats[$i] eq "romdotparen") {
+                                    $foiltag = $romans[$k-1].'.)';
+                                } 
                                 $r->print(qq|$foiltag $multparts{$j}[$k]<br>\n|);
                             }
                         }
@@ -1132,14 +1155,14 @@
                     if ($qtype[$i] eq "MC") {
                         $items[$k] =~ tr/A-Z/a-z/;
                         $items[$k] =~ s/\W//g;
-                        if ($foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod") {
+                        if ($foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "lconeparen" || $foilformats[$i] eq "lcdotparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod" || $foilformats[$i] eq "uconeparen" || $foilformats[$i] eq "ucdotparen") {
                             for (my $j=0; $j<@alphabet; $j++) {
                                 if ($alphabet[$j] eq $items[$k]) {
                                     push @{$answers{$k}}, $j;
                                     last;
                                 }
                             }
-                        } elsif (($foilformats[$i] eq "romparen") || ($foilformats[$i] eq "romperiod")) {
+                        } elsif (($foilformats[$i] eq "romparen") || ($foilformats[$i] eq "romperiod") || ($foilformats[$i] eq "romoneparen") || ($foilformats[$i] eq "romdotparen")) {
                             for (my $j=0; $j<@romans; $j++) {
                                 if ($romans[$j] eq $items[$k]) {
                                     push @{$answers{$k}}, $j;
@@ -1159,7 +1182,7 @@
                                         last;
                                     }
                                 }
-                            } elsif (($foilformats[$i] eq "romparen") || ($foilformats[$i] eq "romperiod")) {
+                            } elsif (($foilformats[$i] eq "romparen") || ($foilformats[$i] eq "romperiod") || ($foilformats[$i] eq "romoneparen") || ($foilformats[$i] eq "romdotparen")) {
                                 for (my $j=0; $j<@romans; $j++) {
                                     if ($romans[$j] eq $correct) {
                                         push @{$answers{$k}}, $j;
@@ -1410,7 +1433,7 @@
     } elsif ($qnumformat eq "trailparen") {
         $qpattern = '\d{1'.$numpat.'\)';
     }
-    my @questions = split/[\r\n\f]+\s?$qpattern\s?/,$text_in;
+    my @questions = split/[\r\n\f]+\s*$qpattern\s*/,$text_in;
 # my @questions = split/\n\s\d{1,3}\.\s/,$text_in;
     shift @questions;
     my %multparts = ();
@@ -1422,20 +1445,30 @@
                     $splitstr = '[a-z]\.';
                 } elsif (${$foilsref}[$i] eq "lcparen") {
                     $splitstr = '\([a-z]\)';
+                } elsif (${$foilsref}[$i] eq "lconeparen") {
+                    $splitstr = '[a-z]\)';
+                } elsif (${$foilsref}[$i] eq "lcdotparen") {
+                    $splitstr = '[a-z]\.\)';
                 } elsif (${$foilsref}[$i] eq "ucperiod") {
                     $splitstr = '[A-Z]\.';
                 } elsif (${$foilsref}[$i] eq "ucparen") {
                     $splitstr = '\([A-Z]\)';
+                } elsif (${$foilsref}[$i] eq "uconeparen") {
+                    $splitstr = '[A-Z]\)';
+                } elsif (${$foilsref}[$i] eq "ucdotparen") {
+                    $splitstr = '[A-Z]\.\)';
                 } elsif (${$foilsref}[$i] eq "romperiod") {
                     $splitstr = '[ivx]+\.';
                 } elsif (${$foilsref}[$i] eq "romparen") {
                     $splitstr = '\([ivx]+\)';
+                } elsif (${$foilsref}[$i] eq "romoneparen") {
+                    $splitstr = '[ivx]+\)';
+                } elsif (${$foilsref}[$i] eq "romdotparen") {
+                    $splitstr = '[ivx]+\.\)';
                 }
                 for (my $j=${$startsref}[$i]-1; $j<${$endsref}[$i]; $j++) {
-                    @{$multparts{$j}} = split/[\r\n\f]+\s?$splitstr\s?/,$questions[$j];
+                    @{$multparts{$j}} = split/[\r\n\f]+\s*$splitstr\s*/,$questions[$j];
                     chomp(@{$multparts{$j}});
-                    foreach my $foil (@{$multparts{$j}}) {
-                    } 
                 }
             } elsif (${$qtyperef}[$i] eq "FIB") { 
                 for (my $j=${$startsref}[$i]-1; $j<${$endsref}[$i]; $j++) {

--raeburn1091740104--