[LON-CAPA-cvs] cvs: loncom /homework optionresponse.pm radiobuttonresponse.pm /xml lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 07 Apr 2003 22:28:08 -0000


albertel		Mon Apr  7 18:28:08 2003 EDT

  Modified files:              
    /loncom/homework	radiobuttonresponse.pm optionresponse.pm 
    /loncom/xml	lonxml.pm 
  Log:
  - better handling of counters
  - always increment the counters for modes with output
  
  - option/radiobutton responses now use new method for getting current response
    supporting scantron mode
  
  
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.66 loncom/homework/radiobuttonresponse.pm:1.67
--- loncom/homework/radiobuttonresponse.pm:1.66	Fri Apr  4 18:37:04 2003
+++ loncom/homework/radiobuttonresponse.pm	Mon Apr  7 18:28:08 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.66 2003/04/04 23:37:04 albertel Exp $
+# $Id: radiobuttonresponse.pm,v 1.67 2003/04/07 22:28:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -169,9 +169,7 @@
       }
     }
   }
-  if ($target eq 'tex' && $Apache::lonhomework::type eq 'exam') {
-      &Apache::lonxml::increment_counter();
-  }
+  &Apache::lonxml::increment_counter();
   return $result;
 }
 
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.73 loncom/homework/optionresponse.pm:1.74
--- loncom/homework/optionresponse.pm:1.73	Wed Apr  2 13:40:37 2003
+++ loncom/homework/optionresponse.pm	Mon Apr  7 18:28:08 2003
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.73 2003/04/02 18:40:37 sakharuk Exp $
+# $Id: optionresponse.pm,v 1.74 2003/04/07 22:28:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -185,7 +185,10 @@
 	my $wrong=0;
 	my $ignored=0;
 	foreach $name (@whichopt) {
-	  my $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1'].":$temp"};
+	  my $response=&Apache::response::getresponse($temp);
+	  if ($ENV{'form.submitted'} eq 'scantron') {
+	      $response = $opt[$response];
+	  }
 	  $responsehash{$name}=$response;
 	  if ( $response =~ /[^\s]/) {
 	    my $value=$Apache::response::foilgroup{$name.'.value'};
@@ -227,10 +230,13 @@
 	&Apache::response::handle_previous(\%previous,$ad);
       }
     }
+    &Apache::lonxml::increment_counter(&getfoilcounts($max));
   } elsif ($target eq 'edit') {
     $result.=&Apache::edit::end_table();
-  }  
-  if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {$result .= '\end{enumerate}';}
+  }
+  if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
+      $result .= '\end{enumerate}';
+  }
   return $result;
 }
 
@@ -505,7 +511,6 @@
 	}
 
     }
-    &Apache::lonxml::increment_counter();
     return $result;
 }
 
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.246 loncom/xml/lonxml.pm:1.247
--- loncom/xml/lonxml.pm:1.246	Thu Apr  3 17:34:26 2003
+++ loncom/xml/lonxml.pm	Mon Apr  7 18:28:08 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.246 2003/04/03 22:34:26 albertel Exp $
+# $Id: lonxml.pm,v 1.247 2003/04/07 22:28:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -898,18 +898,23 @@
 }
 
 sub increment_counter {
-    $Apache::lonxml::counter++;
+    my ($increment) = @_;
+    if (defined($increment) && $increment gt 0) {
+	$Apache::lonxml::counter+=$increment;
+    } else {
+	$Apache::lonxml::counter++;
+    }
     $Apache::lonxml::counter_changed=1;
 }
 
 sub init_counter {
     if (defined($ENV{'form.counter'})) {
 	$Apache::lonxml::counter=$ENV{'form.counter'};
+	$Apache::lonxml::counter_changed=0;
     } else {
 	$Apache::lonxml::counter=1;
-	&store_counter();
+	$Apache::lonxml::counter_changed=1;
     }
-    $Apache::lonxml::counter_changed=0;
 }
 
 sub store_counter {