--- loncom/homework/outputtags.pm 2001/01/11 15:20:58 1.1 +++ loncom/homework/outputtags.pm 2001/08/06 20:33:23 1.10 @@ -5,19 +5,16 @@ use Apache::lonnet; use POSIX qw(strftime); sub BEGIN { - &Apache::lonxml::register('Apache::outputtags',('duedatebox')); + &Apache::lonxml::register('Apache::outputtags',('displayduedate','displaytitle')); } - -sub start_duedatebox { - my ($target,$token,$parstack,$parser,$safeeval)=@_; +sub start_displayduedate { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result; my $status=$Apache::inputtags::status['-1']; &Apache::lonxml::debug("got a $status in duedatebox"); - if ($status =~ /CAN.*_ANSWER/) { - my $args =''; - if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } - my $format = &Apache::run::run("{$args;".'return $format}',$safeeval); + if (($status =~ /CAN.*_ANSWER/) && ($target eq 'web')) { + my $format = &Apache::lonxml::get_param('format',$parstack,$safeeval); if ($format eq '') { &Apache::lonxml::debug("using default format"); $format="%c"; @@ -25,14 +22,32 @@ sub start_duedatebox { my $id = $Apache::inputtags::part; my $date = &Apache::lonnet::EXT("resource.$id.duedate"); &Apache::lonxml::debug("duedatebox found $date for $id"); - $result ='
Due at '. - POSIX::strftime($format,localtime($date)). - '
'; + if ($date) { + $result ='
Due at '. + POSIX::strftime($format,localtime($date)). + '
'; + } else { + $result ='
No due date set.
'; + } + } + return $result; +} + +sub end_displayduedate { + return ''; +} + +sub start_displaytitle { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; + my $result=''; + if ($target eq 'web') { + $result="

$Apache::lonhomework::name

"; } return $result; } -sub end_duedatebox { +sub end_displaytitle { + return ''; } 1;