--- loncom/interface/lonhelper.pm 2005/10/17 21:14:55 1.126 +++ loncom/interface/lonhelper.pm 2006/01/24 22:20:19 1.130 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.126 2005/10/17 21:14:55 albertel Exp $ +# $Id: lonhelper.pm,v 1.130 2006/01/24 22:20:19 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -576,6 +576,7 @@ sub display { my $html=&Apache::lonxml::xmlbegin(); my $stateTitle=&mt($state->title()); my $helperTitle = &mt($self->{TITLE}); + my $browser_searcher_js = &Apache::loncommon::browser_and_searcher_javascript(); my $bodytag = &Apache::loncommon::bodytag($helperTitle,'',''); my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"'); my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"'); @@ -586,6 +587,9 @@ sub display { $html $loncapaHelper: $helperTitle + $bodytag HEADER @@ -1557,6 +1561,8 @@ sub render { my $date; my $time=time; + $date = localtime($time); + $date->min(0); my ($anytime,$onclick); if (defined($self->{DEFAULT_VALUE})) { @@ -1564,14 +1570,18 @@ sub render { die('Error in default value code for variable ' . $self->{'variable'} . ', Perl said: ' . $@) if $@; $time = &$valueFunc($helper, $self); - if (lc($time) eq 'anytime') { $time=time; $anytime=1; } + if (lc($time) eq 'anytime') { + $anytime=1; + } else { + $date = localtime($time); + } + } else { + } if ($anytime) { $onclick = "onclick=\"javascript:updateCheck(this.form,'${var}anytime',false)\""; } # Default date: The current hour. - $date = localtime($time); - $date->min(0); if (defined $self->{ERROR_MSG}) { $result .= '' . $self->{ERROR_MSG} . '

'; @@ -2980,6 +2990,73 @@ sub end_section { } 1; +package Apache::lonhelper::group; + +=pod + +=head2 Element: groupX + +
allows the user to choose one or more groups from the current course. + +It takes the standard attributes "variable", "multichoice", and "nextstate", meaning what they do for most other elements. + +=cut + +no strict; +@ISA = ("Apache::lonhelper::choices"); +use strict; + +BEGIN { + &Apache::lonhelper::register('Apache::lonhelper::group', + ('group')); +} + +sub new { + my $ref = Apache::lonhelper::choices->new(); + bless($ref); +} + +sub start_group { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; + + if ($target ne 'helper') { + return ''; + } + + $paramHash->{CHOICES} = []; + + $paramHash->{'variable'} = $token->[2]{'variable'}; + $helper->declareVar($paramHash->{'variable'}); + $paramHash->{'multichoice'} = $token->[2]{'multichoice'}; + if (defined($token->[2]{'nextstate'})) { + $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; + } + + # Populate the CHOICES element + my %choices; + + my $numgroups; + my %curr_groups; + if (&Apache::loncommon::coursegroups(\%curr_groups)) { + foreach my $group_name (keys %curr_groups) { + $choices{$group_name} = $group_name; + } + } + foreach my $group_name (sort(keys(%choices))) { + push @{$paramHash->{CHOICES}}, [$group_name, $group_name]; + } +} + +sub end_group { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; + + if ($target ne 'helper') { + return ''; + } + Apache::lonhelper::group->new(); +} +1; + package Apache::lonhelper::string; =pod @@ -3361,8 +3438,11 @@ sub render { } my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"'); my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"'); + my $target = " target='loncapaclient'"; + if (($env{'browser.interface'} eq 'textual') || + ($env{'environment.remote'} eq 'off')) { $target=''; } $result .= "
\n" . - "
\n" . + "\n" . "" . "" . "\n" . @@ -3563,6 +3643,11 @@ sub render { $result .= '
  • '.&mt('for section [_1]',"$section").'
  • '; $result .= "&\"") . "' />\n"; + } elsif ($vars->{TARGETS} eq 'group') { + my $group = $vars->{GROUP_NAME}; + $result .= '
  • '.&mt('for group [_1]',"$group").'
  • '; + $result .= "&\"") . "' />\n"; } else { # FIXME: This is probably wasteful! Store the name! my $classlist = Apache::loncoursedata::get_classlist();