--- loncom/interface/lonhelper.pm 2004/04/27 15:32:45 1.77 +++ loncom/interface/lonhelper.pm 2005/02/22 11:43:05 1.98 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.77 2004/04/27 15:32:45 sakharuk Exp $ +# $Id: lonhelper.pm,v 1.98 2005/02/22 11:43:05 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -575,6 +575,7 @@ sub display { } # Phase 4: Display. + my $html=&Apache::lonxml::xmlbegin(); my $stateTitle=&mt($state->title()); my $helperTitle = &mt($self->{TITLE}); my $bodytag = &Apache::loncommon::bodytag($helperTitle,'',''); @@ -584,9 +585,8 @@ sub display { my $loncapaHelper = &mt("LON-CAPA Helper:"); $result .= < +$html - $loncapaHelper: $helperTitle $bodytag @@ -1165,7 +1165,7 @@ sub start_choice { $parser)); my $nextstate = $token->[2]{'nextstate'}; my $evalFlag = $token->[2]{'eval'}; - push @{$paramHash->{CHOICES}}, [$human, $computer, $nextstate, + push @{$paramHash->{CHOICES}}, [&mtn($human), $computer, $nextstate, $evalFlag]; return ''; } @@ -1174,6 +1174,13 @@ sub end_choice { return ''; } +{ + # used to generate unique id attributes for tags. + # internal use only. + my $id = 0; + sub new_id { return $id++; } +} + sub render { my $self = shift; my $var = $self->{'variable'}; @@ -1256,14 +1263,16 @@ BUTTONS my $type = "radio"; if ($self->{'multichoice'}) { $type = 'checkbox'; } foreach my $choice (@{$self->{CHOICES}}) { + my $id = &new_id(); $result .= "\n \n"; $result .= "&"') + HTML::Entities::encode($choice->[1],"<>&\"'") . "'"; if ($checkedChoices{$choice->[1]}) { $result .= " checked "; } + $result .= qq{id="$id"}; my $choiceLabel = $choice->[0]; if ($choice->[4]) { # if we need to evaluate this choice $choiceLabel = "sub { my $helper = shift; my $state = shift;" . @@ -1271,8 +1280,8 @@ BUTTONS $choiceLabel = eval($choiceLabel); $choiceLabel = &$choiceLabel($helper, $self); } - &Apache::lonnet::logthis("TITLE TRANSLATION >$choiceLabel<"); - $result .= "/> " . &mtn($choiceLabel) . "\n"; + $result .= "/> ".qq{\n"; } $result .= "\n\n\n"; $result .= $buttons; @@ -1415,7 +1424,7 @@ sub render { $result .= "&\"'"); + if($option_vars) { + foreach my $option_var (@$option_vars) { + my $checked =""; + if($helper->{VARS}->{$option_var} =~ /$raw_name/) { + $checked = "checked"; + } + $col .= + " "; + } + } + + $col .= "&"') - . "' />"; - return $col; + $col .= "value='" . $resource_name . "' />"; + + return $result.$col; } }; + my $renderPartsFunc = sub { + my ($resource, $part, $params) = @_; + my $col= ""; + my $id=$resource->{ID}; + my $resource_name = + &HTML::Entities::encode(&$valueFunc($resource),"<>&\"'"); + if ($addparts && (scalar(@{$resource->parts}) > 1)) { + $col .= ""; + } + $col .= ""; + }; + $result.=(< + function updateRadio(form,name,value) { + var radiobutton=form[name]; + for (var i=0; i