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