--- loncom/interface/lonhelper.pm 2005/07/12 16:03:12 1.111 +++ loncom/interface/lonhelper.pm 2005/10/17 21:14:55 1.126 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.111 2005/07/12 16:03:12 albertel Exp $ +# $Id: lonhelper.pm,v 1.126 2005/10/17 21:14:55 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1188,7 +1188,8 @@ sub render { if ($self->{'multichoice'}) { $result .= < + SCRIPT } @@ -1436,7 +1438,7 @@ sub render { $choiceLabel = eval($choiceLabel); $choiceLabel = &$choiceLabel($helper, $self); } - $result .= ">" . &mtn($choiceLabel) . "\n"; + $result .= ">" . &mtn($choiceLabel) . "\n"; } $result .= "\n"; @@ -1534,6 +1536,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 { @@ -1552,9 +1555,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}) { @@ -1563,7 +1579,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++) { @@ -1627,14 +1643,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 .= "