File:
[LON-CAPA] /
loncom /
interface /
lonhtmlcommon.pm
Revision
1.7:
download - view:
text,
annotated -
select for diffs
Tue Aug 13 00:37:18 2002 UTC (22 years ago) by
stredwic
Branches:
MAIN
CVS tags:
version_0_5_1,
version_0_5,
HEAD
First, added unescaping of $key in lond dump command.
Next, I added a new way to download student course data. There are now
two functions for storing data, DownloadStudentCourseData and
DownloadStudentCourseDataSeparate. These two functions base their running
on input parameters. The option parameters are whether or not to check
the date for downloading, whether or not to store all the dumped data or
extract out the data you want, whether or not to display a status window.
The extracting data parameter will be best utilized if someone adds in the
ability to send a list of what parameters are desired and perhaps some simple
commands to affect how that data is processed, like tries, sum would
sum record the sum of all the tries for a student. This is just an idea.
Currently, I have all the statistics modules using the extract ability.
This slightly increases in download time, but drastically reduces cache
size. Possible ideas include pushing the extract to the lond side with a
list of parameter/commands, or even downloading everything to a temp cache,
then extract the necessary data into the cache then removing the temp
cache. There are lots of other possibilities, which can change the download
time, cache size, and other factors. Now, only loncoursedata handles the
downloading of data to a hash.
lonstudentassessment was changed slightly to remove ' ' as a link if the
student actually hadn't attempted the problem.
lonproblemanalysis was updated for the new str2hash type functions. There
are a couple of (cludges/fixes) for it. Depending on whether or not the
str2hash type functions are changed, these may or may not need to be
updated.
lonproblemstatistics was drastically overhauled. Most of the processing
was removed. Now, it just does its few statistics functions and outputs
the table. Currently, I broke the graph, discussion column, and
discriminant factor columns. These will be fixed on the next commit soon.
There is also no caching done. This will also be remedied soon. The
problem that will need attention with caching is to know when to update
the statistics cached data when a student's course data is updated.
Lastly, I plan to add perhaps a toggle legend display button, another graph
button(percentage correct), a button to send the CSV format(not just display),
and add a toggle button for sorting within a sequence and sorting all
the problems.
Also, I changed the look and feel to be the same as the class list page.
Also, the displaying of sequence headers and child sequences are not
working. This will be fixed, but thought will be put into how best to
make it look and have a similiar fill for all the table combinations.
1: # The LearningOnline Network with CAPA
2: # a pile of common html routines
3: #
4: # $Id: lonhtmlcommon.pm,v 1.7 2002/08/13 00:37:18 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 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 .= '<body bgcolor="#FFFFFF">'."\n";
179: $Str .= '<script>window.focus(); window.width=500;window.height=500;';
180: $Str .= '</script>'."\n";
181: $Str .= '<table width="100%"><tr><td valign="top">';
182: $Str .= '<h1> Course: ';
183: $Str .= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
184: $Str .= '</h1></td><td align="right">'."\n";
185: $Str .= '<img align="right" src=/adm/lonIcons/lonlogos.gif>';
186: $Str .= '</td></tr></table>'."\n";
187:
188: return $Str;
189: }
190:
191: =pod
192:
193: =item &CreateTableHeadings()
194:
195: This function generates the column headings for the chart.
196:
197: =over 4
198:
199: Inputs: $CacheData, $keyID, $headings, $spacePadding
200:
201: $CacheData: pointer to a hash tied to the cached data database
202:
203: $keyID: a pointer to an array containing the names of the data
204: held in a column and is used as part of a key into $CacheData
205:
206: $headings: The names of the headings for the student information
207:
208: $spacePadding: The spaces to go between columns
209:
210: Output: $Str
211:
212: $Str: A formatted string of the table column headings.
213:
214: =back
215:
216: =cut
217:
218: sub CreateHeadings {
219: my ($data,$keyID,$headings,$displayString,$format)=@_;
220: my $Str='';
221: my $formatting = '';
222:
223: for(my $index=0; $index<(scalar @$headings); $index++) {
224: my $currentHeading=$headings->[$index];
225: if($format eq 'preformatted') {
226: my @dataLength=split(//,$currentHeading);
227: my $length=scalar @dataLength;
228: $formatting = (' 'x
229: ($data->{$keyID->[$index].':columnWidth'}-$length));
230: }
231: my $linkdata=$keyID->[$index];
232:
233: my $tempString = $displayString;
234: $tempString =~ s/LINKDATA/$linkdata/;
235: $tempString =~ s/DISPLAYDATA/$currentHeading/;
236: $tempString =~ s/FORMATTING/$formatting/;
237:
238: $Str .= $tempString;
239: }
240:
241: return $Str;
242: }
243:
244: =pod
245:
246: =item &FormatStudentInformation()
247:
248: This function produces a formatted string of the student's information:
249: username, domain, section, full name, and PID.
250:
251: =over 4
252:
253: Input: $cache, $name, $keyID, $spacePadding
254:
255: $cache: This is a pointer to a hash that is tied to the cached data
256:
257: $name: The name and domain of the current student in name:domain format
258:
259: $keyID: A pointer to an array holding the names used to
260:
261: remove data from the hash. They represent the name of the data to be removed.
262:
263: $spacePadding: Extra spaces that represent the space between columns
264:
265: Output: $Str
266:
267: $Str: Formatted string.
268:
269: =back
270:
271: =cut
272:
273: sub FormatStudentInformation {
274: my ($data,$name,$keyID,$displayString,$format)=@_;
275: my $Str='';
276: my $currentColumn;
277:
278: for(my $index=0; $index<(scalar @$keyID); $index++) {
279: $currentColumn=$data->{$name.':'.$keyID->[$index]};
280:
281: if($format eq 'preformatted') {
282: my @dataLength=split(//,$currentColumn);
283: my $length=scalar @dataLength;
284: $currentColumn.= (' 'x
285: ($data->{$keyID->[$index].':columnWidth'}-$length));
286: }
287:
288: my $tempString = $displayString;
289: $tempString =~ s/DISPLAYDATA/$currentColumn/;
290:
291: $Str .= $tempString;
292: }
293:
294: return $Str;
295: }
296:
297: # Create progress
298: sub Create_PrgWin {
299: my ($r, $title, $heading)=@_;
300: $r->print('<script>'.
301: "popwin=open(\'\',\'popwin\',\'width=400,height=100\');".
302: "popwin.document.writeln(\'<html><body bgcolor=\"#88DDFF\">".
303: "<title>$title</title>".
304: "<h4>$heading</h4>".
305: "<form name=popremain>".
306: "<input type=text size=35 name=remaining value=Starting></form>".
307: "</body></html>\');".
308: "popwin.document.close();".
309: "</script>");
310:
311: $r->rflush();
312: }
313:
314: # update progress
315: sub Update_PrgWin {
316: my ($displayString,$r)=@_;
317: $r->print('<script>popwin.document.popremain.remaining.value="'.
318: $displayString.'";</script>');
319: $r->rflush();
320: }
321:
322: # close Progress Line
323: sub Close_PrgWin {
324: my ($r)=@_;
325: $r->print('<script>popwin.close()</script>'."\n");
326: $r->rflush();
327: }
328:
329: 1;
330: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>