File:  [LON-CAPA] / loncom / homework / outputtags.pm
Revision 1.19: download - view: text, annotated - select for diffs
Mon Aug 19 19:06:02 2002 UTC (21 years, 8 months ago) by sakharuk
Branches: MAIN
CVS tags: version_0_5_1, version_0_5, HEAD
 Corrections for the % in problem's title.

    1: # The LearningOnline Network with CAPA 
    2: # tags that create controlled output
    3: #
    4: # $Id: outputtags.pm,v 1.19 2002/08/19 19:06:02 sakharuk 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: 
   29: package Apache::outputtags; 
   30: 
   31: use strict;
   32: use Apache::lonnet;
   33: use POSIX qw(strftime);
   34: 
   35: BEGIN {
   36:   &Apache::lonxml::register('Apache::outputtags',('displayduedate','displaytitle'));
   37: }
   38: 
   39: sub start_displayduedate {
   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>';
   59:     }
   60:   } elsif ( $target eq 'edit' ) {
   61:     $result=&Apache::edit::tag_start($target,$token);
   62:     $result.='</td></tr>';
   63:     $result.=&Apache::edit::end_table();
   64:   }
   65:   return $result;
   66: }
   67: 
   68: sub end_displayduedate {
   69:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   70:   my @result;
   71:   if ($target eq 'edit') { $result[1]='no'; }
   72:   return @result;
   73: }
   74: 
   75: sub start_displaytitle {
   76:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   77:   my $result='';
   78:   if ($target eq 'web') {
   79:     $result="<h1>$Apache::lonhomework::name</h1>";
   80:   } elsif ($target eq 'edit') {
   81:     $result=&Apache::edit::tag_start($target,$token);
   82:     $result.='</td></tr>';
   83:     $result.=&Apache::edit::end_table();
   84:   } elsif ($target eq 'tex') {
   85:       $Apache::lonhomework::name=~s/%/\%/g;
   86:       $Apache::lonhomework::name=~s/&/\&/g;
   87:       $result='\vskip 0 mm\noindent\textbf{'.$Apache::lonhomework::name.'}\vskip 0 mm';
   88:   }
   89:   return $result;
   90: }
   91: 
   92: sub end_displaytitle {
   93:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   94:   my @result;
   95:   if ($target eq 'edit') { $result[1]='no'; }
   96:   return @result;
   97: }
   98: 
   99: 1;
  100: __END__

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