File:
[LON-CAPA] /
loncom /
interface /
lonstatistics.pm
Revision
1.34:
download - view:
text,
annotated -
select for diffs
Fri Jul 26 19:49:26 2002 UTC (21 years, 11 months ago) by
stredwic
Branches:
MAIN
CVS tags:
HEAD
Finished combining the chart and student assessment reports, except for
documentation. The grade information is displayed like the chart, but
has more of an interface like student assessment. Currently, all the
controls change onchange, except for student section and column
reselection multiselects. These will be updated whenever another
interface button submits a form.
1: # The LearningOnline Network with CAPA
2: # (Publication Handler
3: #
4: # $Id: lonstatistics.pm,v 1.34 2002/07/26 19:49:26 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: # (Navigate problems for statistical reports
29: # YEAR=2001
30: # 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
31: # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
32: # YEAR=2002
33: # 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
34: # 5/12,5/14,5/15,5/19,5/26,7/16,25/7 Behrouz Minaei
35: #
36: ###
37:
38: package Apache::lonstatistics;
39:
40: use strict;
41: use Apache::Constants qw(:common :http);
42: use Apache::lonnet();
43: use Apache::lonhomework;
44: use Apache::loncommon;
45: use Apache::loncoursedata;
46: use Apache::lonhtmlcommon;
47: use Apache::lonproblemanalysis;
48: use Apache::lonproblemstatistics;
49: use Apache::lonstudentassessment;
50: use Apache::lonchart;
51: use HTML::TokeParser;
52: use GDBM_File;
53:
54: #my $jr;
55:
56: sub CheckFormElement {
57: my ($cache, $ENVName, $cacheName, $default)=@_;
58:
59: if(defined($ENV{'form.'.$ENVName})) {
60: $cache->{$cacheName} = $ENV{'form.'.$ENVName};
61: } elsif(!defined($cache->{$cacheName})) {
62: $cache->{$cacheName} = $default;
63: }
64:
65: return;
66: }
67:
68: sub ProcessFormData{
69: my ($cache)=@_;
70:
71: $cache->{'reportKey'} = 'false';
72:
73: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
74: ['sort','download',
75: 'reportSelected',
76: 'StudentAssessmentStudent']);
77: &CheckFormElement($cache, 'Status', 'Status', 'Active');
78: &CheckFormElement($cache, 'postdata', 'reportSelected', 'Class list');
79: &CheckFormElement($cache, 'reportSelected', 'reportSelected',
80: 'Class list');
81: $cache->{'reportSelected'} =
82: &Apache::lonnet::unescape($cache->{'reportSelected'});
83: &CheckFormElement($cache, 'DownloadAll', 'DownloadAll', 'false');
84: &CheckFormElement($cache, 'sort', 'sort', 'fullname');
85: &CheckFormElement($cache, 'download', 'download', 'false');
86:
87: if(defined($ENV{'form.CreateStudentAssessment'}) ||
88: defined($ENV{'form.NextStudent'}) ||
89: defined($ENV{'form.PreviousStudent'})) {
90: $cache->{'reportSelected'} = 'Student Assessment';
91: }
92: if(defined($ENV{'form.NextStudent'})) {
93: $cache->{'StudentAssessmentMove'} = 'next';
94: } elsif(defined($ENV{'form.PreviousStudent'})) {
95: $cache->{'StudentAssessmentMove'} = 'previous';
96: } else {
97: $cache->{'StudentAssessmentMove'} = 'selected';
98: }
99: &CheckFormElement($cache, 'StudentAssessmentStudent',
100: 'StudentAssessmentStudent', 'All Students');
101: $cache->{'StudentAssessmentStudent'} =
102: &Apache::lonnet::unescape($cache->{'StudentAssessmentStudent'});
103: &CheckFormElement($cache, 'DefaultColumns', 'DefaultColumns', 'false');
104:
105: if(defined($ENV{'form.Section'})) {
106: my @sectionsSelected = (ref($ENV{'form.Section'}) ?
107: @{$ENV{'form.Section'}} :
108: ($ENV{'form.Section'}));
109: $cache->{'sectionsSelected'} = join(':', @sectionsSelected);
110: } elsif(!defined($cache->{'sectionsSelected'})) {
111: $cache->{'sectionsSelected'} = $cache->{'sectionList'};
112: }
113:
114: my @headingColumns=();
115: my @sequenceColumns=();
116: my $foundColumn = 0;
117: if(defined($ENV{'form.ReselectColumns'})) {
118: my @reselected = (ref($ENV{'form.ReselectColumns'}) ?
119: @{$ENV{'form.ReselectColumns'}}
120: : ($ENV{'form.ReselectColumns'}));
121: foreach (@reselected) {
122: if(/HeadingColumn/) {
123: push(@headingColumns, $_);
124: $foundColumn = 1;
125: } elsif(/SequenceColumn/) {
126: push(@sequenceColumns, $_);
127: $foundColumn = 1;
128: }
129: }
130: }
131:
132: foreach (keys(%ENV)) {
133: if(/form\.Analyze:::/) {
134: # $cache->{'reportSelected'} = 'Analyze';
135: # $cache->{'reportKey'} = 'Problem Analysis';
136: my ($uri, $title, $part, $problem);
137: (undef, $uri, $title, $part, $problem)=split(':::', $_);
138: $cache->{'AnalyzeURI'} = $uri;
139: $cache->{'AnalyzeTitle'} = $title;
140: $cache->{'AnalyzePart'} = $part;
141: $cache->{'AnalyzeProblem'} = $problem;
142:
143: &CheckFormElement($cache, 'Interval', 'Interval', '1');
144: } elsif(/form\.HeadingColumn/) {
145: my $value = $_;
146: $value =~ s/form\.//;
147: push(@headingColumns, $value);
148: $foundColumn=1;
149: } elsif(/form\.SequenceColumn/) {
150: my $value = $_;
151: $value =~ s/form\.//;
152: push(@sequenceColumns, $value);
153: $foundColumn=1;
154: }
155: }
156:
157: if($foundColumn) {
158: $cache->{'HeadingsFound'} = join(':', @headingColumns);
159: $cache->{'SequencesFound'} = join(':', @sequenceColumns);;
160: }
161: if(!defined($cache->{'HeadingsFound'}) ||
162: $cache->{'DefaultColumns'} ne 'false') {
163: $cache->{'HeadingsFound'}='HeadingColumnFull Name';
164: }
165: if(!defined($cache->{'SequencesFound'}) ||
166: $cache->{'DefaultColumns'} ne 'false') {
167: $cache->{'SequencesFound'}='All Sequences';
168: }
169: $cache->{'DefaultColumns'} = 'false';
170:
171: return;
172:
173: # Select page to display
174: if(defined($ENV{'form.ProblemStatistics'}) ||
175: defined($ENV{'form.ProblemStatisticsRecalculate'}) ||
176: defined($ENV{'form.DisplayCSVFormat'})) {
177: $cache->{'GoToPage'} = 'ProblemStatistics';
178: &CheckFormElement($cache, 'DisplayCSVFormat',
179: 'DisplayFormat', 'Display Table Format');
180: &CheckFormElement($cache, 'Ascend','ProblemStatisticsAscend',
181: 'Ascending');
182: &CheckFormElement($cache, 'Maps', 'ProblemStatisticsMap',
183: 'All Maps');
184: } elsif(defined($ENV{'form.ProblemAnalysis'})) {
185: $cache->{'GoToPage'} = 'ProblemAnalysis';
186: &CheckFormElement($cache, 'Interval', 'Interval', '1');
187: } elsif(defined($ENV{'form.DoDiffGraph'})) {
188: $cache->{'GoToPage'} = 'DoDiffGraph';
189: } elsif(defined($ENV{'form.PercentWrongGraph'})) {
190: $cache->{'GoToPage'} = 'PercentWrongGraph';
191: } elsif(defined($ENV{'form.ActivityLog'})) {
192: $cache->{'GoToPage'} = 'ActivityLog';
193: } else {
194: $cache->{'GoToPage'} = 'Menu';
195: }
196:
197: &CheckFormElement($cache, 'Status', 'Status', 'Active');
198:
199: return;
200: }
201:
202: =pod
203:
204: =item &SortStudents()
205:
206: Determines which students to display and in which order. Which are
207: displayed are determined by their status(active/expired). The order
208: is determined by the sort button pressed (default to username). The
209: type of sorting is username, lastname, or section.
210:
211: =over 4
212:
213: Input: $students, $CacheData
214:
215: $students: A array pointer to a list of students (username:domain)
216:
217: $CacheData: A pointer to the hash tied to the cached data
218:
219: Output: \@order
220:
221: @order: An ordered list of students (username:domain)
222:
223: =back
224:
225: =cut
226:
227: sub SortStudents {
228: my ($cache)=@_;
229:
230: my @students = split(':::',$cache->{'NamesOfStudents'});
231: my @sorted1Students=();
232: foreach (@students) {
233: if($cache->{'Status'} eq 'Any' ||
234: $cache->{$_.':Status'} eq $cache->{'Status'}) {
235: push(@sorted1Students, $_);
236: }
237: }
238:
239: my $sortBy = '';
240: if(defined($cache->{'sort'})) {
241: $sortBy = ':'.$cache->{'sort'};
242: }
243: my @order = sort { $cache->{$a.$sortBy} cmp $cache->{$b.$sortBy} ||
244: $cache->{$a.':fullname'} cmp $cache->{$b.':fullname'} }
245: @sorted1Students;
246:
247: return \@order;
248: }
249:
250: =pod
251:
252: =item &SpaceColumns()
253:
254: Determines the width of all the columns in the chart. It is based on
255: the max of the data for that column and its header.
256:
257: =over 4
258:
259: Input: $students, $studentInformation, $headings, $ChartDB
260:
261: $students: An array pointer to a list of students (username:domain)
262:
263: $studentInformatin: The type of data for the student information. It is
264: used as part of the key in $CacheData.
265:
266: $headings: The name of the student information columns.
267:
268: $ChartDB: The name of the cache database which is opened for read/write.
269:
270: Output: None - All data stored in cache.
271:
272: =back
273:
274: =cut
275:
276: sub SpaceColumns {
277: my ($students,$studentInformation,$headings,$cache)=@_;
278:
279: # Initialize Lengths
280: for(my $index=0; $index<(scalar @$headings); $index++) {
281: my @titleLength=split(//,$headings->[$index]);
282: $cache->{$studentInformation->[$index].':columnWidth'}=
283: scalar @titleLength;
284: }
285:
286: foreach my $name (@$students) {
287: foreach (@$studentInformation) {
288: my @dataLength=split(//,$cache->{$name.':'.$_});
289: my $length=(scalar @dataLength);
290: if($length > $cache->{$_.':columnWidth'}) {
291: $cache->{$_.':columnWidth'}=$length;
292: }
293: }
294: }
295:
296: return;
297: }
298:
299: sub PrepareData {
300: my ($c, $cacheDB, $studentInformation, $headings)=@_;
301:
302: # Test for access to the cache data
303: my $courseID=$ENV{'request.course.id'};
304: my $isRecalculate=0;
305: if(defined($ENV{'form.Recalculate'})) {
306: $isRecalculate=1;
307: }
308:
309: my $isCached = &Apache::loncoursedata::TestCacheData($cacheDB,
310: $isRecalculate);
311: if($isCached < 0) {
312: return "Unable to tie hash to db file.";
313: }
314:
315: # Download class list information if not using cached data
316: my %cache;
317: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
318: return "Unable to tie hash to db file.";
319: }
320:
321: if(!$isCached) {
322: my $processTopResourceMapReturn=
323: &Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c);
324: if($processTopResourceMapReturn ne 'OK') {
325: untie(%cache);
326: return $processTopResourceMapReturn;
327: }
328: }
329:
330: if($c->aborted()) {
331: untie(%cache);
332: return 'aborted';
333: }
334:
335: my $classlist=&Apache::loncoursedata::DownloadClasslist($courseID,
336: $cache{'ClasslistTimestamp'},
337: $c);
338: foreach (keys(%$classlist)) {
339: if(/^(con_lost|error|no_such_host)/i) {
340: untie(%cache);
341: return "Error getting student data.";
342: }
343: }
344:
345: if($c->aborted()) {
346: untie(%cache);
347: return 'aborted';
348: }
349:
350: # Active is a temporary solution, remember to change
351: Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c);
352: if($c->aborted()) {
353: untie(%cache);
354: return 'aborted';
355: }
356:
357: &ProcessFormData(\%cache);
358: my $students = &SortStudents(\%cache);
359: &SpaceColumns($students, $studentInformation, $headings, \%cache);
360: $cache{'updateTime:columnWidth'}=24;
361:
362: if($cache{'download'} ne 'false') {
363: my $who = $cache{'download'};
364: my $courseData =
365: &Apache::loncoursedata::DownloadCourseInformation(
366: $who, $courseID,
367: $cache{$who.':lastDownloadTime'});
368: &Apache::loncoursedata::ProcessStudentData(\%cache, $courseData, $who);
369: $cache{'download'} = 'false';
370: } elsif($cache{'DownloadAll'} ne 'false') {
371: my @allStudents;
372: if($cache{'DownloadAll'} eq 'sorted') {
373: @allStudents = @$students;
374: } else {
375: @allStudents = split(':::', $cache{'NamesOfStudents'});
376: }
377: foreach (@allStudents) {
378: my $courseData =
379: &Apache::loncoursedata::DownloadCourseInformation(
380: $_, $courseID,
381: $cache{$_.':lastDownloadTime'});
382: &Apache::loncoursedata::ProcessStudentData(\%cache, $courseData,
383: $_);
384: if($c->aborted()) {
385: untie(%cache);
386: return 'aborted';
387: }
388: }
389: $cache{'DownloadAll'} = 'false';
390: }
391:
392: if($c->aborted()) {
393: untie(%cache);
394: return 'aborted';
395: }
396:
397: untie(%cache);
398:
399: return ('OK', $students);
400: }
401:
402:
403: # Create progress
404: sub Create_PrgWin {
405: my ($r)=@_;
406: $r->print(<<ENDPOP);
407: <script>
408: popwin=open('','popwin','width=400,height=100');
409: popwin.document.writeln('<html><body bgcolor="#88DDFF">'+
410: '<title>LON-CAPA Statistics</title>'+
411: '<h4>Computation Progress</h4>'+
412: '<form name=popremain>'+
413: '<input type=text size=35 name=remaining value=Starting></form>'+
414: '</body></html>');
415: popwin.document.close();
416: </script>
417: ENDPOP
418:
419: $r->rflush();
420: }
421:
422: # update progress
423: sub Update_PrgWin {
424: my ($totalStudents,$index,$name,$r)=@_;
425: $r->print('<script>popwin.document.popremain.remaining.value="'.
426: 'Computing '.$index.'/'.$totalStudents.': '.
427: $name.'";</script>');
428: $r->rflush();
429: }
430:
431: # close Progress Line
432: sub Close_PrgWin {
433: my ($r)=@_;
434: $r->print('<script>popwin.close()</script>');
435: $r->rflush();
436: }
437:
438: # For loading the colored table for display or un-colored for print
439: sub setbgcolor {
440: my $PrintTable=shift;
441: my %color;
442: if ($PrintTable){
443: $color{"gb"}="#FFFFFF";
444: $color{"red"}="#FFFFFF";
445: $color{"yellow"}="#FFFFFF";
446: $color{"green"}="#FFFFFF";
447: $color{"purple"}="#FFFFFF";
448: } else {
449: $color{"gb"}="#DDFFFF";
450: $color{"red"}="#FFDDDD";
451: $color{"yellow"}="#EEFFCC";
452: $color{"green"}="#DDFFDD";
453: $color{"purple"}="#FFDDFF";
454: }
455:
456: return \%color;
457: }
458:
459: sub BuildClasslist {
460: my ($cacheDB,$students,$studentInformation,$headings)=@_;
461:
462: my %cache;
463: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
464: return '<html><body>Unable to tie database.</body></html>';
465: }
466:
467: my $Str='';
468: $Str .= '<table border="0"><tr><td bgcolor="#777777">'."\n";
469: $Str .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n";
470:
471: my $displayString = '<td align="left"><a href="/adm/statistics?';
472: $displayString .= 'sort=LINKDATA">DISPLAYDATA </a></td>'."\n";
473: $Str .= &Apache::lonhtmlcommon::CreateHeadings(\%cache, $studentInformation,
474: $headings, $displayString);
475: $Str .= '</tr>'."\n";
476: my $alternate=0;
477: foreach (@$students) {
478: my ($username, $domain) = split(':', $_);
479: if($alternate) {
480: $Str .= '<tr bgcolor="#ffffe6">';
481: } else {
482: $Str .= '<tr bgcolor="#ffffc6">';
483: }
484: $alternate = ($alternate + 1) % 2;
485: foreach my $data (@$studentInformation) {
486: $Str .= '<td>';
487: if($data eq 'fullname') {
488: $Str .= '<a href="/adm/statistics?reportSelected=';
489: $Str .= &Apache::lonnet::escape('Student Assessment');
490: $Str .= '&StudentAssessmentStudent=';
491: $Str .= &Apache::lonnet::escape($cache{$_.':'.$data}).'">';
492: $Str .= $cache{$_.':'.$data}.' ';
493: $Str .= '</a>';
494: } elsif($data eq 'updateTime') {
495: $Str .= '<a href="/adm/statistics?reportSelected=';
496: $Str .= &Apache::lonnet::escape('Class list');
497: $Str .= '&download='.$_.'">';
498: $Str .= $cache{$_.':'.$data}.' ';
499: $Str .= ' </a>';
500: } else {
501: $Str .= $cache{$_.':'.$data}.' ';
502: }
503:
504: $Str .= '</td>'."\n";
505: }
506: }
507:
508: $Str .= '</tr>'."\n";
509: $Str .= '</table></td></tr></table>'."\n";
510:
511: untie(%cache);
512:
513: return $Str;
514: }
515:
516: sub CreateMainMenu {
517: my ($status, $reports)=@_;
518:
519: my $Str = '';
520:
521: $Str .= '<table border="0"><tbody><tr>'."\n";
522: $Str .= '<td></td><td></td>'."\n";
523: $Str .= '<td align="center"><b>Analysis Reports:</b></td>'."\n";
524: $Str .= '<td align="center"><b>Student Status:</b></td></tr>'."\n";
525: $Str .= '<tr>'."\n";
526: $Str .= '<td align="center"><input type="submit" name="Refresh" ';
527: $Str .= 'value="Refresh" /></td>'."\n";
528: $Str .= '<td align="center"><input type="submit" name="DownloadAll" ';
529: $Str .= 'value="Update All Student Data" /></td>'."\n";
530: $Str .= '<td align="center">';
531: $Str .= '<select name="reportSelected" onchange="document.';
532: $Str .= 'Statistics.submit()">'."\n";
533:
534: foreach (sort(keys(%$reports))) {
535: next if($_ eq 'reportSelected');
536: $Str .= '<option name="'.$_.'"';
537: if($reports->{'reportSelected'} eq $reports->{$_}) {
538: $Str .= ' selected=""';
539: }
540: $Str .= '>'.$reports->{$_}.'</option>'."\n";
541: }
542: $Str .= '</select></td>'."\n";
543:
544: $Str .= '<td align="center">';
545: $Str .= &Apache::lonhtmlcommon::StatusOptions($status, 'Statistics');
546: $Str .= '</td>'."\n";
547:
548: $Str .= '</tr></tbody></table>'."\n";
549: $Str .= '<hr>'."\n";
550:
551: return $Str;
552: }
553:
554: sub BuildStatistics {
555: my ($r)=@_;
556:
557: my $c = $r->connection;
558: my @studentInformation=('fullname','section','id','domain','username',
559: 'updateTime');
560: my @headings=('Full Name', 'Section', 'PID', 'Domain', 'User Name',
561: 'Last Updated');
562: my $spacing = ' ';
563: my %reports = ('classlist' => 'Class list',
564: 'problem_statistics' => 'Problem Statistics',
565: 'student_assessment' => 'Student Assessment',
566: 'reportSelected' => 'Class list');
567:
568: my %cache;
569: my $courseID=$ENV{'request.course.id'};
570: my $cacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
571: "_$ENV{'user.domain'}_$courseID\_statistics.db";
572:
573: my %color=&setbgcolor(0);
574: my ($returnValue, $students) = &PrepareData($c, $cacheDB,
575: \@studentInformation,
576: \@headings);
577: if($returnValue ne 'OK') {
578: $r->print('<html><body>'.$returnValue."\n".'</body></html>');
579: return OK;
580: }
581:
582: my $GoToPage;
583: if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
584: $GoToPage = $cache{'reportSelected'};
585: $reports{'reportSelected'} = $cache{'reportSelected'};
586: # if(defined($cache{'reportKey'}) && $cache{'reportKey'} ne 'false') {
587: # $reports{$cache{'reportKey'}} = $cache{'reportSelected'};
588: # }
589:
590: if(defined($cache{'OptionResponses'})) {
591: $reports{'problem_analysis'} = 'Problem Analysis';
592: }
593:
594: $r->print(&Apache::lonhtmlcommon::Title('LON-CAPA Statistics'));
595: $r->print('<form name="Statistics" ');
596: $r->print('method="post" action="/adm/statistics">');
597: $r->print(&CreateMainMenu($cache{'Status'}, \%reports));
598: untie(%cache);
599: } else {
600: $r->print('<html><body>Unable to tie database.</body></html>');
601: return OK;
602: }
603:
604: if($GoToPage eq 'Activity Log') {
605: &Apache::lonproblemstatistics::Activity();
606: } elsif($GoToPage eq 'Problem Statistics') {
607: $r->print(
608: &Apache::lonproblemstatistics::BuildProblemStatisticsPage($cacheDB,
609: $students,
610: $courseID,
611: $c,$r,
612: \%color));
613: } elsif($GoToPage eq 'Problem Analysis') {
614: $r->print(
615: &Apache::lonproblemanalysis::BuildProblemAnalysisPage($cacheDB));
616: } elsif($GoToPage eq 'Student Assessment') {
617: $r->print(
618: &Apache::lonstudentassessment::BuildStudentAssessmentPage($cacheDB,
619: $students,
620: $courseID,
621: 'Statistics',
622: \@headings,
623: $spacing,
624: \@studentInformation,
625: $r, $c));
626: } elsif($GoToPage eq 'Analyze') {
627: $r->print(&Apache::lonproblemanalysis::BuildAnalyzePage($cacheDB,
628: $students,
629: $courseID));
630: } elsif($GoToPage eq 'DoDiffGraph') {
631: &Apache::lonproblemstatistics::BuildDiffGraph($r);
632: } elsif($GoToPage eq 'PercentWrongGraph') {
633: &Apache::lonproblemstatistics::BuildWrongGraph($r);
634: } elsif($GoToPage eq 'Class list') {
635: $r->print(&BuildClasslist($cacheDB, $students, \@studentInformation,
636: \@headings));
637: }
638:
639: $r->print('</form>'."\n");
640: $r->print("\n".'</body>'."\n".'</html>');
641: $r->rflush();
642:
643: return OK;
644: }
645:
646: # ================================================================ Main Handler
647:
648: sub handler {
649: my $r=shift;
650:
651: # $jr = $r;
652:
653: unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
654: $ENV{'user.error.msg'}=
655: $r->uri.":vgr:0:0:Cannot view grades for complete course";
656: return HTTP_NOT_ACCEPTABLE;
657: }
658:
659: # Set document type for header only
660: if($r->header_only) {
661: if ($ENV{'browser.mathml'}) {
662: $r->content_type('text/xml');
663: } else {
664: $r->content_type('text/html');
665: }
666: &Apache::loncommon::no_cache($r);
667: $r->send_http_header;
668: return OK;
669: }
670:
671: unless($ENV{'request.course.fn'}) {
672: my $requrl=$r->uri;
673: $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
674: return HTTP_NOT_ACCEPTABLE;
675: }
676:
677: $r->content_type('text/html');
678: $r->send_http_header;
679:
680: &BuildStatistics($r);
681:
682: return OK;
683: }
684: 1;
685: __END__
686:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>