File:  [LON-CAPA] / loncom / homework / outputtags.pm
Revision 1.11: download - view: text, annotated - select for diffs
Mon Aug 13 20:51:04 2001 UTC (22 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- <displayduedate> and <displaytitle> are now visible in the editing mechanism.
  and have reasoanble displays

    1: package Apache::outputtags; 
    2: 
    3: use strict;
    4: use Apache::lonnet;
    5: use POSIX qw(strftime);
    6: 
    7: sub BEGIN {
    8:   &Apache::lonxml::register('Apache::outputtags',('displayduedate','displaytitle'));
    9: }
   10: 
   11: sub start_displayduedate {
   12:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   13:   my $result;
   14:   my $status=$Apache::inputtags::status['-1'];
   15:   &Apache::lonxml::debug("got a $status in duedatebox");
   16:   if (($status =~ /CAN.*_ANSWER/) && ($target eq 'web')) {
   17:     my $format = &Apache::lonxml::get_param('format',$parstack,$safeeval);
   18:     if ($format eq '') {
   19:       &Apache::lonxml::debug("using default format");
   20:       $format="%c";
   21:     }
   22:     my $id = $Apache::inputtags::part;
   23:     my $date = &Apache::lonnet::EXT("resource.$id.duedate");
   24:     &Apache::lonxml::debug("duedatebox found $date for $id");
   25:     if ($date) {
   26:        $result ='<table border="on"><tr><td>Due at '.
   27:          POSIX::strftime($format,localtime($date)).
   28: 	   '</td></tr></table>';
   29:     } else {
   30:       $result ='<table border="on"><tr><td>No due date set.</td></tr></table>';
   31:     }
   32:   } elsif ( $target eq 'edit' ) {
   33:     $result=&Apache::edit::tag_start($target,$token,
   34: 				     &Apache::lonxml::description($token));
   35:     $result.='</td></tr>';
   36:     $result.=&Apache::edit::end_table();
   37:   }
   38:   return $result;
   39: }
   40: 
   41: sub end_displayduedate {
   42:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   43:   my @result;
   44:   if ($target eq 'edit') { @result[1]='no'; }
   45:   return @result;
   46: }
   47: 
   48: sub start_displaytitle {
   49:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   50:   my $result='';
   51:   if ($target eq 'web') {
   52:     $result="<h1>$Apache::lonhomework::name</h1>";
   53:   } elsif ($target eq 'edit') {
   54:     $result=&Apache::edit::tag_start($target,$token,
   55: 				     &Apache::lonxml::description($token));
   56:     $result.='</td></tr>';
   57:     $result.=&Apache::edit::end_table();
   58:   }
   59:   return $result;
   60: }
   61: 
   62: sub end_displaytitle {
   63:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   64:   my @result;
   65:   if ($target eq 'edit') { @result[1]='no'; }
   66:   return @result;
   67: }
   68: 
   69: 1;
   70: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>