[LON-CAPA-cvs] cvs: loncom /homework matchresponse.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Wed, 19 Mar 2003 19:20:44 -0000


sakharuk		Wed Mar 19 14:20:44 2003 EDT

  Modified files:              
    /loncom/homework	matchresponse.pm 
  Log:
   Corrections done in calculation of possible choices (letters with mark them).
  
  
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.8 loncom/homework/matchresponse.pm:1.9
--- loncom/homework/matchresponse.pm:1.8	Wed Mar 19 14:10:16 2003
+++ loncom/homework/matchresponse.pm	Wed Mar 19 14:20:44 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Full matching style response
 #
-# $Id: matchresponse.pm,v 1.8 2003/03/19 19:10:16 sakharuk Exp $
+# $Id: matchresponse.pm,v 1.9 2003/03/19 19:20:44 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -128,7 +128,7 @@
     foreach my $name (@names) {
 	$letter_name_map{$alphabet[$i]}=$name;
 	$name_letter_map{$name}=$alphabet[$i];
-	push @Items, $alphabet[$i];
+	$Items[$i] = $alphabet[$i];
 	$i++;
     }
      $Apache::response::itemgroup{'letter_name_map'}=\%letter_name_map;
@@ -383,7 +383,9 @@
 	my $id=$Apache::inputtags::response[-1];
 	my $part=$Apache::inputtags::part;
 	my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"};
-	my %lastresponse=&Apache::lonnet::str2hash($lastresponse);
+	my %lastresponse=&Apache::lonnet::str2hash($lastresponse);    
+	my @alphabet=('A'..'Z');
+        my @Items_letter = splice @alphabet, 0, $#Items + 1;
 	foreach my $name (@whichfoils) {
 	    my $lastopt=$lastresponse{$name};
 	    my $last_letter=$name_letter_map{$lastopt};
@@ -416,12 +418,12 @@
 	    if ($target ne 'tex') {
 		$question.='<br />'.$optionlist.$text."\n";
 		if ($Apache::lonhomework::type eq 'exam') {
-		    $question.=&Apache::optionresponse::webbubbles(\@Items,\@Items);
+		    $question.=&Apache::optionresponse::webbubbles(\@Items_letter,\@Items);
 		}
 	    } else {		
 		if ($Apache::lonhomework::type eq 'exam') {
 		    $question.=' '.$optionlist.$text."\n";
-		    $question.=&Apache::optionresponse::bubbles(\@Items,\@Items).'\end{enumerate} \vskip -7 mm \strut ';
+		    $question.=&Apache::optionresponse::bubbles(\@Items_letter,\@Items).'\end{enumerate} \vskip -7 mm \strut ';
 		    &Apache::lonxml::increment_counter();
 	        } else {
 		    $question.=' \\\\ '.$optionlist.$text."\n";