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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 01 Aug 2006 14:41:50 -0000


albertel		Tue Aug  1 10:41:50 2006 EDT

  Modified files:              
    /loncom/homework	response.pm 
  Log:
  - making custom response point scorable
  - adding an answer display to customresponse (BUG#4938)
  
  
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.145 loncom/homework/response.pm:1.146
--- loncom/homework/response.pm:1.145	Tue Jul 18 14:52:57 2006
+++ loncom/homework/response.pm	Tue Aug  1 10:41:46 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.145 2006/07/18 18:52:57 albertel Exp $
+# $Id: response.pm,v 1.146 2006/08/01 14:41:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -403,8 +403,11 @@
     my $id=$Apache::inputtags::response[-1];
     if ( $target eq 'grade' && &Apache::response::submitted() ) {
 	my $response = &Apache::response::getresponse();
-	if ( $response =~ /[^\s]/ && 
-	     $Apache::response::custom_answer_type eq 'loncapa/perl') {
+	if ($Apache::lonhomework::type eq 'exam' ||
+	    &Apache::response::submitted('scantron')) {
+	    &Apache::response::scored_response($part,$id);
+	} elsif ( $response =~ /[^\s]/ && 
+		  $Apache::response::custom_answer_type eq 'loncapa/perl') {
 	    if (!$Apache::lonxml::default_homework_loaded) {
 		&Apache::lonxml::default_homework_load($safeeval);
 	    }
@@ -429,6 +432,19 @@
 		    $error;
 	    }
 	}
+    } elsif ( $target eq 'answer') {
+	$result  = &Apache::response::answer_header('customresponse');
+	my $answer = &Apache::lonxml::get_param('answerdisplay',$parstack,
+						$safeeval);
+	if ($env{'form.answer_output_mode'} ne 'tex') {
+	    $answer = '<b>'.$answer.'</b>';
+	}
+	$result .= &Apache::response::answer_part('customresponse',$answer);
+	$result .= &Apache::response::answer_footer('customresponse');
+    }
+    if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || 
+	$target eq 'tex' || $target eq 'analyze') {
+	&Apache::lonxml::increment_counter(&Apache::response::repetition());
     }
     pop(@Apache::lonxml::namespace);
     &Apache::lonxml::deregister('Apache::response',('answer'));