Annotation of loncom/homework/outputtags.pm, revision 1.14
1.13 albertel 1: # The LearningOnline Network with CAPA
2: # tags that create controlled output
3: #
1.14 ! matthew 4: # $Id: outputtags.pm,v 1.13 2001/12/04 15:17:56 albertel 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:
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' ) {
1.14 ! matthew 61: $result=&Apache::edit::tag_start($target,$token);
1.11 albertel 62: $result.='</td></tr>';
63: $result.=&Apache::edit::end_table();
1.10 albertel 64: }
65: return $result;
1.1 albertel 66: }
67:
1.2 albertel 68: sub end_displayduedate {
1.11 albertel 69: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
70: my @result;
1.12 albertel 71: if ($target eq 'edit') { $result[1]='no'; }
1.11 albertel 72: return @result;
1.2 albertel 73: }
74:
75: sub start_displaytitle {
1.10 albertel 76: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
77: my $result='';
78: if ($target eq 'web') {
79: $result="<h1>$Apache::lonhomework::name</h1>";
1.11 albertel 80: } elsif ($target eq 'edit') {
1.14 ! matthew 81: $result=&Apache::edit::tag_start($target,$token);
1.11 albertel 82: $result.='</td></tr>';
83: $result.=&Apache::edit::end_table();
1.10 albertel 84: }
85: return $result;
1.2 albertel 86: }
87:
88: sub end_displaytitle {
1.11 albertel 89: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
90: my @result;
1.12 albertel 91: if ($target eq 'edit') { $result[1]='no'; }
1.11 albertel 92: return @result;
1.1 albertel 93: }
94:
95: 1;
96: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>