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