File:
[LON-CAPA] /
loncom /
interface /
lonhtmlcommon.pm
Revision
1.3:
download - view:
text,
annotated -
select for diffs
Wed Jul 24 14:52:32 2002 UTC (22 years, 1 month ago) by
stredwic
Branches:
MAIN
CVS tags:
HEAD
Broke lonstatistics up. Now the bulk of the code that generate the
html pages for the different forms have there own module. Some minor
modifications were necessary to accomplish this.
Also added default student selected on student assessment page is now
all students. The full name links on the classlist page now take
you to the student assessment page with that student selected. I
had forgotten to put the post data in the get_unprocessed_cgi
function call.
1: # The LearningOnline Network with CAPA
2: # a pile of common html routines
3: #
4: # $Id: lonhtmlcommon.pm,v 1.3 2002/07/24 14:52:32 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)=@_;
61:
62: my $Str = '';
63: $Str = '<select name="'.(($page)?$page:'').'Student">'."\n";
64:
65: my $selected=0;
66:
67: foreach (@$students) {
68: $Str .= '<option';
69: if($selectedName eq $_) {
70: $Str .= ' selected';
71: $selected = 1;
72: }
73: $Str .= '>';
74: $Str .= $cache->{$_.':fullname'};
75: $Str .= '</option>'."\n";
76: }
77:
78: $Str .= '<option';
79: if($selectedName eq 'No Student Selected') {
80: $Str .= ' selected';
81: $selected = 1;
82: }
83: $Str .= '>No Student Selected</option>'."\n";
84:
85: $Str .= '<option';
86: if(!$selected) {
87: $Str .= ' selected';
88: }
89: $Str .= '>All Students</option>'."\n";
90:
91: $Str .= '</select>'."\n";
92:
93: return $Str;
94: }
95:
96: sub StatusOptions {
97: my ($status, $formName)=@_;
98:
99: my $OpSel1 = '';
100: my $OpSel2 = '';
101: my $OpSel3 = '';
102:
103: if($status eq 'Any') { $OpSel3 = ' selected'; }
104: elsif($status eq 'Expired' ) { $OpSel2 = ' selected'; }
105: else { $OpSel1 = ' selected'; }
106:
107: my $Str = '';
108: $Str .= '<select name="Status"';
109: if(defined($formName) && $formName ne '') {
110: $Str .= ' onchange="document.'.$formName.'.submit()"';
111: }
112: $Str .= '>'."\n";
113: $Str .= '<option'.$OpSel1.'>Active</option>'."\n";
114: $Str .= '<option'.$OpSel2.'>Expired</option>'."\n";
115: $Str .= '<option'.$OpSel3.'>Any</option>'."\n";
116: $Str .= '</select>'."\n";
117: }
118:
119: sub Title {
120: my ($pageName)=@_;
121:
122: my $Str = '';
123:
124: $Str .= '<html><head><title>'.$pageName.'</title></head>'."\n";
125: $Str .= '<body bgcolor="#FFFFFF">'."\n";
126: $Str .= '<script>window.focus(); window.width=500;window.height=500;';
127: $Str .= '</script>'."\n";
128: $Str .= '<table width="100%"><tr><td valign="top">';
129: $Str .= '<h1> Course: ';
130: $Str .= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
131: $Str .= '</h1></td><td align="right">'."\n";
132: $Str .= '<img align="right" src=/adm/lonIcons/lonlogos.gif>';
133: $Str .= '</td></tr></table>'."\n";
134: # $Str .= '<h3>Current Time: '.localtime(time).'</h3><br><br><br>'."\n";
135:
136: return $Str;
137: }
138:
139: sub CreateStatisticsMainMenu {
140: my ($status, $reports)=@_;
141:
142: my $Str = '';
143:
144: $Str .= '<table border="0"><tbody><tr>'."\n";
145: $Str .= '<td></td><td></td>'."\n";
146: $Str .= '<td align="center"><b>Analysis Reports:</b></td>'."\n";
147: $Str .= '<td align="center"><b>Student Status:</b></td></tr>'."\n";
148: $Str .= '<tr>'."\n";
149: $Str .= '<td align="center"><input type="submit" name="Refresh" ';
150: $Str .= 'value="Refresh" /></td>'."\n";
151: $Str .= '<td align="center"><input type="submit" name="DownloadAll" ';
152: $Str .= 'value="Update All Student Data" /></td>'."\n";
153: $Str .= '<td align="center">';
154: $Str .= '<select name="reportSelected" onchange="document.';
155: $Str .= 'Statistics.submit()">'."\n";
156:
157: foreach (sort(keys(%$reports))) {
158: next if($_ eq 'reportSelected');
159: $Str .= '<option name="'.$_.'"';
160: if($reports->{'reportSelected'} eq $reports->{$_}) {
161: $Str .= ' selected=""';
162: }
163: $Str .= '>'.$reports->{$_}.'</option>'."\n";
164: }
165: $Str .= '</select></td>'."\n";
166:
167: $Str .= '<td align="center">';
168: $Str .= &StatusOptions($status, 'Statistics');
169: $Str .= '</td>'."\n";
170:
171: $Str .= '</tr></tbody></table>'."\n";
172: $Str .= '<hr>'."\n";
173:
174: return $Str;
175: }
176:
177: =pod
178:
179: =item &CreateTableHeadings()
180:
181: This function generates the column headings for the chart.
182:
183: =over 4
184:
185: Inputs: $CacheData, $studentInformation, $headings, $spacePadding
186:
187: $CacheData: pointer to a hash tied to the cached data database
188:
189: $studentInformation: a pointer to an array containing the names of the data
190: held in a column and is used as part of a key into $CacheData
191:
192: $headings: The names of the headings for the student information
193:
194: $spacePadding: The spaces to go between columns
195:
196: Output: $Str
197:
198: $Str: A formatted string of the table column headings.
199:
200: =back
201:
202: =cut
203:
204: sub CreateStudentInformationHeadings {
205: my ($data,$studentInformation,$headings,$displayString)=@_;
206: my $Str='';
207:
208: for(my $index=0; $index<(scalar @$headings); $index++) {
209: # if(!&ShouldShowColumn($data, 'ChartHeading'.$index)) {
210: # next;
211: # }
212: my $data=$headings->[$index];
213: my $linkdata=$studentInformation->[$index];
214: my $tempString = $displayString;
215: $tempString =~ s/LINKDATA/$linkdata/;
216: $tempString =~ s/DISPLAYDATA/$data/;
217: $Str .= $tempString;
218: }
219:
220: return $Str;
221: }
222:
223: =pod
224:
225: =item &FormatStudentInformation()
226:
227: This function produces a formatted string of the student's information:
228: username, domain, section, full name, and PID.
229:
230: =over 4
231:
232: Input: $cache, $name, $studentInformation, $spacePadding
233:
234: $cache: This is a pointer to a hash that is tied to the cached data
235:
236: $name: The name and domain of the current student in name:domain format
237:
238: $studentInformation: A pointer to an array holding the names used to
239:
240: remove data from the hash. They represent the name of the data to be removed.
241:
242: $spacePadding: Extra spaces that represent the space between columns
243:
244: Output: $Str
245:
246: $Str: Formatted string.
247:
248: =back
249:
250: =cut
251:
252: sub FormatStudentInformation {
253: my ($cache,$name,$studentInformation,$spacePadding)=@_;
254: my $Str='';
255: my $data;
256:
257: for(my $index=0; $index<(scalar @$studentInformation); $index++) {
258: if(!&ShouldShowColumn($cache, 'ChartHeading'.$index)) {
259: next;
260: }
261: $data=$cache->{$name.':'.$studentInformation->[$index]};
262: $Str .= $data;
263:
264: my @dataLength=split(//,$data);
265: my $length=scalar @dataLength;
266: $Str .= (' 'x($cache->{$studentInformation->[$index].'Length'}-
267: $length));
268: $Str .= $spacePadding;
269: }
270:
271: return $Str;
272: }
273:
274: 1;
275: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>