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