--- loncom/interface/lonhelper.pm 2005/10/01 02:28:55 1.116 +++ loncom/interface/lonhelper.pm 2006/01/17 18:39:50 1.129 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.116 2005/10/01 02:28:55 albertel Exp $ +# $Id: lonhelper.pm,v 1.129 2006/01/17 18:39:50 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 @@ -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,9 +1559,22 @@ sub render { my $var = $self->{'variable'}; my $date; - + + my $time=time; + 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') { $time=time; $anytime=1; } + } + if ($anytime) { + $onclick = "onclick=\"javascript:updateCheck(this.form,'${var}anytime',false)\""; + } # Default date: The current hour. - $date = localtime(); + $date = localtime($time); $date->min(0); if (defined $self->{ERROR_MSG}) { @@ -1565,7 +1583,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 +1647,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 .= "