--- loncom/homework/radiobuttonresponse.pm 2001/12/13 23:36:39 1.32 +++ loncom/homework/radiobuttonresponse.pm 2002/01/07 18:03:57 1.34 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # mutliple choice style responses # -# $Id: radiobuttonresponse.pm,v 1.32 2001/12/13 23:36:39 albertel Exp $ +# $Id: radiobuttonresponse.pm,v 1.34 2002/01/07 18:03:57 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -65,6 +65,7 @@ sub end_radiobuttonresponse { if ($target eq 'edit') { $result=&Apache::edit::end_table(); } &Apache::response::end_response; pop @Apache::lonxml::namespace; + &Apache::lonxml::deregister('Apache::radiobuttonresponse',('foilgroup','foil','conceptgroup')); return $result; } @@ -77,19 +78,17 @@ sub start_foilgroup { } sub storesurvey { - if ( defined $ENV{'form.submitted'}) { - my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']}; - &Apache::lonxml::debug("Here I am!:$response:"); - if ( $response =~ /[0-9]+/) { - my $id = $Apache::inputtags::response['-1']; - my @whichfoils=@{ $Apache::response::foilgroup{'names'} }; - my %responsehash; - $responsehash{$whichfoils[$response]}=$response; - $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.submission"}=&Apache::lonnet::hash2str(%responsehash); - $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='SUBMITTED'; - &Apache::lonxml::debug("submitted a $response
\n"); - } - } + if ( !defined($ENV{'form.submitted'})) { return ''; } + my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']}; + &Apache::lonxml::debug("Here I am!:$response:"); + if ( $response !~ /[0-9]+/) { return ''; } + my $id = $Apache::inputtags::response['-1']; + my @whichfoils=@{ $Apache::response::foilgroup{'names'} }; + my %responsehash; + $responsehash{$whichfoils[$response]}=$response; + $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.submission"}=&Apache::lonnet::hash2str(%responsehash); + $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='SUBMITTED'; + &Apache::lonxml::debug("submitted a $response
\n"); return ''; } @@ -154,11 +153,13 @@ sub end_foilgroup { sub getfoilcounts { my ($parstack,$safeeval)=@_; my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2'); - my @names = @{ $Apache::response::foilgroup{'names'} }; + my @names; my $truecnt=0; my $falsecnt=0; my $name; - + if ( $Apache::response::foilgroup{'names'} ) { + @names= @{ $Apache::response::foilgroup{'names'} }; + } foreach $name (@names) { if ($Apache::response::foilgroup{$name.'.value'} eq 'true') { $truecnt++; @@ -196,7 +197,10 @@ sub whichfoils { my @truelist; my @falselist; - my @names = @{ $Apache::response::foilgroup{'names'} }; + my @names; + if ( $Apache::response::foilgroup{'names'} ) { + @names= @{ $Apache::response::foilgroup{'names'} }; + } foreach my $name (@names) { #result.="
$name is $Apache::response::foilgroup{$name.'.value'} "; if ($Apache::response::foilgroup{$name.'.value'} eq 'true') { @@ -257,7 +261,6 @@ sub displayfoils { sub displayanswers { my ($max,$answer)=@_; - my @names = @{ $Apache::response::foilgroup{'names'} }; my @whichopt = &whichfoils($max,$answer); my $result=&Apache::response::answer_header('radiobuttonresponse'); foreach my $name (@whichopt) {