--- loncom/homework/optionresponse.pm 2001/06/12 22:42:55 1.14 +++ loncom/homework/optionresponse.pm 2001/06/16 18:35:27 1.15 @@ -27,9 +27,12 @@ sub start_optionresponse { } sub end_optionresponse { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; &Apache::response::end_response; pop @Apache::lonxml::namespace; - return ''; + my $result; + if ($target eq 'edit') { $result=&Apache::edit::end_table(); } + return $result; } sub insert_optionresponse { @@ -107,7 +110,7 @@ sub end_foilgroup { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result; - if ($target ne 'meta') { + if ($target eq 'grade' || $target eq 'web') { my $name; my ($count,$max) = &getfoilcounts($parstack,$safeeval); if ($count>$max) { $count=$max } @@ -148,6 +151,9 @@ sub end_foilgroup { } } } + if ($target eq 'edit') { + $result.=&Apache::edit::end_table(); + } return $result; } @@ -206,14 +212,23 @@ sub displayfoils { sub start_conceptgroup { - $Apache::optionresponse::conceptgroup=1; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; + $Apache::optionresponse::conceptgroup=1; %Apache::response::conceptgroup={}; - return ''; + my $result; + if ($target eq 'edit') { + my $insertlist=&Apache::edit::insertlist($target,$token); + $result.=&Apache::edit::tag_start($target,$token,"Concept Grouped Foils"); + my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval); + $result.="Concept: "; + } + return $result; } sub end_conceptgroup { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; - $Apache::optionresponse::conceptgroup=0; + $Apache::optionresponse::conceptgroup=0; + my $result=''; if ($target eq 'web' || $target eq 'grade') { my @names = @{ $Apache::response::conceptgroup{'names'} }; my $pick=int rand $#names+1; @@ -225,7 +240,10 @@ sub end_conceptgroup { $Apache::response::foilgroup{"$name.concept"} = $concept; &Apache::lonxml::debug("Selecting $name in $concept"); } - return ''; + if ($target eq 'edit') { + $result=&Apache::edit::end_table(); + } + return $result; } sub start_foil { @@ -234,14 +252,45 @@ sub start_foil { if ($target eq 'web') { &Apache::lonxml::startredirection; } if ($target eq 'edit') { $result=&Apache::edit::tag_start($target,$token,"Foil"); + my $level='-2'; + if ($$tagstack['-2'] eq 'conceptgroup') { $level = '-3'; } my @opt; - eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval,'-2'); - my $optionlist="\n"; + eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval,$level); + my $value=&Apache::lonxml::get_param('value',$parstack,$safeeval); + my $optionlist="\n"; foreach my $option (@opt) { - $optionlist.="\n"; + if ( $value eq $option ) { + $optionlist.="\n"; + } else { + $optionlist.="\n"; + } + } + my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval); + $result.="Name: ". + "Correct Option: + "; + } + if ($target eq 'modified') { + my $constructtag=0; + foreach my $arg ('value','name') { + my $value=&Apache::lonxml::get_param($arg,$parstack,$safeeval); + my $newvalue=$ENV{"form.$Apache::lonxml::curdepth.$arg"}; + &Apache::lonxml::debug(" for:$arg: cur is :$value: new is :$newvalue:"); + if ($value ne $newvalue) { + $token->[2]->{$arg}=$newvalue; + $constructtag=1; + } + } + if ($constructtag) { + $result = '<'.$token->[1]; + while (my ($key,$val)= each(%{$token->[2]})) { + &Apache::lonxml::debug("setting :$key: to :$val:"); + $result.=' '.$key.'="'.$val.'"'; + } + $result.=">"; } - $result.="Name: ". - "Correct Option:"; } return $result; } @@ -275,7 +324,7 @@ sub end_foil { sub insert_foil { return ' - + ';