[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 06 Oct 2003 21:39:51 -0000
albertel Mon Oct 6 17:39:51 2003 EDT
Modified files:
/loncom/homework chemresponse.pm
Log:
- allow an array arg to <organicresponse> and <reactionresponse>
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.12 loncom/homework/chemresponse.pm:1.13
--- loncom/homework/chemresponse.pm:1.12 Mon Sep 8 18:08:37 2003
+++ loncom/homework/chemresponse.pm Mon Oct 6 17:39:51 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.12 2003/09/08 22:08:37 albertel Exp $
+# $Id: chemresponse.pm,v 1.13 2003/10/06 21:39:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -175,15 +175,18 @@
if ( $response =~ /[^\s]/) {
my $partid = $Apache::inputtags::part;
my $id = $Apache::inputtags::response['-1'];
- my $answer=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
+ 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;
- &Apache::lonxml::debug("submitted a $response for $answer<br \>\n");
my $ad;
- if ($response eq $answer) {
- $ad='EXACT_ANS';
- } else {
- $ad='INCORRECT';
+ foreach my $answer (@answers) {
+ &Apache::lonxml::debug("submitted a $response for $answer<br \>\n");
+ if ($response eq $answer) {
+ $ad='EXACT_ANS';
+ last;
+ } else {
+ $ad='INCORRECT';
+ }
}
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
@@ -307,15 +310,17 @@
if ( $response =~ /[^\s]/) {
my $partid = $Apache::inputtags::part;
my $id = $Apache::inputtags::response['-1'];
- my $answer=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
+ my (@answers)=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
my %previous = &Apache::response::check_for_previous($response,$partid,$id);
$Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
- &Apache::lonxml::debug("submitted a $response for $answer<br \>\n");
my $ad;
- if ($response eq $answer) {
- $ad='EXACT_ANS';
- } else {
- $ad='INCORRECT';
+ foreach my $answer (@answers) {
+ &Apache::lonxml::debug("submitted a $response for $answer<br \>\n");
+ if ($response eq $answer) {
+ $ad='EXACT_ANS';
+ } else {
+ $ad='INCORRECT';
+ }
}
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;