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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 01 Mar 2007 02:31:29 -0000


albertel		Wed Feb 28 21:31:29 2007 EDT

  Modified files:              
    /loncom/homework	radiobuttonresponse.pm 
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - mroe bug#2622 add code for fixing uyp displays of numerical/formula/radio responses to make more sense to users
  
  
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.111 loncom/homework/radiobuttonresponse.pm:1.112
--- loncom/homework/radiobuttonresponse.pm:1.111	Wed Feb 21 20:25:31 2007
+++ loncom/homework/radiobuttonresponse.pm	Wed Feb 28 21:31:20 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.111 2007/02/22 01:25:31 albertel Exp $
+# $Id: radiobuttonresponse.pm,v 1.112 2007/03/01 02:31:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -180,6 +180,9 @@
 	if ( $style eq 'survey'  && $target ne 'analyze') {
 	    if ($target eq 'web' || $target eq 'tex') {
 		$result=&displayallfoils($direction, $target);
+		if ($target eq 'web') {
+		    &setup_prior_tries_hash();
+		}
 	    } elsif ( $target eq 'answer' ) {
 		$result=&displayallanswers();
 	    } elsif ( $target eq 'grade' ) {
@@ -193,6 +196,9 @@
 						       $safeeval,'-2');
 	    if ($target eq 'web' || $target eq 'tex') {
 		$result=&displayfoils($target,$max,$randomize,$direction);
+		if ($target eq 'web') {
+		    &setup_prior_tries_hash();
+		}
 	    } elsif ($target eq 'answer' ) {
 		$result=&displayanswers($max,$randomize);
 	    } elsif ( $target eq 'grade') {
@@ -231,6 +237,20 @@
     return ($truecnt,$falsecnt);
 }
 
+sub setup_prior_tries_hash {
+    my $part=$Apache::inputtags::part;
+    my $id=$Apache::inputtags::response[-1];	
+    foreach my $i (1..$Apache::lonhomework::history{'version'}) {
+	my $key = "$i:resource.$part.$id.submission";
+	next if (!exists($Apache::lonhomework::history{"$key"}));
+	my %response = 
+	    &Apache::lonnet::str2hash($Apache::lonhomework::history{$key});
+	my ($name) = keys(%response);
+	$Apache::inputtags::submission_display{$key} = 
+	    $Apache::response::foilgroup{$name.'.text'}
+    }
+}
+
 sub displayallfoils {
     my ($direction, $target)=@_;
     my $result;
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.208 loncom/homework/caparesponse/caparesponse.pm:1.209
--- loncom/homework/caparesponse/caparesponse.pm:1.208	Sat Feb 17 21:03:18 2007
+++ loncom/homework/caparesponse/caparesponse.pm	Wed Feb 28 21:31:29 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.208 2007/02/18 02:03:18 albertel Exp $
+# $Id: caparesponse.pm,v 1.209 2007/03/01 02:31:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -601,6 +601,7 @@
 		}
 	    }
 	}
+	&setup_prior_tries_hash();
     } elsif ($target eq 'edit') {
 	$result.='</td></tr>'.&Apache::edit::end_table;
     } elsif ($target eq 'answer' || $target eq 'analyze') {
@@ -791,6 +792,19 @@
     return $result;
 }
 
+sub setup_prior_tries_hash {
+    #FIXME support multi answer numericals/formula
+    my $part=$Apache::inputtags::part;
+    my $id=$Apache::inputtags::response[-1];	
+    foreach my $i (1..$Apache::lonhomework::history{'version'}) {
+	my $key = "$i:resource.$part.$id.submission";
+	next if (!exists($Apache::lonhomework::history{"$key"}));
+	$Apache::inputtags::submission_display{$key} =
+	    '<pre>'.&HTML::Entities::encode($Apache::lonhomework::history{$key},
+					  '"<>&').'</pre>';
+    }
+}
+
 sub check_for_answer_errors {
     my ($parstack,$safeeval) = @_;
     &add_in_tag_answer($parstack,$safeeval);