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

raeburn raeburn at source.lon-capa.org
Wed Oct 9 20:46:50 EDT 2013


raeburn		Thu Oct 10 00:46:50 2013 EDT

  Modified files:              
    /loncom/publisher	testbankimport.pm 
  Log:
  - Support 'a ' and 'A ' (i.e., letter+space) as foil identifiers.
  
  
Index: loncom/publisher/testbankimport.pm
diff -u loncom/publisher/testbankimport.pm:1.42 loncom/publisher/testbankimport.pm:1.43
--- loncom/publisher/testbankimport.pm:1.42	Mon Jul 15 14:32:59 2013
+++ loncom/publisher/testbankimport.pm	Thu Oct 10 00:46:50 2013
@@ -1,5 +1,5 @@
 # Handler for parsing text upload problem descriptions into .problems
-# $Id: testbankimport.pm,v 1.42 2013/07/15 14:32:59 bisitz Exp $
+# $Id: testbankimport.pm,v 1.43 2013/10/10 00:46:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -289,18 +289,20 @@
     else {
         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")) {
             poolForm.elements[caller*5+4].options[0] = new Option("Select","-1",true,true)
-            poolForm.elements[caller*5+4].options[1] = new Option("a.","lcperiod",false,false)
-            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("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].options[1] = new Option("a ","lcspace",false,false)
+            poolForm.elements[caller*5+4].options[2] = new Option("A ","ucspace",false,false) 
+            poolForm.elements[caller*5+4].options[3] = new Option("a.","lcperiod",false,false)
+            poolForm.elements[caller*5+4].options[4] = new Option("A.","ucperiod",false,false)
+            poolForm.elements[caller*5+4].options[5] = new Option("(a)","lcparen",false,false)
+            poolForm.elements[caller*5+4].options[6] = new Option("(A)","ucparen",false,false)
+            poolForm.elements[caller*5+4].options[7] = new Option("a)","lconeparen",false,false)
+            poolForm.elements[caller*5+4].options[8] = new Option("A)","uconeparen",false,false)
+            poolForm.elements[caller*5+4].options[9] = new Option("a.)","lcdotparen",false,false)
+            poolForm.elements[caller*5+4].options[10] = new Option("A.)","ucdotparen",false,false)
+            poolForm.elements[caller*5+4].options[11] = new Option("(i)","romparen",false,false)
+            poolForm.elements[caller*5+4].options[12] = new Option("i)","romoneparen",false,false)
+            poolForm.elements[caller*5+4].options[13] = new Option("i.)","romdotparen",false,false)
+            poolForm.elements[caller*5+4].options[14] = new Option("i.","romperiod",false,false)
             poolForm.elements[caller*5+4].selectedIndex = 0
         }
         else {
@@ -774,7 +776,12 @@
                                           '<td valign="top">'.$showqn.'<br /><br />'."\n");
                             } else {
                                 my $foiltag = '';
-                                if ($foilformats[$i] eq "lcperiod") {
+                                if ($foilformats[$i] eq "lcspace") {
+                                    $foiltag = $alphabet->[$k-1].' ';
+                                } elsif ($foilformats[$i] eq "ucspace") {
+                                    $foiltag = $alphabet->[$k-1].' ';
+                                    $foiltag =~ tr/a-z/A-Z/;
+                                } elsif ($foilformats[$i] eq "lcperiod") {
                                     $foiltag = $alphabet->[$k-1].'.'; 
                                 } elsif ($foilformats[$i] eq "lcparen") {
                                     $foiltag = '('.$alphabet->[$k-1].')';
@@ -924,7 +931,7 @@
                         $items->[$k] =~ tr/A-Z/a-z/;
                         $items->[$k] =~ s/<\/?[^>]+>//g;
                         $items->[$k] =~ s/\W//g;
-                        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") {
+                        if ($foilformats[$i] eq "lcspace" || $foilformats[$i] eq "ucspace" || $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{$qnum}}, $j;
@@ -957,7 +964,7 @@
                             } else {
                                 $correct =~s/\W//g;
                             }
-                            if ($foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod") {
+                            if ($foilformats[$i] eq "lcspace" || $foilformats[$i] eq "ucspace" || $foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod") {
                                 if (($qtype[$i] eq "Ord") && (@tied > 0)) {
                                     my @ties;
                                     foreach my $tie (@tied) {
@@ -1275,7 +1282,11 @@
         if (${$numsref}[$i] > 0) {
             if ((${$qtyperef}[$i] eq "MC") || (${$qtyperef}[$i] eq "MA") || (${$qtyperef}[$i] eq "Ord")) {
                 my $splitstr = '';
-                if (${$foilsref}[$i] eq "lcperiod") {
+                if (${$foilsref}[$i] eq "lcspace") {
+                    $splitstr = '[a-z]\s';
+                } elsif (${$foilsref}[$i] eq "ucspace") {
+                    $splitstr = '[A-Z]\s';
+                } elsif (${$foilsref}[$i] eq "lcperiod") {
                     $splitstr = '[a-z]\.';
                 } elsif (${$foilsref}[$i] eq "lcparen") {
                     $splitstr = '\([a-z]\)';




More information about the LON-CAPA-cvs mailing list