[LON-CAPA-cvs] cvs: loncom /homework lonsimpleproblemedit.pm simpleproblem.problem

www www@source.lon-capa.org
Mon, 17 Aug 2009 19:46:50 -0000


www		Mon Aug 17 19:46:50 2009 EDT

  Modified files:              
    /loncom/homework	lonsimpleproblemedit.pm simpleproblem.problem 
  Log:
  Bug #2579: Simple numerical problem
  
  
Index: loncom/homework/lonsimpleproblemedit.pm
diff -u loncom/homework/lonsimpleproblemedit.pm:1.24 loncom/homework/lonsimpleproblemedit.pm:1.25
--- loncom/homework/lonsimpleproblemedit.pm:1.24	Mon Aug 17 18:18:35 2009
+++ loncom/homework/lonsimpleproblemedit.pm	Mon Aug 17 19:46:49 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Problem Parameter Setting "Editor"
 #
-# $Id: lonsimpleproblemedit.pm,v 1.24 2009/08/17 18:18:35 www Exp $
+# $Id: lonsimpleproblemedit.pm,v 1.25 2009/08/17 19:46:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -220,6 +220,10 @@
 	    ('resourcedata',\%storecontent,
 	     $env{'course.'.$env{'request.course.id'}.'.domain'},
 	     $env{'course.'.$env{'request.course.id'}.'.num'});
+        
+        &Apache::lonnet::devalidatecourseresdata(
+                            $env{'course.'.$env{'request.course.id'}.'.num'},
+                            $env{'course.'.$env{'request.course.id'}.'.domain'});
 
     }
 # ------------------------------------------------------------------- Read Data
@@ -342,7 +346,7 @@
             unless ($stringtypes{$stringtype}) { $stringtype='cs'; }
 	    $r->print(
 		  '<table bgcolor="#00ee44" cellspacing="4" cellpadding="2">'.
-	          '<tr><td>'.&mt('Correct answer').': <input type="text" size="20" name="stringanswer" value="'.$stringanswer.'" />&nbsp;&nbsp;'.
+	          '<tr><td><label>'.&mt('Correct answer').': <input type="text" size="20" name="stringanswer" value="'.$stringanswer.'" /></label>&nbsp;&nbsp;'.
 		      &Apache::loncommon::select_form
 		      ($stringtype,'stringtype',%stringtypes).
 		  '</td></tr></table><br />');
@@ -352,10 +356,18 @@
         if ($qtype eq 'numerical') {
            my $numericalanswer=$qparms{$prefix.'numericalanswer'};
            unless (defined($numericalanswer)) { $numericalanswer=''; }
+           my $numericaltolerance=$qparms{$prefix.'numericaltolerance'};
+           unless (defined($numericaltolerance)) { $numericaltolerance='5%'; }
+           my $numericalsigfigs=$qparms{$prefix.'numericalsigfigs'};
+           unless (defined($numericalsigfigs)) { $numericalsigfigs='1,15'; }
 
            $r->print(
                   '<table bgcolor="#00ee44" cellspacing="4" cellpadding="2">'.
-                  '<tr><td>'.&mt('Correct answer').': <input type="text" size="20" name="numericalanswer" value="'.$numericalanswer.'" />'.
+                  '<tr><td><label>'.&mt('Correct answer').': <input type="text" size="20" name="numericalanswer" value="'.$numericalanswer.'" /></label>&nbsp;&nbsp;'.
+                  '<label>'.&mt('Unit').':  <input type="text" size="5" name="numericalunit" value="'.$qparms{$prefix.'numericalunit'}.'" /></label>&nbsp;&nbsp;'.
+                  '<label>'.&mt('Format').':  <input type="text" size="5" name="numericalformat" value="'.$qparms{$prefix.'numericalformat'}.'" /></label>&nbsp;&nbsp;'.
+                  '<label>'.&mt('Tolerance').':  <input type="text" size="5" name="numericaltolerance" value="'.$numericaltolerance.'" /></label>&nbsp;&nbsp;'.
+                  '<label>'.&mt('Significant digits').':  <input type="text" size="5" name="numericalsigfigs" value="'.$numericalsigfigs.'" /></label>'.
                   '</td></tr></table><br />');
            $r->print(&hint());
         }
Index: loncom/homework/simpleproblem.problem
diff -u loncom/homework/simpleproblem.problem:1.10 loncom/homework/simpleproblem.problem:1.11
--- loncom/homework/simpleproblem.problem:1.10	Mon Aug 17 18:18:35 2009
+++ loncom/homework/simpleproblem.problem	Mon Aug 17 19:46:49 2009
@@ -24,8 +24,8 @@
 unless ($numericaltolerance) { $numericaltolerance='5%'; }
 $numericalsigfigs=&EXT('resource.0.numericalsigfigs');
 unless ($numericalsigfigs) { $numericalsigfigs='1,15'; }
-$numericalunits=&EXT('resource.0.numericalunits');
-unless ($numericalunits) { $numericalunits=''; }
+$numericalunit=&EXT('resource.0.numericalunit');
+unless ($numericalunit) { $numericalunit=''; }
 $numericalformat=&EXT('resource.0.numericalformat');
 unless ($numericalformat) { $numericalformat=''; }
 $numericalscript=&EXT('resource.0.numericalscript');
@@ -144,7 +144,8 @@
 
 <part id="numerical">
 <script type="loncapa/perl">
-$numericalscript
+$tag='script';
+&xmlparse("<$tag type='loncapa/perl'>$numericalscript</$tag>");
 </script>
 <startouttext /><parse>&EXT('resource.0.questiontext')</parse><br /><endouttext />
 <numericalresponse id="numericalsegment" answer="$numericalanswer" unit="$numericalunit" format="$numericalformat">