Annotation of loncom/homework/outputtags.pm, revision 1.13

1.13    ! albertel    1: # The LearningOnline Network with CAPA 
        !             2: # tags that create controlled output
        !             3: #
        !             4: # $Id: gplheader.pl,v 1.1 2001/11/29 18:19:27 www Exp $
        !             5: #
        !             6: # Copyright Michigan State University Board of Trustees
        !             7: #
        !             8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
        !             9: #
        !            10: # LON-CAPA is free software; you can redistribute it and/or modify
        !            11: # it under the terms of the GNU General Public License as published by
        !            12: # the Free Software Foundation; either version 2 of the License, or
        !            13: # (at your option) any later version.
        !            14: #
        !            15: # LON-CAPA is distributed in the hope that it will be useful,
        !            16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            18: # GNU General Public License for more details.
        !            19: #
        !            20: # You should have received a copy of the GNU General Public License
        !            21: # along with LON-CAPA; if not, write to the Free Software
        !            22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        !            23: #
        !            24: # /home/httpd/html/adm/gpl.txt
        !            25: #
        !            26: # http://www.lon-capa.org/
        !            27: #
        !            28: 
1.1       albertel   29: package Apache::outputtags; 
                     30: 
                     31: use strict;
                     32: use Apache::lonnet;
                     33: use POSIX qw(strftime);
                     34: 
                     35: sub BEGIN {
1.10      albertel   36:   &Apache::lonxml::register('Apache::outputtags',('displayduedate','displaytitle'));
1.1       albertel   37: }
                     38: 
1.2       albertel   39: sub start_displayduedate {
1.10      albertel   40:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     41:   my $result;
                     42:   my $status=$Apache::inputtags::status['-1'];
                     43:   &Apache::lonxml::debug("got a $status in duedatebox");
                     44:   if (($status =~ /CAN.*_ANSWER/) && ($target eq 'web')) {
                     45:     my $format = &Apache::lonxml::get_param('format',$parstack,$safeeval);
                     46:     if ($format eq '') {
                     47:       &Apache::lonxml::debug("using default format");
                     48:       $format="%c";
                     49:     }
                     50:     my $id = $Apache::inputtags::part;
                     51:     my $date = &Apache::lonnet::EXT("resource.$id.duedate");
                     52:     &Apache::lonxml::debug("duedatebox found $date for $id");
                     53:     if ($date) {
                     54:        $result ='<table border="on"><tr><td>Due at '.
                     55:          POSIX::strftime($format,localtime($date)).
                     56: 	   '</td></tr></table>';
                     57:     } else {
                     58:       $result ='<table border="on"><tr><td>No due date set.</td></tr></table>';
1.5       www        59:     }
1.11      albertel   60:   } elsif ( $target eq 'edit' ) {
                     61:     $result=&Apache::edit::tag_start($target,$token,
                     62: 				     &Apache::lonxml::description($token));
                     63:     $result.='</td></tr>';
                     64:     $result.=&Apache::edit::end_table();
1.10      albertel   65:   }
                     66:   return $result;
1.1       albertel   67: }
                     68: 
1.2       albertel   69: sub end_displayduedate {
1.11      albertel   70:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     71:   my @result;
1.12      albertel   72:   if ($target eq 'edit') { $result[1]='no'; }
1.11      albertel   73:   return @result;
1.2       albertel   74: }
                     75: 
                     76: sub start_displaytitle {
1.10      albertel   77:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     78:   my $result='';
                     79:   if ($target eq 'web') {
                     80:     $result="<h1>$Apache::lonhomework::name</h1>";
1.11      albertel   81:   } elsif ($target eq 'edit') {
                     82:     $result=&Apache::edit::tag_start($target,$token,
                     83: 				     &Apache::lonxml::description($token));
                     84:     $result.='</td></tr>';
                     85:     $result.=&Apache::edit::end_table();
1.10      albertel   86:   }
                     87:   return $result;
1.2       albertel   88: }
                     89: 
                     90: sub end_displaytitle {
1.11      albertel   91:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     92:   my @result;
1.12      albertel   93:   if ($target eq 'edit') { $result[1]='no'; }
1.11      albertel   94:   return @result;
1.1       albertel   95: }
                     96: 
                     97: 1;
                     98: __END__

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