[LON-CAPA-cvs] cvs: loncom /homework response.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 08 Apr 2003 02:42:55 -0000
albertel Mon Apr 7 22:42:55 2003 EDT
Modified files:
/loncom/homework response.pm
Log:
- consitancy for input fields
-also adding getresponse, as a better way for getting the current response
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.69 loncom/homework/response.pm:1.70
--- loncom/homework/response.pm:1.69 Thu Feb 13 18:48:27 2003
+++ loncom/homework/response.pm Mon Apr 7 22:42:55 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# various response type definitons response definition
#
-# $Id: response.pm,v 1.69 2003/02/13 23:48:27 albertel Exp $
+# $Id: response.pm,v 1.70 2003/04/08 02:42:55 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -253,7 +253,7 @@
&Apache::response::setup_params('dataresponse');
my $partid = $Apache::inputtags::part;
my $id = $Apache::inputtags::response['-1'];
- my $response = $ENV{'form.HWVAL'.$id};
+ my $response = $ENV{'form.HWVAL_'.$id};
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
if ( $response =~ /[^\s]/) {
$Apache::lonhomework::results{"resource.$partid.$id.$name"}=
@@ -401,6 +401,29 @@
$return=1;
}
return $return;
+}
+
+sub getresponse {
+ my ($temp)=@_;
+ my $formparm='form.HWVAL_'.$Apache::inputtags::response['-1'];
+ my $response;
+ if (!defined($temp)) {
+ $temp=1;
+ } else {
+ $formparm.=":$temp";
+ }
+ my %let_to_num=('A'=>0,'B'=>1,'C'=>2,'D'=>3,'E'=>4,'F'=>5,'G'=>6,'H'=>7,
+ 'I'=>8,'J'=>9,'K'=>10,'L'=>11,'M'=>12,'N'=>13,'O'=>14,
+ 'P'=>15,'Q'=>16,'R'=>17,'S'=>18,'T'=>19,'U'=>20,'V'=>21,
+ 'W'=>22,'X'=>23,'Y'=>24,'Z'=>25);
+ if ($ENV{'form.submitted'} eq 'scantron') {
+ $response = $ENV{'scantron.'.($Apache::lonxml::counter+$temp-1).
+ '.answer'};
+ $response = $let_to_num{$response};
+ } else {
+ $response = $ENV{$formparm};
+ }
+ return $response;
}
1;
__END__