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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 09 Mar 2006 01:12:10 -0000


albertel		Wed Mar  8 20:12:10 2006 EDT

  Modified files:              
    /loncom/homework	chemresponse.pm 
  Log:
  - reactionrespionse and organicresponse should be scroed reponse gradable now
  
  
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.63 loncom/homework/chemresponse.pm:1.64
--- loncom/homework/chemresponse.pm:1.63	Wed Mar  8 19:48:47 2006
+++ loncom/homework/chemresponse.pm	Wed Mar  8 20:12:05 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.63 2006/03/09 00:48:47 albertel Exp $
+# $Id: chemresponse.pm,v 1.64 2006/03/09 01:12:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -258,12 +258,23 @@
 sub end_organicresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
-    if ($target eq 'grade' && &Apache::response::submitted()) {
+
+    my $partid = $Apache::inputtags::part;
+    my $id = $Apache::inputtags::response['-1'];
+
+    if ($target eq 'grade' 
+	&& &Apache::response::submitted()
+	&& $Apache::lonhomework::type eq 'exam') {
+
+	&Apache::response::scored_response($partid,$id);
+
+    } elsif ($target eq 'grade' 
+	&& &Apache::response::submitted()
+	&& $Apache::lonhomework::type ne 'exam') {
+
 	&Apache::response::setup_params($$tagstack[-1],$safeeval);
 	my $response = &Apache::response::getresponse();
 	if ( $response =~ /[^\s]/) {
-	    my $partid = $Apache::inputtags::part;
-	    my $id = $Apache::inputtags::response['-1'];
 	    my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
 	    my %previous = &Apache::response::check_for_previous($response,$partid,$id);
 	    $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
@@ -451,12 +462,23 @@
 sub end_reactionresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
-    if ($target eq 'grade' && &Apache::response::submitted()) {
+
+    my $partid = $Apache::inputtags::part;
+    my $id = $Apache::inputtags::response['-1'];
+
+    if ($target eq 'grade' 
+	&& &Apache::response::submitted()
+	&& $Apache::lonhomework::type eq 'exam') {
+
+	&Apache::response::scored_response($partid,$id);
+
+    } elsif ($target eq 'grade' 
+	&& &Apache::response::submitted()
+	&& $Apache::lonhomework::type ne 'exam') {
+
 	&Apache::response::setup_params($$tagstack[-1],$safeeval);
 	my $response = &Apache::response::getresponse();
 	if ( $response =~ /[^\s]/) {
-	    my $partid = $Apache::inputtags::part;
-	    my $id = $Apache::inputtags::response['-1'];
 	    my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
 	    my %previous = &Apache::response::check_for_previous($response,$partid,$id);
 	    $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;