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