--- loncom/homework/radiobuttonresponse.pm 2001/12/13 23:36:39 1.32 +++ loncom/homework/radiobuttonresponse.pm 2002/01/25 16:11:37 1.37 @@ -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.37 2002/01/25 16:11:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,7 +30,7 @@ package Apache::radiobuttonresponse; use strict; -sub BEGIN { +BEGIN { &Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse')); } @@ -45,12 +45,13 @@ sub start_radiobuttonresponse { $result=&Apache::response::meta_package_write('radiobuttonresponse'); } elsif ($target eq 'edit' ) { $result.=&Apache::edit::start_table($token). - ''.&Apache::lonxml::description($token)."Delete:". + ''.&Apache::lonxml::description($token)."Delete:". &Apache::edit::deletelist($target,$token) - ." \n"; - $result.=&Apache::edit::text_arg('Max Number Of Foils:','max',$token,'4'). - ""; - $result.="\n"; + ." ".&Apache::edit::end_row() + .&Apache::edit::start_spanning_row(); + + $result.=&Apache::edit::text_arg('Max Number Of Shown Foils:','max',$token,'4'). + &Apache::edit::end_row().&Apache::edit::start_spanning_row()."\n"; } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack, $safeeval,'max'); @@ -65,6 +66,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 +79,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 +154,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 +198,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 +262,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) { @@ -276,7 +280,7 @@ sub start_conceptgroup { if ($target eq 'edit') { $result.=&Apache::edit::tag_start($target,$token); $result.=&Apache::edit::text_arg('Concept:','concept',$token,'50'). - "\n"; + &Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack, $safeeval,'concept'); @@ -322,6 +326,7 @@ sub start_foil { $result.=&Apache::edit::text_arg('Name:','name',$token); $result.=&Apache::edit::select_arg('Correct Option:','value', ['unused','true','false'],$token); + $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval, 'value','name');