File:
[LON-CAPA] /
loncom /
interface /
lonhtmlcommon.pm
Revision
1.8:
download - view:
text,
annotated -
select for diffs
Wed Aug 21 17:18:08 2002 UTC (22 years ago) by
www
Branches:
MAIN
CVS tags:
HEAD
Starting to implement common header and color scheme for LON-CAPA handlers
(non-content pages).
Instead of <body bgcolor="#...."><h1>... call
&Apache::loncommon::bodytag(title,[role],[add_body_parms]);
title: what it says in the header
role (OPTIONAL): override role choice
('admin','coordinator','student','author')
add_body_parms: additional parameters to be put into the body tag, for
example 'onLoad="init();" or stuff
Colors and layout will likely change in the future, including domain
customization, help function calls, (css?)
1: # The LearningOnline Network with CAPA
2: # a pile of common html routines
3: #
4: # $Id: lonhtmlcommon.pm,v 1.8 2002/08/21 17:18:08 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:
29: package Apache::lonhtmlcommon;
30:
31: use strict;
32:
33: sub AscendOrderOptions {
34: my ($order, $page, $formName)=@_;
35:
36: my $OpSel1 = '';
37: my $OpSel2 = '';
38:
39: if($order eq 'Ascending') {
40: $OpSel1 = ' selected';
41: } else {
42: $OpSel2 = ' selected';
43: }
44:
45: my $Str = '';
46: $Str .= '<select name="'.(($page)?$page:'').'Ascend"';
47: if($formName) {
48: $Str .= ' onchange="document.'.$formName.'.submit()"';
49: }
50: $Str .= '>'."\n";
51: $Str .= '<option'.$OpSel1.'>Ascending</option>'."\n".
52: '<option'.$OpSel2.'>Descending</option>'."\n";
53: $Str .= '</select>'."\n";
54:
55: return $Str;
56: }
57:
58: sub MapOptions {
59: my ($data, $page, $formName)=@_;
60: my $Str = '';
61: $Str .= '<select name="';
62: $Str .= (($page)?$page:'').'Maps"';
63: if($formName) {
64: $Str .= ' onchange="document.'.$formName.'.submit()"';
65: }
66: $Str .= '>'."\n";
67:
68: my $selected = 0;
69: foreach my $sequence (split(':',$data->{'orderedSequences'})) {
70: $Str .= '<option';
71: if($data->{$page.'Maps'} eq $data->{$sequence.':title'}) {
72: $Str .= ' selected';
73: $selected = 1;
74: }
75: $Str .= '>'.$data->{$sequence.':title'}.'</option>'."\n";
76: }
77: $Str .= '<option';
78: if(!$selected) {
79: $Str .= ' selected';
80: }
81: $Str .= '>All Maps</option>'."\n";
82:
83: $Str .= '</select>'."\n";
84:
85: return $Str;
86: }
87:
88: sub StudentOptions {
89: my ($cache, $students, $selectedName, $page, $formName)=@_;
90:
91: my $Str = '';
92: $Str .= '<select name="'.(($page)?$page:'').'Student"';
93: if($formName) {
94: $Str .= ' onchange="document.'.$formName.'.submit()"';
95: }
96: $Str .= '>'."\n";
97:
98: my $selected=0;
99:
100: foreach (@$students) {
101: $Str .= '<option';
102: if($selectedName eq $_) {
103: $Str .= ' selected';
104: $selected = 1;
105: }
106: $Str .= '>';
107: $Str .= $cache->{$_.':fullname'};
108: $Str .= '</option>'."\n";
109: }
110:
111: $Str .= '<option';
112: if($selectedName eq 'No Student Selected') {
113: $Str .= ' selected';
114: $selected = 1;
115: }
116: $Str .= '>No Student Selected</option>'."\n";
117:
118: $Str .= '<option';
119: if(!$selected) {
120: $Str .= ' selected';
121: }
122: $Str .= '>All Students</option>'."\n";
123:
124: $Str .= '</select>'."\n";
125:
126: return $Str;
127: }
128:
129: sub StatusOptions {
130: my ($status, $formName)=@_;
131:
132: my $OpSel1 = '';
133: my $OpSel2 = '';
134: my $OpSel3 = '';
135:
136: if($status eq 'Any') { $OpSel3 = ' selected'; }
137: elsif($status eq 'Expired' ) { $OpSel2 = ' selected'; }
138: else { $OpSel1 = ' selected'; }
139:
140: my $Str = '';
141: $Str .= '<select name="Status"';
142: if(defined($formName) && $formName ne '') {
143: $Str .= ' onchange="document.'.$formName.'.submit()"';
144: }
145: $Str .= '>'."\n";
146: $Str .= '<option'.$OpSel1.'>Active</option>'."\n";
147: $Str .= '<option'.$OpSel2.'>Expired</option>'."\n";
148: $Str .= '<option'.$OpSel3.'>Any</option>'."\n";
149: $Str .= '</select>'."\n";
150: }
151:
152: sub MultipleSectionSelect {
153: my ($sections,$selectedSections)=@_;
154:
155: my $Str = '';
156: $Str .= '<select name="Section" multiple="true" size="4">'."\n";
157:
158: foreach (@$sections) {
159: $Str .= '<option';
160: foreach my $selected (@$selectedSections) {
161: if($_ eq $selected) {
162: $Str .= ' selected=""';
163: }
164: }
165: $Str .= '>'.$_.'</option>'."\n";
166: }
167: $Str .= '</select>'."\n";
168:
169: return $Str;
170: }
171:
172: sub Title {
173: my ($pageName)=@_;
174:
175: my $Str = '';
176:
177: $Str .= '<html><head><title>'.$pageName.'</title></head>'."\n";
178: $Str .= &Apache::loncommon::bodytag($pageName)."\n";
179: $Str .= '<script>window.focus(); window.width=500;window.height=500;';
180: $Str .= '</script>'."\n";
181:
182: return $Str;
183: }
184:
185: =pod
186:
187: =item &CreateTableHeadings()
188:
189: This function generates the column headings for the chart.
190:
191: =over 4
192:
193: Inputs: $CacheData, $keyID, $headings, $spacePadding
194:
195: $CacheData: pointer to a hash tied to the cached data database
196:
197: $keyID: a pointer to an array containing the names of the data
198: held in a column and is used as part of a key into $CacheData
199:
200: $headings: The names of the headings for the student information
201:
202: $spacePadding: The spaces to go between columns
203:
204: Output: $Str
205:
206: $Str: A formatted string of the table column headings.
207:
208: =back
209:
210: =cut
211:
212: sub CreateHeadings {
213: my ($data,$keyID,$headings,$displayString,$format)=@_;
214: my $Str='';
215: my $formatting = '';
216:
217: for(my $index=0; $index<(scalar @$headings); $index++) {
218: my $currentHeading=$headings->[$index];
219: if($format eq 'preformatted') {
220: my @dataLength=split(//,$currentHeading);
221: my $length=scalar @dataLength;
222: $formatting = (' 'x
223: ($data->{$keyID->[$index].':columnWidth'}-$length));
224: }
225: my $linkdata=$keyID->[$index];
226:
227: my $tempString = $displayString;
228: $tempString =~ s/LINKDATA/$linkdata/;
229: $tempString =~ s/DISPLAYDATA/$currentHeading/;
230: $tempString =~ s/FORMATTING/$formatting/;
231:
232: $Str .= $tempString;
233: }
234:
235: return $Str;
236: }
237:
238: =pod
239:
240: =item &FormatStudentInformation()
241:
242: This function produces a formatted string of the student's information:
243: username, domain, section, full name, and PID.
244:
245: =over 4
246:
247: Input: $cache, $name, $keyID, $spacePadding
248:
249: $cache: This is a pointer to a hash that is tied to the cached data
250:
251: $name: The name and domain of the current student in name:domain format
252:
253: $keyID: A pointer to an array holding the names used to
254:
255: remove data from the hash. They represent the name of the data to be removed.
256:
257: $spacePadding: Extra spaces that represent the space between columns
258:
259: Output: $Str
260:
261: $Str: Formatted string.
262:
263: =back
264:
265: =cut
266:
267: sub FormatStudentInformation {
268: my ($data,$name,$keyID,$displayString,$format)=@_;
269: my $Str='';
270: my $currentColumn;
271:
272: for(my $index=0; $index<(scalar @$keyID); $index++) {
273: $currentColumn=$data->{$name.':'.$keyID->[$index]};
274:
275: if($format eq 'preformatted') {
276: my @dataLength=split(//,$currentColumn);
277: my $length=scalar @dataLength;
278: $currentColumn.= (' 'x
279: ($data->{$keyID->[$index].':columnWidth'}-$length));
280: }
281:
282: my $tempString = $displayString;
283: $tempString =~ s/DISPLAYDATA/$currentColumn/;
284:
285: $Str .= $tempString;
286: }
287:
288: return $Str;
289: }
290:
291: # Create progress
292: sub Create_PrgWin {
293: my ($r, $title, $heading)=@_;
294: $r->print('<script>'.
295: "popwin=open(\'\',\'popwin\',\'width=400,height=100\');".
296: "popwin.document.writeln(\'<html><body bgcolor=\"#88DDFF\">".
297: "<title>$title</title>".
298: "<h4>$heading</h4>".
299: "<form name=popremain>".
300: "<input type=text size=35 name=remaining value=Starting></form>".
301: "</body></html>\');".
302: "popwin.document.close();".
303: "</script>");
304:
305: $r->rflush();
306: }
307:
308: # update progress
309: sub Update_PrgWin {
310: my ($displayString,$r)=@_;
311: $r->print('<script>popwin.document.popremain.remaining.value="'.
312: $displayString.'";</script>');
313: $r->rflush();
314: }
315:
316: # close Progress Line
317: sub Close_PrgWin {
318: my ($r)=@_;
319: $r->print('<script>popwin.close()</script>'."\n");
320: $r->rflush();
321: }
322:
323: 1;
324: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>