Annotation of loncom/homework/outputtags.pm, revision 1.20
1.13 albertel 1: # The LearningOnline Network with CAPA
2: # tags that create controlled output
3: #
1.20 ! albertel 4: # $Id: outputtags.pm,v 1.19 2002/08/19 19:06:02 sakharuk Exp $
1.13 albertel 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:
1.15 harris41 35: BEGIN {
1.20 ! albertel 36: &Apache::lonxml::register('Apache::outputtags',('displayduedate','displaytitle'));
! 37: }
! 38:
! 39: sub initialize_outputtags {
! 40: %Apache::outputtags::showonce=();
1.1 albertel 41: }
42:
1.2 albertel 43: sub start_displayduedate {
1.20 ! albertel 44: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
! 45: my $result;
! 46: if (exists($Apache::outputtags::showonce{'displayduedate'})) {
! 47: return '';
! 48: } else {
! 49: $Apache::outputtags::showonce{'displayduedate'}=1;
1.10 albertel 50: }
1.20 ! albertel 51: my $status=$Apache::inputtags::status['-1'];
! 52: &Apache::lonxml::debug("got a $status in duedatebox");
! 53: if (($status =~ /CAN.*_ANSWER/) && ($target eq 'web')) {
! 54: my $format = &Apache::lonxml::get_param('format',$parstack,$safeeval);
! 55: if ($format eq '') {
! 56: &Apache::lonxml::debug("using default format");
! 57: $format="%c";
! 58: }
! 59: my $id = $Apache::inputtags::part;
! 60: my $date = &Apache::lonnet::EXT("resource.$id.duedate");
! 61: &Apache::lonxml::debug("duedatebox found $date for $id");
! 62: if ($date) {
! 63: $result ='<table border="on"><tr><td>Due at '.
! 64: POSIX::strftime($format,localtime($date)).
! 65: '</td></tr></table>';
! 66: } else {
! 67: $result ='<table border="on"><tr><td>No due date set.</td></tr></table>';
! 68: }
! 69: } elsif ( $target eq 'edit' ) {
! 70: $result=&Apache::edit::tag_start($target,$token);
! 71: $result.='</td></tr>';
! 72: $result.=&Apache::edit::end_table();
1.5 www 73: }
1.20 ! albertel 74: return $result;
1.1 albertel 75: }
76:
1.2 albertel 77: sub end_displayduedate {
1.20 ! albertel 78: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
! 79: my @result;
! 80: if ($target eq 'edit') { $result[1]='no'; }
! 81: return @result;
1.2 albertel 82: }
83:
84: sub start_displaytitle {
1.20 ! albertel 85: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
! 86: my $result='';
! 87: if (exists($Apache::outputtags::showonce{'displayduedate'})) {
! 88: return '';
! 89: } else {
! 90: $Apache::outputtags::showonce{'displayduedate'}=1;
! 91: }
! 92: if ($target eq 'web') {
! 93: $result="<h1>$Apache::lonhomework::name</h1>";
! 94: } elsif ($target eq 'edit') {
! 95: $result=&Apache::edit::tag_start($target,$token);
! 96: $result.='</td></tr>';
! 97: $result.=&Apache::edit::end_table();
! 98: } elsif ($target eq 'tex') {
! 99: $Apache::lonhomework::name=~s/%/\%/g;
! 100: $Apache::lonhomework::name=~s/&/\&/g;
! 101: $result='\vskip 0 mm\noindent\textbf{'.$Apache::lonhomework::name.'}\vskip 0 mm';
! 102: }
! 103: return $result;
1.2 albertel 104: }
105:
106: sub end_displaytitle {
1.20 ! albertel 107: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
! 108: my @result;
! 109: if ($target eq 'edit') { $result[1]='no'; }
! 110: return @result;
1.1 albertel 111: }
112:
113: 1;
114: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>