File:
[LON-CAPA] /
loncom /
interface /
lonhtmlcommon.pm
Revision
1.5:
download - view:
text,
annotated -
select for diffs
Fri Jul 26 16:22:09 2002 UTC (22 years, 1 month ago) by
stredwic
Branches:
MAIN
CVS tags:
HEAD
Added section selection. I added a new multiselect box for sections. All
students without a section number or a space or undefined will fall under
the none category. A list of possible sections for a course will be displayed.
Only students with a section number matching one of the selected sections
will be selectable in the students menu and/or display their report. If
the currently view student doesn't have the correct section when the section
selection changes, the student selection will revert to no student selected.
Note: To refresh the reports after changing which sections to display, press
the refresh button or any of the other onchange interface controls.
1: # The LearningOnline Network with CAPA
2: # a pile of common html routines
3: #
4: # $Id: lonhtmlcommon.pm,v 1.5 2002/07/26 16:22:09 stredwic 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 MapOptions {
34: my ($data, $page)=@_;
35: my $Str = '';
36: $Str .= '<select name="';
37: $Str .= (($page)?$page:'').'Map">'."\n";
38:
39: my $selected = 0;
40: foreach my $sequence (split(':',$data->{'orderedSequences'})) {
41: $Str .= '<option';
42: if($data->{$page.'Map'} eq $data->{$sequence.':title'}) {
43: $Str .= ' selected';
44: $selected = 1;
45: }
46: $Str .= '>'.$data->{$sequence.':title'}.'</option>'."\n";
47: }
48: $Str .= '<option';
49: if(!$selected) {
50: $Str .= ' selected';
51: }
52: $Str .= '>All Maps</option>'."\n";
53:
54: $Str .= '</select>'."\n";
55:
56: return $Str;
57: }
58:
59: sub StudentOptions {
60: my ($cache, $students, $selectedName, $page, $formName)=@_;
61:
62: my $Str = '';
63: $Str .= '<select name="'.(($page)?$page:'').'Student"';
64: if($formName) {
65: $Str .= ' onchange="document.'.$formName.'.submit()"';
66: }
67: $Str .= '>'."\n";
68:
69: my $selected=0;
70:
71: foreach (@$students) {
72: $Str .= '<option';
73: if($selectedName eq $_) {
74: $Str .= ' selected';
75: $selected = 1;
76: }
77: $Str .= '>';
78: $Str .= $cache->{$_.':fullname'};
79: $Str .= '</option>'."\n";
80: }
81:
82: $Str .= '<option';
83: if($selectedName eq 'No Student Selected') {
84: $Str .= ' selected';
85: $selected = 1;
86: }
87: $Str .= '>No Student Selected</option>'."\n";
88:
89: $Str .= '<option';
90: if(!$selected) {
91: $Str .= ' selected';
92: }
93: $Str .= '>All Students</option>'."\n";
94:
95: $Str .= '</select>'."\n";
96:
97: return $Str;
98: }
99:
100: sub StatusOptions {
101: my ($status, $formName)=@_;
102:
103: my $OpSel1 = '';
104: my $OpSel2 = '';
105: my $OpSel3 = '';
106:
107: if($status eq 'Any') { $OpSel3 = ' selected'; }
108: elsif($status eq 'Expired' ) { $OpSel2 = ' selected'; }
109: else { $OpSel1 = ' selected'; }
110:
111: my $Str = '';
112: $Str .= '<select name="Status"';
113: if(defined($formName) && $formName ne '') {
114: $Str .= ' onchange="document.'.$formName.'.submit()"';
115: }
116: $Str .= '>'."\n";
117: $Str .= '<option'.$OpSel1.'>Active</option>'."\n";
118: $Str .= '<option'.$OpSel2.'>Expired</option>'."\n";
119: $Str .= '<option'.$OpSel3.'>Any</option>'."\n";
120: $Str .= '</select>'."\n";
121: }
122:
123: sub MultipleSectionSelect {
124: my ($sections,$selectedSections)=@_;
125:
126: my $Str = '';
127: $Str .= '<select name="Section" multiple="" size="4">'."\n";
128:
129: foreach (@$sections) {
130: $Str .= '<option';
131: foreach my $selected (@$selectedSections) {
132: if($_ eq $selected) {
133: $Str .= ' selected=""';
134: }
135: }
136: $Str .= '>'.$_.'</option>'."\n";
137: }
138: $Str .= '</select>'."\n";
139:
140: return $Str;
141: }
142:
143: sub Title {
144: my ($pageName)=@_;
145:
146: my $Str = '';
147:
148: $Str .= '<html><head><title>'.$pageName.'</title></head>'."\n";
149: $Str .= '<body bgcolor="#FFFFFF">'."\n";
150: $Str .= '<script>window.focus(); window.width=500;window.height=500;';
151: $Str .= '</script>'."\n";
152: $Str .= '<table width="100%"><tr><td valign="top">';
153: $Str .= '<h1> Course: ';
154: $Str .= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
155: $Str .= '</h1></td><td align="right">'."\n";
156: $Str .= '<img align="right" src=/adm/lonIcons/lonlogos.gif>';
157: $Str .= '</td></tr></table>'."\n";
158:
159: return $Str;
160: }
161:
162: =pod
163:
164: =item &CreateTableHeadings()
165:
166: This function generates the column headings for the chart.
167:
168: =over 4
169:
170: Inputs: $CacheData, $keyID, $headings, $spacePadding
171:
172: $CacheData: pointer to a hash tied to the cached data database
173:
174: $keyID: a pointer to an array containing the names of the data
175: held in a column and is used as part of a key into $CacheData
176:
177: $headings: The names of the headings for the student information
178:
179: $spacePadding: The spaces to go between columns
180:
181: Output: $Str
182:
183: $Str: A formatted string of the table column headings.
184:
185: =back
186:
187: =cut
188:
189: sub CreateHeadings {
190: my ($data,$keyID,$headings,$displayString,$format)=@_;
191: my $Str='';
192: my $formatting = '';
193:
194: for(my $index=0; $index<(scalar @$headings); $index++) {
195: my $currentHeading=$headings->[$index];
196: if($format eq 'preformatted') {
197: my @dataLength=split(//,$currentHeading);
198: my $length=scalar @dataLength;
199: $formatting = (' 'x
200: ($data->{$keyID->[$index].':columnWidth'}-$length));
201: }
202: my $linkdata=$keyID->[$index];
203:
204: my $tempString = $displayString;
205: $tempString =~ s/LINKDATA/$linkdata/;
206: $tempString =~ s/DISPLAYDATA/$currentHeading/;
207: $tempString =~ s/FORMATTING/$formatting/;
208:
209: $Str .= $tempString;
210: }
211:
212: return $Str;
213: }
214:
215: =pod
216:
217: =item &FormatStudentInformation()
218:
219: This function produces a formatted string of the student's information:
220: username, domain, section, full name, and PID.
221:
222: =over 4
223:
224: Input: $cache, $name, $keyID, $spacePadding
225:
226: $cache: This is a pointer to a hash that is tied to the cached data
227:
228: $name: The name and domain of the current student in name:domain format
229:
230: $keyID: A pointer to an array holding the names used to
231:
232: remove data from the hash. They represent the name of the data to be removed.
233:
234: $spacePadding: Extra spaces that represent the space between columns
235:
236: Output: $Str
237:
238: $Str: Formatted string.
239:
240: =back
241:
242: =cut
243:
244: sub FormatStudentInformation {
245: my ($data,$name,$keyID,$displayString,$format)=@_;
246: my $Str='';
247: my $currentColumn;
248:
249: for(my $index=0; $index<(scalar @$keyID); $index++) {
250: $currentColumn=$data->{$name.':'.$keyID->[$index]};
251:
252: if($format eq 'preformatted') {
253: my @dataLength=split(//,$currentColumn);
254: my $length=scalar @dataLength;
255: $currentColumn.= (' 'x
256: ($data->{$keyID->[$index].':columnWidth'}-$length));
257: }
258:
259: my $tempString = $displayString;
260: $tempString =~ s/DISPLAYDATA/$currentColumn/;
261:
262: $Str .= $tempString;
263: }
264:
265: return $Str;
266: }
267:
268: 1;
269: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>