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