--- loncom/interface/lonhelper.pm 2009/02/13 20:20:30 1.170 +++ loncom/interface/lonhelper.pm 2009/06/12 15:31:30 1.174 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.170 2009/02/13 20:20:30 schafran Exp $ +# $Id: lonhelper.pm,v 1.174 2009/06/12 15:31:30 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -188,6 +188,8 @@ use Apache::lonlocal; use Apache::lonnet; use Apache::longroup; use Apache::lonselstudent; + + use LONCAPA; # Register all the tags with the helper, so the helper can @@ -587,15 +589,24 @@ sub display { &Apache::loncommon::browser_and_searcher_javascript(). "\n".''; + # Breadcrumbs + my $brcrum = [{'href' => '', + 'text' => 'Helper'}]; + # FIXME: Dynamically add context sensitive breadcrumbs + # depending on the caller, + # e.g. printing, parametrization, etc. + # FIXME: Add breadcrumbs to reflect current helper state + $result .= &Apache::loncommon::start_page($self->{TITLE}, - $browser_searcher_js); - + $browser_searcher_js, + {'bread_crumbs' => $brcrum,}); + my $previous = HTML::Entities::encode(&mt("Back"), '<>&"'); my $next = HTML::Entities::encode(&mt("Next"), '<>&"'); # FIXME: This should be parameterized, not concatenated - Jeremy - if (!$state->overrideForm()) { $result.="
"; } + if (!$state->overrideForm()) { $result.=''; } if ($stateHelp) { $stateHelp = &Apache::loncommon::help_open_topic($stateHelp); } @@ -1508,12 +1519,15 @@ sub postprocess { my $self = shift; my $chosenValue = $env{'form.' . $self->{'variable'} . '_forminput'}; + if (!defined($chosenValue) && !$self->{'allowempty'}) { $self->{ERROR_MSG} = &mt("You must choose one or more choices to continue."); return 0; } + + if (ref($chosenValue)) { $helper->{VARS}->{$self->{'variable'}} = join('|||', @$chosenValue); } @@ -2446,6 +2460,21 @@ sub postprocess { $self->{ERROR_MSG} = 'You must choose at least one resource to continue.'; return 0; } + # For each of the attached options. If it's env var is undefined, set it to + # an empty string instead.. an undef'd env var means no choices selected. + # + + my $option_vars = $self->{OPTION_VARS}; + if ($option_vars) { + foreach my $var (@$option_vars) { + my $env_name = "form.".$var."_forminput"; + if (!defined($env{$env_name})) { + $env{$env_name} = ''; + $helper->{VARS}->{$var} = ''; + } + } + } + if (defined($self->{NEXTSTATE})) { $helper->changeState($self->{NEXTSTATE}); @@ -3545,8 +3574,7 @@ sub render { my $previous = HTML::Entities::encode(&mt("Back"), '<>&"'); my $next = HTML::Entities::encode(&mt("Next"), '<>&"'); my $target = " target='loncapaclient'"; - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { $target=''; } + if ($env{'environment.remote'} eq 'off') { $target=''; } $result .= "
\n" . "\n" . "" . @@ -3695,7 +3723,7 @@ sub render { $paramlevel = 'full'; } - my $result = "\n"; + my $result = "\n"; $result .= "\n"; $result .= "\n"; $result .= "