[LON-CAPA-cvs] cvs: loncom /homework essayresponse.pm response.pm /homework/caparesponse caparesponse.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 18 Apr 2003 07:12:13 -0000


albertel		Fri Apr 18 03:12:13 2003 EDT

  Modified files:              
    /loncom/homework	essayresponse.pm response.pm 
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - break out the 'repetition' clculation
  - essayresponse, start support of scantron
  
  
Index: loncom/homework/essayresponse.pm
diff -u loncom/homework/essayresponse.pm:1.26 loncom/homework/essayresponse.pm:1.27
--- loncom/homework/essayresponse.pm:1.26	Mon Apr  7 22:40:56 2003
+++ loncom/homework/essayresponse.pm	Fri Apr 18 03:12:13 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.26 2003/04/08 02:40:56 albertel Exp $
+# $Id: essayresponse.pm,v 1.27 2003/04/18 07:12:13 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -89,6 +89,7 @@
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $part          = $Apache::inputtags::part;
     my $id            = $Apache::inputtags::response[-1];
+    my $increment     = 1;
     my $result;
     if ( $target eq 'grade' ) {
 	my $collaborators = $ENV{'form.HWCOL'.$part.'_'.$id};	
@@ -97,7 +98,11 @@
 	    $Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators
 		if ($collaborators ne $previous_list);
 	}
-	if ( defined $ENV{'form.submitted'}) {
+	if ( defined($ENV{'form.submitted'}) &&
+	     $ENV{'form.submitted'}='scantron' ) {
+	    my $repetition=&Apache::response::repetition();
+	    $increment=$repetition;
+	} elsif ( defined($ENV{'form.submitted'}) ) {
 	    my $response      = $ENV{'form.HWVAL_'.$id};
             my $filename= $ENV{'form.HWFILE'.$part.'_'.$id.'.filename'};
 	    if (( $response =~ /[^\s]/) || ($filename =~ /[^\s]/)) {
@@ -132,19 +137,19 @@
 	$result.=&Apache::edit::end_table();
     } elsif ($target eq 'tex') {
 	if ($Apache::lonhomework::type eq 'exam') {
-	    my $id = $Apache::inputtags::part;
-	    my $weight = &Apache::lonnet::EXT("resource.$id.weight");
-            my $repetition = int $weight/9;
-	    if ($weight % 9 != 0) {$repetition++;} 
+	    my $repetition=&Apache::response::repetition();
 	    $result.='\begin{enumerate}';
 	    for (my $i=0;$i<$repetition;$i++) {
-		$result.='\item[\textbf{'.$Apache::lonxml::counter.'}.]\textit{Leave blank on scoring form}\vskip 0 mm';
-		&Apache::lonxml::increment_counter();
+		$result.='\item[\textbf{'.($Apache::lonxml::counter+$i).
+		    '}.]\textit{Leave blank on scoring form}\vskip 0 mm';
 	    }
 	    $result.= '\end{enumerate}';
 	}
     }
-
+    if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
+	$target eq 'tex' || $target eq 'analyze') {
+	&Apache::lonxml::increment_counter($increment);
+    }
     &Apache::response::end_response;
     return $result;
 }
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.70 loncom/homework/response.pm:1.71
--- loncom/homework/response.pm:1.70	Mon Apr  7 22:42:55 2003
+++ loncom/homework/response.pm	Fri Apr 18 03:12:13 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.70 2003/04/08 02:42:55 albertel Exp $
+# $Id: response.pm,v 1.71 2003/04/18 07:12:13 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -417,14 +417,28 @@
 		    'P'=>15,'Q'=>16,'R'=>17,'S'=>18,'T'=>19,'U'=>20,'V'=>21,
 		    'W'=>22,'X'=>23,'Y'=>24,'Z'=>25);
     if ($ENV{'form.submitted'} eq 'scantron') {
+	my $part  = $Apache::inputtags::part;
+	my $id    = $Apache::inputtags::response[-1];
 	$response = $ENV{'scantron.'.($Apache::lonxml::counter+$temp-1).
 			 '.answer'};
+	# save bubbled letter for later
+	$Apache::lonhomework::results{"resource.$part.$id.scantron"}.=
+	    $response;
 	$response = $let_to_num{$response};
     } else {
 	$response = $ENV{$formparm};
     }
     return $response;
 }
+
+sub repetition {
+    my $id = $Apache::inputtags::part;
+    my $weight = &Apache::lonnet::EXT("resource.$id.weight");
+    my $repetition = int $weight/9;
+    if ($weight % 9 != 0) {$repetition++;} 
+    return $repetition;
+}
+
 1;
 __END__
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.92 loncom/homework/caparesponse/caparesponse.pm:1.93
--- loncom/homework/caparesponse/caparesponse.pm:1.92	Tue Apr  8 00:17:13 2003
+++ loncom/homework/caparesponse/caparesponse.pm	Fri Apr 18 03:12:13 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.92 2003/04/08 04:17:13 albertel Exp $
+# $Id: caparesponse.pm,v 1.93 2003/04/18 07:12:13 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -242,13 +242,10 @@
 		    $result.='\end{enumerate}';
 		} else {
 		    $result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
-		    my $id = $Apache::inputtags::part;
-		    my $weight = &Apache::lonnet::EXT("resource.$id.weight");
-		    my $repetition = int $weight/9;
-		    if ($weight % 9 != 0) {$repetition++;}
+		    my $repetition = &Apache::response::repetition();
 		    $result.='\begin{enumerate}';
 		    for (my $i=0;$i<$repetition;$i++) {
-			$result.='\item[\textbf{'.$Apache::lonxml::counter.'}.]\textit{Leave blank on scoring form}\vskip 0 mm';
+			$result.='\item[\textbf{'.($Apache::lonxml::counter+$i).'}.]\textit{Leave blank on scoring form}\vskip 0 mm';
 		    }
 		    $increment=$repetition;
 		    $result.= '\end{enumerate}';