[LON-CAPA-cvs] cvs: loncom /imspackages imsexport.pm

raeburn raeburn at source.lon-capa.org
Mon Nov 11 23:54:58 EST 2013


raeburn		Tue Nov 12 04:54:58 2013 EDT

  Modified files:              
    /loncom/imspackages	imsexport.pm 
  Log:
  - Conversion of simpleproblems to regular LON-CAPA .problem files.
    - Correct detection of string question type
    - Include initial text block in all question types
    - Add support for numerical question type.
  
  
Index: loncom/imspackages/imsexport.pm
diff -u loncom/imspackages/imsexport.pm:1.10 loncom/imspackages/imsexport.pm:1.11
--- loncom/imspackages/imsexport.pm:1.10	Mon May  7 02:12:54 2012
+++ loncom/imspackages/imsexport.pm	Tue Nov 12 04:54:57 2013
@@ -1,6 +1,6 @@
 # The LearningOnline Network
 #
-# $Id: imsexport.pm,v 1.10 2012/05/07 02:12:54 raeburn Exp $
+# $Id: imsexport.pm,v 1.11 2013/11/12 04:54:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -673,6 +673,7 @@
                 %values = &evaloptionhash($options);
                 $output .= qq|
 <problem>
+  <startouttext />$qtext<endouttext />
   <optionresponse max="$maxfoils" randomize="$randomize">
     <foilgroup options="$options">
 |;
@@ -701,8 +702,9 @@
             } else {
                 $output .= qq|
 <problem>
+  <startouttext />$qtext<endouttext />
   <radiobuttonresponse max="$maxfoils" randomize="$randomize">
-   <foilgroup>
+  <foilgroup>
 |;
                 for (my $k=0; $k<10; $k++) {
                     my $iter = $k+1;
@@ -727,14 +729,14 @@
 </problem>
 |;
             }
-        } elsif ($qtype eq 'stringanswer') {
+        } elsif ($qtype eq 'string') {
             my $stringanswer = $qparms{$prefix.'stringanswer'};
             my $stringtype=$qparms{$prefix.'stringtype'};
             $output .= qq|
 <problem>
   <stringresponse answer="$stringanswer" type="$stringtype">
-    <textline>
-    </textline>
+  <startouttext />$qtext<endouttext />
+    <textline />
             |;
             if ($hint) {
                 $output .= '
@@ -748,6 +750,55 @@
   </stringresponse>
 </problem>
 |;
+        } elsif ($qtype eq 'numerical') {
+            my $sigfigs = $qparms{$prefix.'numericalsigfigs'};
+            my $unit = $qparms{$prefix.'numericalunit'};
+            my $answer = $qparms{$prefix.'numericalanswer'};
+            my $tolerance = $qparms{$prefix.'numericaltolerance'};
+            my $format = $qparms{$prefix.'numericalformat'};
+            my $scriptblock = $qparms{$prefix.'numericalscript'};
+            $output .= qq|
+<problem>
+|;
+            if ($scriptblock) {
+                $output .= qq|
+<script type="loncapa/perl">
+$scriptblock
+</script>|;
+             }
+             $output .= qq|
+<startouttext />$qtext<endouttext />
+<numericalresponse answer="$answer" |;
+             if ($unit ne '') {
+                 $output .= qq|unit="$unit" |;
+             }
+             if ($format ne '') {
+                 $output .= qq|format="$format" |;
+             }
+             $output =~ s{ $}{};
+             $output .= '>';
+             if ($tolerance ne '') {
+                 $output .= qq|
+  <responseparam name="tol" type="tolerance" default="$tolerance" description="Numerical Tolerance" />|;
+             }
+             if ($sigfigs) {
+                 $output .= qq|
+  <responseparam name="sig" type="int_range" default="$sigfigs" description="Significant Digits" />|;
+             }
+             $output .= qq|
+  <textline />|;
+            if ($hint) {
+                $output .= qq|
+  <hintgroup>
+    <hintpart on="default">
+      <startouttext />'.$hint.'<endouttext/>
+    </hintpart>
+  </hintgroup>|;
+            }
+            $output .= qq|
+</numericalresponse>
+</problem>
+|;
         } else {
             $output .= qq|
 <problem>




More information about the LON-CAPA-cvs mailing list