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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 18 Oct 2005 13:58:14 -0000


albertel		Tue Oct 18 09:58:14 2005 EDT

  Modified files:              
    /loncom/homework	externalresponse.pm 
  Log:
  - retabinate
  
  
Index: loncom/homework/externalresponse.pm
diff -u loncom/homework/externalresponse.pm:1.4 loncom/homework/externalresponse.pm:1.5
--- loncom/homework/externalresponse.pm:1.4	Thu Apr  7 02:56:21 2005
+++ loncom/homework/externalresponse.pm	Tue Oct 18 09:58:12 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # external style responses
 #
-# $Id: externalresponse.pm,v 1.4 2005/04/07 06:56:21 albertel Exp $
+# $Id: externalresponse.pm,v 1.5 2005/10/18 13:58:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,7 +33,7 @@
 use Apache::lonnet;
 
 BEGIN {
-  &Apache::lonxml::register('Apache::externalresponse',('externalresponse'));
+    &Apache::lonxml::register('Apache::externalresponse',('externalresponse'));
 }
 
 #FIXME
@@ -41,57 +41,57 @@
 # accept a string to be printed out (Where does it get shown?) (.message)
 # need to get a correct answer from somewhere (probably here since randomized)
 sub start_externalresponse {
-  my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-  my $result;
-  my $id = &Apache::response::start_response($parstack,$safeeval);
-  return $result;
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+    my $result;
+    my $id = &Apache::response::start_response($parstack,$safeeval);
+    return $result;
 }
 
 sub end_externalresponse {
-  my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-  my $result;
-  if ($target eq 'grade') {
-    if ( defined $env{'form.submitted'}) {
-      my $id = $Apache::inputtags::response['-1'];
-      my $response = $env{'form.HWVAL_'.$id};
-      if ( $response =~ /[^\s]/) {
-	my $url = &Apache::lonxml::get_param('url',$parstack,$safeeval);
-	my $answer = &Apache::lonxml::get_param('answer',$parstack,$safeeval);
-	my %form = &Apache::lonxml::get_param_var('form',$parstack,$safeeval);
-	$form{'LONCAPA_student_response'}=$response;
-	$form{'LONCAPA_correct_answer'}=$answer;
-	$form{'LONCAPA_language'}=
-	  &Apache::lonnet::metadata($ENV{'REQUEST_URI'},'language');
-	&Apache::lonxml::debug("Asking $url, with:");
-	&Apache::lonhomework::showhash(%form);
-	my $ua = LWP::UserAgent->new;
-	my $res = $ua->request(POST $url, \%form);
-	my $partid = $Apache::inputtags::part;
-	my $id = $Apache::inputtags::response['-1'];
-	my %previous = &Apache::response::check_for_previous($response,
-							     $partid,$id);
-	%Apache::loncapagrade::results=();
-        if ($res->{_rc} != '200') {
-	  $Apache::loncapagrade::results{'awardetail'}='ERROR';
-	} else {
-	  &Apache::lonxml::register('Apache::loncapagrade',('loncapagrade'));
-	  my $result=&Apache::scripttag::xmlparse($res->{_content});
-	  &Apache::lonxml::debug("Got a result of :$result:");
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+    my $result;
+    if ($target eq 'grade') {
+	if ( defined $env{'form.submitted'}) {
+	    my $id = $Apache::inputtags::response['-1'];
+	    my $response = $env{'form.HWVAL_'.$id};
+	    if ( $response =~ /[^\s]/) {
+		my $url = &Apache::lonxml::get_param('url',$parstack,$safeeval);
+		my $answer = &Apache::lonxml::get_param('answer',$parstack,$safeeval);
+		my %form = &Apache::lonxml::get_param_var('form',$parstack,$safeeval);
+		$form{'LONCAPA_student_response'}=$response;
+		$form{'LONCAPA_correct_answer'}=$answer;
+		$form{'LONCAPA_language'}=
+		    &Apache::lonnet::metadata($ENV{'REQUEST_URI'},'language');
+		&Apache::lonxml::debug("Asking $url, with:");
+		&Apache::lonhomework::showhash(%form);
+		my $ua = LWP::UserAgent->new;
+		my $res = $ua->request(POST $url, \%form);
+		my $partid = $Apache::inputtags::part;
+		my $id = $Apache::inputtags::response['-1'];
+		my %previous = &Apache::response::check_for_previous($response,
+								     $partid,$id);
+		%Apache::loncapagrade::results=();
+		if ($res->{_rc} != '200') {
+		    $Apache::loncapagrade::results{'awardetail'}='ERROR';
+		} else {
+		    &Apache::lonxml::register('Apache::loncapagrade',('loncapagrade'));
+		    my $result=&Apache::scripttag::xmlparse($res->{_content});
+		    &Apache::lonxml::debug("Got a result of :$result:");
+		}
+		foreach my $key (%Apache::loncapagrade::results) {
+		    $Apache::lonhomework::results{"resource.$partid.$id.$key"}=
+			$Apache::loncapagrade::results{$key};
+		}
+		&Apache::response::handle_previous(\%previous,
+						   $Apache::loncapagrade::results{'awarddetail'});
+		&Apache::lonxml::debug("response of");
+		&Apache::lonhomework::showhash(%$res);
+		&Apache::lonhomework::showhash(%Apache::loncapagrade::results);
+	    }
 	}
-	foreach my $key (%Apache::loncapagrade::results) {
-	  $Apache::lonhomework::results{"resource.$partid.$id.$key"}=
-	    $Apache::loncapagrade::results{$key};
-	}
-	&Apache::response::handle_previous(\%previous,
-		    $Apache::loncapagrade::results{'awarddetail'});
-	&Apache::lonxml::debug("response of");
-	&Apache::lonhomework::showhash(%$res);
-	&Apache::lonhomework::showhash(%Apache::loncapagrade::results);
-      }
     }
-  }
-  &Apache::response::end_response;
-  return $result;
+    &Apache::response::end_response;
+    return $result;
 }
 
 1;