--- loncom/interface/lonhelper.pm 2005/07/12 16:11:19 1.112 +++ loncom/interface/lonhelper.pm 2006/03/06 23:32:31 1.132 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.112 2005/07/12 16:11:19 albertel Exp $ +# $Id: lonhelper.pm,v 1.132 2006/03/06 23:32:31 foxr 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 @@ -1536,6 +1540,7 @@ sub start_date { $paramHash->{'variable'} = $token->[2]{'variable'}; $helper->declareVar($paramHash->{'variable'}); $paramHash->{'hoursminutes'} = $token->[2]{'hoursminutes'}; + $paramHash->{'anytime'} = $token->[2]{'anytime'}; } sub end_date { @@ -1554,10 +1559,29 @@ sub render { my $var = $self->{'variable'}; my $date; - - # Default date: The current hour. - $date = localtime(); + + my $time=time; + $date = localtime($time); $date->min(0); + my ($anytime,$onclick); + + if (defined($self->{DEFAULT_VALUE})) { + my $valueFunc = eval($self->{DEFAULT_VALUE}); + die('Error in default value code for variable ' . + $self->{'variable'} . ', Perl said: ' . $@) if $@; + $time = &$valueFunc($helper, $self); + 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. if (defined $self->{ERROR_MSG}) { $result .= '' . $self->{ERROR_MSG} . '

'; @@ -1565,7 +1589,7 @@ sub render { # Month my $i; - $result .= "\n"; for ($i = 0; $i < 12; $i++) { if ($i == $date->mon) { $result .= "\n"; for ($i = 1; $i < 12; $i++) { @@ -1629,14 +1653,16 @@ sub render { $result .= " :\n"; - $result .= "\n"; + my $selected=0; + for my $i ((0,15,30,45,59,undef,0..59)) { my $printedMinute = $i; - if ($i < 10) { + if (defined($i) && $i < 10) { $printedMinute = "0" . $printedMinute; } - if ($date->min == $i) { + if (!$selected && $date->min == $i) { $result .= "