Annotation of loncom/interface/lonstatistics.pm, revision 1.47
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # (Publication Handler
3: #
1.47 ! www 4: # $Id: lonstatistics.pm,v 1.46 2002/08/14 20:42:48 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');
1.44 stredwic 85: &CheckFormElement($cache, 'StatisticsMaps',
86: 'StatisticsMaps', 'All Maps');
87: if(defined($ENV{'form.Section'})) {
88: my @sectionsSelected = (ref($ENV{'form.Section'}) ?
89: @{$ENV{'form.Section'}} :
90: ($ENV{'form.Section'}));
91: $cache->{'sectionsSelected'} = join(':', @sectionsSelected);
92: } elsif(!defined($cache->{'sectionsSelected'})) {
93: $cache->{'sectionsSelected'} = $cache->{'sectionList'};
94: }
1.29 stredwic 95:
1.38 stredwic 96: # student assessment
1.29 stredwic 97: if(defined($ENV{'form.CreateStudentAssessment'}) ||
98: defined($ENV{'form.NextStudent'}) ||
99: defined($ENV{'form.PreviousStudent'})) {
100: $cache->{'reportSelected'} = 'Student Assessment';
101: }
102: if(defined($ENV{'form.NextStudent'})) {
103: $cache->{'StudentAssessmentMove'} = 'next';
104: } elsif(defined($ENV{'form.PreviousStudent'})) {
105: $cache->{'StudentAssessmentMove'} = 'previous';
106: } else {
107: $cache->{'StudentAssessmentMove'} = 'selected';
108: }
109: &CheckFormElement($cache, 'StudentAssessmentStudent',
1.30 stredwic 110: 'StudentAssessmentStudent', 'All Students');
111: $cache->{'StudentAssessmentStudent'} =
112: &Apache::lonnet::unescape($cache->{'StudentAssessmentStudent'});
1.34 stredwic 113: &CheckFormElement($cache, 'DefaultColumns', 'DefaultColumns', 'false');
1.29 stredwic 114:
1.38 stredwic 115: # Problem analysis
116: &CheckFormElement($cache, 'Interval', 'Interval', '1');
117:
118: # ProblemStatistcs
119: &CheckFormElement($cache, 'DisplayCSVFormat',
120: 'DisplayFormat', 'Display Table Format');
121: &CheckFormElement($cache, 'ProblemStatisticsAscend',
122: 'ProblemStatisticsAscend', 'Ascending');
1.41 stredwic 123: &CheckFormElement($cache, 'ProblemStatisticsSort',
124: 'ProblemStatisticsSort', 'Homework Sets Order');
1.42 stredwic 125: &CheckFormElement($cache, 'DisplayLegend', 'DisplayLegend', 'Hide Legend');
1.45 stredwic 126: &CheckFormElement($cache, 'SortProblems', 'SortProblems',
127: 'Sort Within Sequence');
1.38 stredwic 128:
129: # Search only form elements
1.34 stredwic 130: my @headingColumns=();
131: my @sequenceColumns=();
132: my $foundColumn = 0;
133: if(defined($ENV{'form.ReselectColumns'})) {
134: my @reselected = (ref($ENV{'form.ReselectColumns'}) ?
135: @{$ENV{'form.ReselectColumns'}}
136: : ($ENV{'form.ReselectColumns'}));
137: foreach (@reselected) {
138: if(/HeadingColumn/) {
139: push(@headingColumns, $_);
140: $foundColumn = 1;
141: } elsif(/SequenceColumn/) {
142: push(@sequenceColumns, $_);
143: $foundColumn = 1;
144: }
145: }
146: }
147:
1.37 stredwic 148: $cache->{'reportKey'} = 'false';
149: if($cache->{'reportSelected'} eq 'Analyze') {
150: $cache->{'reportKey'} = 'Analyze';
1.38 stredwic 151: } elsif($cache->{'reportSelected'} eq 'DoDiffGraph') {
152: $cache->{'reportKey'} = 'DoDiffGraph';
153: } elsif($cache->{'reportSelected'} eq 'PercentWrongGraph') {
154: $cache->{'reportKey'} = 'PercentWrongGraph';
155: }
156:
157: if(defined($ENV{'form.DoDiffGraph'})) {
158: $cache->{'reportSelected'} = 'DoDiffGraph';
159: $cache->{'reportKey'} = 'DoDiffGraph';
160: } elsif(defined($ENV{'form.PercentWrongGraph'})) {
161: $cache->{'reportSelected'} = 'PercentWrongGraph';
162: $cache->{'reportKey'} = 'PercentWrongGraph';
1.37 stredwic 163: }
164:
1.29 stredwic 165: foreach (keys(%ENV)) {
1.37 stredwic 166: if(/form\.Analyze/) {
167: $cache->{'reportSelected'} = 'Analyze';
168: $cache->{'reportKey'} = 'Analyze';
169: my $data;
170: (undef, $data)=split(':::', $_);
171: $cache->{'AnalyzeInfo'}=$data;
1.34 stredwic 172: } elsif(/form\.HeadingColumn/) {
173: my $value = $_;
174: $value =~ s/form\.//;
175: push(@headingColumns, $value);
176: $foundColumn=1;
177: } elsif(/form\.SequenceColumn/) {
178: my $value = $_;
179: $value =~ s/form\.//;
180: push(@sequenceColumns, $value);
181: $foundColumn=1;
1.27 stredwic 182: }
1.29 stredwic 183: }
1.27 stredwic 184:
1.34 stredwic 185: if($foundColumn) {
186: $cache->{'HeadingsFound'} = join(':', @headingColumns);
187: $cache->{'SequencesFound'} = join(':', @sequenceColumns);;
188: }
189: if(!defined($cache->{'HeadingsFound'}) ||
190: $cache->{'DefaultColumns'} ne 'false') {
191: $cache->{'HeadingsFound'}='HeadingColumnFull Name';
192: }
193: if(!defined($cache->{'SequencesFound'}) ||
194: $cache->{'DefaultColumns'} ne 'false') {
195: $cache->{'SequencesFound'}='All Sequences';
196: }
197: $cache->{'DefaultColumns'} = 'false';
198:
1.29 stredwic 199: return;
1.27 stredwic 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 {
1.29 stredwic 228: my ($cache)=@_;
1.27 stredwic 229:
1.29 stredwic 230: my @students = split(':::',$cache->{'NamesOfStudents'});
1.27 stredwic 231: my @sorted1Students=();
1.29 stredwic 232: foreach (@students) {
233: if($cache->{'Status'} eq 'Any' ||
234: $cache->{$_.':Status'} eq $cache->{'Status'}) {
235: push(@sorted1Students, $_);
236: }
1.1 albertel 237: }
1.27 stredwic 238:
1.29 stredwic 239: my $sortBy = '';
240: if(defined($cache->{'sort'})) {
241: $sortBy = ':'.$cache->{'sort'};
1.27 stredwic 242: }
1.29 stredwic 243: my @order = sort { $cache->{$a.$sortBy} cmp $cache->{$b.$sortBy} ||
244: $cache->{$a.':fullname'} cmp $cache->{$b.':fullname'} }
245: @sorted1Students;
1.27 stredwic 246:
247: return \@order;
248: }
249:
1.32 stredwic 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:
1.27 stredwic 299: sub PrepareData {
1.38 stredwic 300: my ($c, $cacheDB, $studentInformation, $headings,$r)=@_;
1.27 stredwic 301:
302: # Test for access to the cache data
303: my $courseID=$ENV{'request.course.id'};
304: my $isRecalculate=0;
1.29 stredwic 305: if(defined($ENV{'form.Recalculate'})) {
1.27 stredwic 306: $isRecalculate=1;
307: }
308:
1.29 stredwic 309: my $isCached = &Apache::loncoursedata::TestCacheData($cacheDB,
310: $isRecalculate);
1.27 stredwic 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;
1.38 stredwic 317: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
1.29 stredwic 318: return "Unable to tie hash to db file.";
319: }
320:
1.27 stredwic 321: if(!$isCached) {
322: my $processTopResourceMapReturn=
1.38 stredwic 323: &Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c, $r);
1.27 stredwic 324: if($processTopResourceMapReturn ne 'OK') {
325: untie(%cache);
326: return $processTopResourceMapReturn;
327: }
1.29 stredwic 328: }
1.27 stredwic 329:
1.29 stredwic 330: if($c->aborted()) {
331: untie(%cache);
332: return 'aborted';
333: }
1.27 stredwic 334:
1.29 stredwic 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) {
1.27 stredwic 340: untie(%cache);
341: return "Error getting student data.";
342: }
1.29 stredwic 343: }
1.27 stredwic 344:
1.29 stredwic 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: }
1.27 stredwic 356:
1.29 stredwic 357: &ProcessFormData(\%cache);
358: my $students = &SortStudents(\%cache);
1.32 stredwic 359: &SpaceColumns($students, $studentInformation, $headings, \%cache);
360: $cache{'updateTime:columnWidth'}=24;
1.27 stredwic 361:
1.29 stredwic 362: if($cache{'download'} ne 'false') {
1.41 stredwic 363: my @who = ($cache{'download'});
1.29 stredwic 364: $cache{'download'} = 'false';
1.41 stredwic 365: if(&Apache::loncoursedata::DownloadStudentCourseData(\@who, 'false',
366: $cacheDB, 'true',
367: 'false', $courseID,
368: $r, $c) ne 'OK') {
369: untie(%cache);
370: return 'Stop at download individual';
371: }
1.29 stredwic 372: } elsif($cache{'DownloadAll'} ne 'false') {
1.39 stredwic 373: $cache{'DownloadAll'} = 'false';
1.29 stredwic 374: my @allStudents;
375: if($cache{'DownloadAll'} eq 'sorted') {
376: @allStudents = @$students;
377: } else {
378: @allStudents = split(':::', $cache{'NamesOfStudents'});
379: }
1.41 stredwic 380: if(&Apache::loncoursedata::DownloadStudentCourseData(\@allStudents,
381: 'false',
382: $cacheDB, 'true',
383: 'true', $courseID,
384: $r, $c) ne 'OK') {
385: untie(%cache);
386: return 'Stop at download all';
1.27 stredwic 387: }
1.29 stredwic 388: }
1.27 stredwic 389:
1.29 stredwic 390: if($c->aborted()) {
1.27 stredwic 391: untie(%cache);
1.29 stredwic 392: return 'aborted';
393: }
394:
395: untie(%cache);
396:
397: return ('OK', $students);
1.27 stredwic 398: }
399:
1.29 stredwic 400: sub BuildClasslist {
1.39 stredwic 401: my ($cacheDB,$students,$studentInformation,$headings,$r)=@_;
1.29 stredwic 402:
403: my %cache;
1.38 stredwic 404: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
1.29 stredwic 405: return '<html><body>Unable to tie database.</body></html>';
1.1 albertel 406: }
407:
1.29 stredwic 408: my $Str='';
409: $Str .= '<table border="0"><tr><td bgcolor="#777777">'."\n";
410: $Str .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n";
411:
412: my $displayString = '<td align="left"><a href="/adm/statistics?';
413: $displayString .= 'sort=LINKDATA">DISPLAYDATA </a></td>'."\n";
1.39 stredwic 414: $Str .= &Apache::lonhtmlcommon::CreateHeadings(\%cache,
415: $studentInformation,
1.32 stredwic 416: $headings, $displayString);
1.29 stredwic 417: $Str .= '</tr>'."\n";
1.39 stredwic 418:
1.29 stredwic 419: my $alternate=0;
420: foreach (@$students) {
421: my ($username, $domain) = split(':', $_);
422: if($alternate) {
1.32 stredwic 423: $Str .= '<tr bgcolor="#ffffe6">';
1.29 stredwic 424: } else {
1.32 stredwic 425: $Str .= '<tr bgcolor="#ffffc6">';
1.29 stredwic 426: }
427: $alternate = ($alternate + 1) % 2;
428: foreach my $data (@$studentInformation) {
1.32 stredwic 429: $Str .= '<td>';
1.29 stredwic 430: if($data eq 'fullname') {
431: $Str .= '<a href="/adm/statistics?reportSelected=';
1.30 stredwic 432: $Str .= &Apache::lonnet::escape('Student Assessment');
433: $Str .= '&StudentAssessmentStudent=';
434: $Str .= &Apache::lonnet::escape($cache{$_.':'.$data}).'">';
1.32 stredwic 435: $Str .= $cache{$_.':'.$data}.' ';
1.29 stredwic 436: $Str .= '</a>';
1.32 stredwic 437: } elsif($data eq 'updateTime') {
438: $Str .= '<a href="/adm/statistics?reportSelected=';
439: $Str .= &Apache::lonnet::escape('Class list');
440: $Str .= '&download='.$_.'">';
441: $Str .= $cache{$_.':'.$data}.' ';
442: $Str .= ' </a>';
443: } else {
444: $Str .= $cache{$_.':'.$data}.' ';
1.29 stredwic 445: }
446:
1.32 stredwic 447: $Str .= '</td>'."\n";
1.29 stredwic 448: }
1.1 albertel 449: }
1.29 stredwic 450:
1.32 stredwic 451: $Str .= '</tr>'."\n";
1.29 stredwic 452: $Str .= '</table></td></tr></table>'."\n";
1.39 stredwic 453: $r->print($Str);
454: $r->rflush();
1.29 stredwic 455:
1.27 stredwic 456: untie(%cache);
1.1 albertel 457:
1.39 stredwic 458: return;
1.1 albertel 459: }
460:
1.33 stredwic 461: sub CreateMainMenu {
462: my ($status, $reports)=@_;
463:
464: my $Str = '';
465:
466: $Str .= '<table border="0"><tbody><tr>'."\n";
467: $Str .= '<td></td><td></td>'."\n";
468: $Str .= '<td align="center"><b>Analysis Reports:</b></td>'."\n";
469: $Str .= '<td align="center"><b>Student Status:</b></td></tr>'."\n";
470: $Str .= '<tr>'."\n";
471: $Str .= '<td align="center"><input type="submit" name="Refresh" ';
472: $Str .= 'value="Refresh" /></td>'."\n";
473: $Str .= '<td align="center"><input type="submit" name="DownloadAll" ';
474: $Str .= 'value="Update All Student Data" /></td>'."\n";
475: $Str .= '<td align="center">';
476: $Str .= '<select name="reportSelected" onchange="document.';
477: $Str .= 'Statistics.submit()">'."\n";
478:
479: foreach (sort(keys(%$reports))) {
480: next if($_ eq 'reportSelected');
481: $Str .= '<option name="'.$_.'"';
482: if($reports->{'reportSelected'} eq $reports->{$_}) {
483: $Str .= ' selected=""';
484: }
485: $Str .= '>'.$reports->{$_}.'</option>'."\n";
486: }
487: $Str .= '</select></td>'."\n";
488:
489: $Str .= '<td align="center">';
490: $Str .= &Apache::lonhtmlcommon::StatusOptions($status, 'Statistics');
491: $Str .= '</td>'."\n";
492:
493: $Str .= '</tr></tbody></table>'."\n";
494: $Str .= '<hr>'."\n";
495:
496: return $Str;
497: }
498:
1.29 stredwic 499: sub BuildStatistics {
500: my ($r)=@_;
501:
502: my $c = $r->connection;
1.32 stredwic 503: my @studentInformation=('fullname','section','id','domain','username',
504: 'updateTime');
505: my @headings=('Full Name', 'Section', 'PID', 'Domain', 'User Name',
506: 'Last Updated');
507: my $spacing = ' ';
1.29 stredwic 508: my %reports = ('classlist' => 'Class list',
509: 'problem_statistics' => 'Problem Statistics',
510: 'student_assessment' => 'Student Assessment',
1.40 minaeibi 511: # 'activitylog' => 'Activity Log',
1.29 stredwic 512: 'reportSelected' => 'Class list');
1.27 stredwic 513:
514: my %cache;
1.29 stredwic 515: my $courseID=$ENV{'request.course.id'};
516: my $cacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
517: "_$ENV{'user.domain'}_$courseID\_statistics.db";
518:
1.47 ! www 519: $r->print(&Apache::lonhtmlcommon::Title('Course Statistics and Charts'));
1.41 stredwic 520:
1.32 stredwic 521: my ($returnValue, $students) = &PrepareData($c, $cacheDB,
522: \@studentInformation,
1.38 stredwic 523: \@headings,$r);
1.29 stredwic 524: if($returnValue ne 'OK') {
1.41 stredwic 525: $r->print($returnValue."\n".'</body></html>');
1.29 stredwic 526: return OK;
527: }
1.41 stredwic 528: if(!$c->aborted()) {
529: &Apache::loncoursedata::CheckForResidualDownload($cacheDB,
530: 'true', 'true',
531: $courseID,
532: $r, $c);
533: }
1.29 stredwic 534:
535: my $GoToPage;
1.38 stredwic 536: if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
1.29 stredwic 537: $GoToPage = $cache{'reportSelected'};
538: $reports{'reportSelected'} = $cache{'reportSelected'};
1.37 stredwic 539: if(defined($cache{'reportKey'}) &&
540: !exists($reports{$cache{'reportKey'}}) &&
541: $cache{'reportKey'} ne 'false') {
542: $reports{$cache{'reportKey'}} = $cache{'reportSelected'};
543: }
1.29 stredwic 544:
545: if(defined($cache{'OptionResponses'})) {
1.46 stredwic 546: $reports{'problem_analysis'} = 'Option Response Analysis';
1.29 stredwic 547: }
548:
549: $r->print('<form name="Statistics" ');
550: $r->print('method="post" action="/adm/statistics">');
1.33 stredwic 551: $r->print(&CreateMainMenu($cache{'Status'}, \%reports));
1.39 stredwic 552: $r->rflush();
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: &Apache::lonproblemstatistics::BuildProblemStatisticsPage($cacheDB,
563: $students,
564: $courseID,
1.36 minaeibi 565: $c,$r);
1.46 stredwic 566: } elsif($GoToPage eq 'Option Response Analysis') {
1.39 stredwic 567: &Apache::lonproblemanalysis::BuildProblemAnalysisPage($cacheDB, $r);
1.29 stredwic 568: } elsif($GoToPage eq 'Student Assessment') {
1.39 stredwic 569: &Apache::lonstudentassessment::BuildStudentAssessmentPage($cacheDB,
1.37 stredwic 570: $students,
571: $courseID,
572: 'Statistics',
573: \@headings,
574: $spacing,
575: \@studentInformation,
1.39 stredwic 576: $r, $c);
1.29 stredwic 577: } elsif($GoToPage eq 'Analyze') {
1.39 stredwic 578: &Apache::lonproblemanalysis::BuildAnalyzePage($cacheDB, $students,
579: $courseID, $r);
1.40 minaeibi 580: } elsif($GoToPage eq 'DoDiffGraph' || $GoToPage eq 'PercentWrongGraph') {
1.43 stredwic 581: my $courseDescription = $ENV{'course.'.$courseID.'.description'};
582: $courseDescription =~ s/\ /"_"/eg;
583: &Apache::lonproblemstatistics::BuildGraphicChart($GoToPage, $cacheDB,
584: $courseDescription,
1.45 stredwic 585: $students, $courseID,
586: $r, $c);
1.29 stredwic 587: } elsif($GoToPage eq 'Class list') {
1.39 stredwic 588: &BuildClasslist($cacheDB, $students, \@studentInformation,
589: \@headings, $r);
1.27 stredwic 590: }
591:
592: $r->print('</form>'."\n");
1.29 stredwic 593: $r->print("\n".'</body>'."\n".'</html>');
594: $r->rflush();
1.27 stredwic 595:
1.29 stredwic 596: return OK;
1.27 stredwic 597: }
1.1 albertel 598:
599: # ================================================================ Main Handler
600:
601: sub handler {
1.31 minaeibi 602: my $r=shift;
1.34 stredwic 603:
604: # $jr = $r;
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>