[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm essayresponse.pm inputtags.pm matchresponse.pm optionresponse.pm radiobuttonresponse.pm rankresponse.pm response.pm /homework/caparesponse caparesponse.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 31 Jan 2005 22:00:40 -0000


This is a MIME encoded message

--albertel1107208840
Content-Type: text/plain

albertel		Mon Jan 31 17:00:40 2005 EDT

  Modified files:              
    /loncom/homework	chemresponse.pm essayresponse.pm inputtags.pm 
                    	matchresponse.pm optionresponse.pm 
                    	radiobuttonresponse.pm rankresponse.pm response.pm 
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - Part of #636, Submit Answer now only submits for a single part. The logic for detecting a submission has been broken out to a subroutine if future tweaks are needed.
  
  
--albertel1107208840
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20050131170040.txt"

Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.44 loncom/homework/chemresponse.pm:1.45
--- loncom/homework/chemresponse.pm:1.44	Fri Jan 21 17:10:59 2005
+++ loncom/homework/chemresponse.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.44 2005/01/21 22:10:59 albertel Exp $
+# $Id: chemresponse.pm,v 1.45 2005/01/31 22:00:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -211,7 +211,7 @@
 sub end_organicresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
-    if ($target eq 'grade' && defined($ENV{'form.submitted'})) {
+    if ($target eq 'grade' && &Apache::response::submitted()) {
 	&Apache::response::setup_params($$tagstack[-1],$safeeval);
 	my $response = &Apache::response::getresponse();
 	if ( $response =~ /[^\s]/) {
@@ -390,7 +390,7 @@
 sub end_reactionresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
-    if ($target eq 'grade' && defined($ENV{'form.submitted'})) {
+    if ($target eq 'grade' && &Apache::response::submitted()) {
 	&Apache::response::setup_params($$tagstack[-1],$safeeval);
 	my $response = &Apache::response::getresponse();
 	if ( $response =~ /[^\s]/) {
Index: loncom/homework/essayresponse.pm
diff -u loncom/homework/essayresponse.pm:1.57 loncom/homework/essayresponse.pm:1.58
--- loncom/homework/essayresponse.pm:1.57	Tue Dec 21 17:46:27 2004
+++ loncom/homework/essayresponse.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.57 2004/12/21 22:46:27 banghart Exp $
+# $Id: essayresponse.pm,v 1.58 2005/01/31 22:00:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -108,10 +108,9 @@
 	    $Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators
 		if ($collaborators ne $previous_list);
 	}
-	if ( defined($ENV{'form.submitted'}) &&
-	     $ENV{'form.submitted'} eq 'scantron' ) {
+	if (  &Apache::response::submitted('scantron') ) {
 	    $increment=&Apache::response::scored_response($part,$id);
-	} elsif ( defined($ENV{'form.submitted'}) ) {
+	} elsif ( &Apache::response::submitted() ) {
 	    my $response      = $ENV{'form.HWVAL_'.$id};
             my $filename= $ENV{'form.HWFILE'.$part.'_'.$id.'.filename'};
             my $portfiles = $ENV{'form.HWPORT'.$part.'_'.$id};
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.155 loncom/homework/inputtags.pm:1.156
--- loncom/homework/inputtags.pm:1.155	Thu Jan 20 15:46:03 2005
+++ loncom/homework/inputtags.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.155 2005/01/20 20:46:03 albertel Exp $
+# $Id: inputtags.pm,v 1.156 2005/01/31 22:00:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -760,7 +760,7 @@
 	if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {$showbutton = 0;}
 	if ( $showbutton ) { 
 	    if ($target ne 'tex') {
-		$button = '<input type="submit" name="submit" value="'.&mt('Submit Answer').'" />';
+		$button = '<input type="submit" name="submit_'.$id.'" value="'.&mt('Submit Answer').'" />';
 	    }
 	}
 	if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) {
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.49 loncom/homework/matchresponse.pm:1.50
--- loncom/homework/matchresponse.pm:1.49	Mon Jan 10 14:21:57 2005
+++ loncom/homework/matchresponse.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Full matching style response
 #
-# $Id: matchresponse.pm,v 1.49 2005/01/10 19:21:57 albertel Exp $
+# $Id: matchresponse.pm,v 1.50 2005/01/31 22:00:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -309,7 +309,7 @@
 						   $randomize,
 				            &Apache::response::showallfoils(),
 				           \%Apache::response::foilgroup);
-    if (!defined($ENV{'form.submitted'})) { return; }
+    if (!&Apache::response::submitted()) { return; }
     my %responsehash;
     my %grade;
     my ($temp,$right,$wrong,$ignored)=(1,0,0,0);
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.123 loncom/homework/optionresponse.pm:1.124
--- loncom/homework/optionresponse.pm:1.123	Mon Jan 10 14:21:57 2005
+++ loncom/homework/optionresponse.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.123 2005/01/10 19:21:57 albertel Exp $
+# $Id: optionresponse.pm,v 1.124 2005/01/31 22:00:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -182,7 +182,7 @@
 	my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
 	push (@{ $Apache::lonhomework::analyze{"$part_id.options"} },@opt);
     } elsif ( $target eq 'grade') {
-      if ( defined $ENV{'form.submitted'}) {
+      if ( &Apache::response::submitted()) {
 	my @whichopt = &whichfoils($max,$randomize);
 	my $temp=1;my $name;
 	my %responsehash;
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.98 loncom/homework/radiobuttonresponse.pm:1.99
--- loncom/homework/radiobuttonresponse.pm:1.98	Mon Jan 10 14:21:57 2005
+++ loncom/homework/radiobuttonresponse.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.98 2005/01/10 19:21:57 albertel Exp $
+# $Id: radiobuttonresponse.pm,v 1.99 2005/01/31 22:00:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -114,7 +114,7 @@
 }
 
 sub storesurvey {
-    if ( !defined($ENV{'form.submitted'})) { return ''; }
+    if ( !&Apache::response::submitted() ) { return ''; }
     my $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1']};
     &Apache::lonxml::debug("Here I am!:$response:");
     if ( $response !~ /[0-9]+/) { return ''; }
@@ -137,7 +137,7 @@
     my ($max,$randomize)=@_;
     #keep the random numbers the same must always call this
     my ($answer,@whichfoils)=&whichfoils($max,$randomize);
-    if (!defined($ENV{'form.submitted'})) { return; }
+    if ( !&Apache::response::submitted() ) { return; }
     my $response;
     if ($ENV{'form.submitted'} eq 'scantron') {
 	$response=&Apache::response::getresponse();
Index: loncom/homework/rankresponse.pm
diff -u loncom/homework/rankresponse.pm:1.43 loncom/homework/rankresponse.pm:1.44
--- loncom/homework/rankresponse.pm:1.43	Mon Jan 10 14:21:57 2005
+++ loncom/homework/rankresponse.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # rank style response
 #
-# $Id: rankresponse.pm,v 1.43 2005/01/10 19:21:57 albertel Exp $
+# $Id: rankresponse.pm,v 1.44 2005/01/31 22:00:40 albertel Exp $
 # Copyright Michigan State University Board of Trustees
 #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -195,7 +195,7 @@
 sub grade_response {
     my ($max,$randomize,$tol)=@_;
     my (@whichfoils)=&whichfoils($max,$randomize);
-    if (!defined($ENV{'form.submitted'})) { return; }
+    if (!&Apache::response::submitted()) { return; }
     my %responsehash;
     my %grade;
     my ($temp,$right,$wrong,$ignored)=(1,0,0,0);
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.112 loncom/homework/response.pm:1.113
--- loncom/homework/response.pm:1.112	Thu Dec 23 17:53:41 2004
+++ loncom/homework/response.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.112 2004/12/23 22:53:41 albertel Exp $
+# $Id: response.pm,v 1.113 2005/01/31 22:00:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -715,6 +715,19 @@
     return $parameter;
 }
 
+sub submitted {
+    my ($who)=@_;
+    
+    # when scatron grading any submission is a submission
+    if ($ENV{'form.submitted'} eq 'scantron') { return 1; }
+    # if the caller only cared if this was a scantron submission
+    if ($who eq 'scantron') { return 0; }
+    # if the Submit Answer button for this particular part was pressed
+    my $partid=$Apache::inputtags::part;
+    if (defined($ENV{'form.submit_'.$partid})) { return 1; }
+    # otherwise no submission occured
+    return 0;
+}
 1;
 __END__
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.161 loncom/homework/caparesponse/caparesponse.pm:1.162
--- loncom/homework/caparesponse/caparesponse.pm:1.161	Wed Jan 26 17:43:43 2005
+++ loncom/homework/caparesponse/caparesponse.pm	Mon Jan 31 17:00:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.161 2005/01/26 22:43:43 albertel Exp $
+# $Id: caparesponse.pm,v 1.162 2005/01/31 22:00:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -128,7 +128,7 @@
     }
     my $tag;
     if (scalar(@$tagstack)) { $tag=$$tagstack[-1]; }
-    if ( $target eq 'grade' && defined($ENV{'form.submitted'})) {
+    if ( $target eq 'grade' && &Apache::response::submitted() ) {
 	&Apache::response::setup_params($tag,$safeeval);
 	$safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
 	my $partid = $Apache::inputtags::part;
@@ -137,7 +137,6 @@
 	    $tag eq 'formularesponse') {
 	    $increment=&Apache::response::scored_response($partid,$id);
 	} elsif ($Apache::lonhomework::type eq 'survey') {
-	    if ( !defined($ENV{'form.submitted'})) { return ''; }
 	    my $response = &Apache::response::getresponse();
 	    if ( $response =~ /[^\s]/) {
 		my %previous=&Apache::response::check_for_previous($response,
@@ -154,7 +153,7 @@
 		&Apache::lonxml::debug("submitted a $response<br>\n");
 		&Apache::lonxml::debug($$parstack[-1] . "\n<br>");
 		
-		if ($ENV{'form.submitted'} eq 'scantron') {
+		if ( &Apache::response::submitted('scantron')) {
 		    my $number_of_bubbles = &Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.numbubbles');
 		    if (!$number_of_bubbles) { $number_of_bubbles=8; }
 		    my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,$safeeval);
@@ -185,7 +184,7 @@
 		}
 		#sig fig don't make much sense either
 		if (($Apache::lonhomework::type eq 'exam' ||
-		     $ENV{'form.submitted'} eq 'scantron') &&
+		     &Apache::response::submitted('scantron')) &&
 		    $tag eq 'numericalresponse') {
 		    delete($$args_ref{'sig'});
 		}
@@ -612,14 +611,13 @@
     if (!$Apache::lonxml::default_homework_loaded) {
 	&Apache::lonxml::default_homework_load($safeeval);
     }
-    if ( $target eq 'grade' && defined($ENV{'form.submitted'})) {
+    if ( $target eq 'grade' && &Apache::response::submitted() ) {
 	&Apache::response::setup_params('stringresponse',$safeeval);
 	$safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
 	if ($Apache::lonhomework::type eq 'exam' ||
-	    $ENV{'form.submitted'} eq 'scantron') {
+	    &Apache::response::submitted('scantron')) {
 	    $increment=&Apache::response::scored_response($part,$id);
 	} elsif ($Apache::lonhomework::type eq 'survey') {
-	    if ( !defined($ENV{'form.submitted'})) { return ''; }
 	    my $response = &Apache::response::getresponse();
 	    if ( $response =~ /[^\s]/) {
 		my %previous=&Apache::response::check_for_previous($response,

--albertel1107208840--