Annotation of loncom/interface/lonstatistics.pm, revision 1.134

1.1       albertel    1: # The LearningOnline Network with CAPA
                      2: #
1.134   ! raeburn     3: # $Id: lonstatistics.pm,v 1.133 2006/05/09 14:38:10 albertel Exp $
1.1       albertel    4: #
                      5: # Copyright Michigan State University Board of Trustees
                      6: #
                      7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      8: #
                      9: # LON-CAPA is free software; you can redistribute it and/or modify
                     10: # it under the terms of the GNU General Public License as published by
                     11: # the Free Software Foundation; either version 2 of the License, or
                     12: # (at your option) any later version.
                     13: #
                     14: # LON-CAPA is distributed in the hope that it will be useful,
                     15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17: # GNU General Public License for more details.
                     18: #
                     19: # You should have received a copy of the GNU General Public License
                     20: # along with LON-CAPA; if not, write to the Free Software
                     21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     22: #
                     23: # /home/httpd/html/adm/gpl.txt
                     24: #
                     25: # http://www.lon-capa.org/
                     26: #
                     27: # (Navigate problems for statistical reports
1.14      minaeibi   28: #
1.1       albertel   29: ###
                     30: 
1.59      matthew    31: =pod
                     32: 
                     33: =head1 NAME
                     34: 
                     35: lonstatistics
                     36: 
                     37: =head1 SYNOPSIS
                     38: 
                     39: Main handler for statistics and chart.
                     40: 
                     41: =over 4
                     42: 
                     43: =cut
                     44: 
1.55      minaeibi   45: package Apache::lonstatistics;
1.1       albertel   46: 
1.30      stredwic   47: use strict;
1.1       albertel   48: use Apache::Constants qw(:common :http);
1.61      matthew    49: use vars qw(
                     50:     @FullClasslist 
                     51:     @Students
1.130     raeburn    52:     @Sections
                     53:     @Groups 
1.61      matthew    54:     %StudentData
                     55:     @StudentDataOrder
                     56:     @SelectedStudentData
1.94      matthew    57:     $enrollment_status);
1.61      matthew    58: 
1.123     albertel   59: use Apache::lonnet;
1.1       albertel   60: use Apache::lonhomework;
1.12      minaeibi   61: use Apache::loncommon;
1.29      stredwic   62: use Apache::loncoursedata;
                     63: use Apache::lonhtmlcommon;
1.97      matthew    64: use Apache::lonmysql;
                     65: use Apache::lonlocal;
                     66: use Time::HiRes;
                     67: #
                     68: # Statistics Packages
1.61      matthew    69: use Apache::lonproblemanalysis();
1.89      matthew    70: use Apache::lonsubmissiontimeanalysis();
1.94      matthew    71: use Apache::loncorrectproblemplot();
1.61      matthew    72: use Apache::lonproblemstatistics();
                     73: use Apache::lonstudentassessment();
1.49      stredwic   74: use Apache::lonpercentage;
1.97      matthew    75: use Apache::lonstudentsubmissions();
1.104     matthew    76: use Apache::lonsurveyreports();
1.128     albertel   77: use Apache::longradinganalysis();
1.60      matthew    78: 
                     79: #######################################################
                     80: #######################################################
                     81: 
                     82: =pod
                     83: 
                     84: =item Package Variables
                     85: 
                     86: =item @FullClasslist The full classlist
                     87: 
                     88: =item @Students The students we are concerned with for this invocation
                     89: 
                     90: =item @Sections The sections available in this class
                     91: 
1.130     raeburn    92: =item @Groups The groups available in the class
                     93: 
1.60      matthew    94: =item $curr_student The student currently being examined
                     95: 
                     96: =item $prev_student The student previous in the classlist
                     97: 
                     98: =item $next_student The student next in the classlist
                     99: 
                    100: =over
                    101: 
                    102: =cut 
                    103: 
                    104: #######################################################
                    105: #######################################################
                    106: #
                    107: # Classlist variables
                    108: #
1.59      matthew   109: my $curr_student;
                    110: my $prev_student;
                    111: my $next_student;
                    112: 
                    113: #######################################################
                    114: #######################################################
                    115: 
                    116: =pod
                    117: 
                    118: =item &clear_classlist_variables()
                    119: 
                    120: undef the following package variables:
                    121: 
                    122: =over
                    123: 
1.60      matthew   124: =item @FullClasslist
                    125: 
                    126: =item @Students
1.59      matthew   127: 
1.60      matthew   128: =item @Sections
1.59      matthew   129: 
1.130     raeburn   130: =item @Groups
                    131: 
1.61      matthew   132: =item %StudentData
                    133: 
                    134: =item @StudentDataOrder
                    135: 
                    136: =item @SelectedStudentData
                    137: 
1.60      matthew   138: =item $curr_student
1.59      matthew   139: 
1.60      matthew   140: =item $prev_student
1.59      matthew   141: 
1.60      matthew   142: =item $next_student
1.59      matthew   143: 
                    144: =back
                    145: 
                    146: =cut
                    147: 
                    148: #######################################################
                    149: #######################################################
                    150: sub clear_classlist_variables {
                    151:     undef(@FullClasslist);
                    152:     undef(@Students);
                    153:     undef(@Sections);
1.130     raeburn   154:     undef(@Groups);
1.61      matthew   155:     undef(%StudentData);
                    156:     undef(@SelectedStudentData);
1.59      matthew   157:     undef($curr_student);
                    158:     undef($prev_student);
                    159:     undef($next_student);
                    160: }
                    161: 
                    162: #######################################################
                    163: #######################################################
                    164: 
                    165: =pod
                    166: 
                    167: =item &PrepareClasslist()
                    168: 
                    169: Build up the classlist information.  The classlist information is kept in
                    170: the following package variables:
                    171: 
                    172: =over
                    173: 
1.60      matthew   174: =item @FullClasslist
                    175: 
                    176: =item @Students
1.59      matthew   177: 
1.60      matthew   178: =item @Sections
1.59      matthew   179: 
1.130     raeburn   180: =item @Groups 
                    181: 
1.61      matthew   182: =item %StudentData
                    183: 
                    184: =item @SelectedStudentData
                    185: 
1.60      matthew   186: =item $curr_student
1.59      matthew   187: 
1.60      matthew   188: =item $prev_student
1.59      matthew   189: 
1.60      matthew   190: =item $next_student
1.59      matthew   191: 
                    192: =back
                    193: 
                    194: $curr_student, $prev_student, and $next_student may not be defined, depending
                    195: upon the calling context.
                    196: 
                    197: =cut
                    198: 
                    199: #######################################################
                    200: #######################################################
                    201: sub PrepareClasslist {
                    202:     my %Sections;
                    203:     &clear_classlist_variables();
                    204:     #
                    205:     # Retrieve the classlist
1.123     albertel  206:     my $cid  = $env{'request.course.id'};
                    207:     my $cdom = $env{'course.'.$cid.'.domain'};
                    208:     my $cnum = $env{'course.'.$cid.'.num'};
1.125     albertel  209:     my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cdom,
                    210: 									$cnum);
1.119     matthew   211:     my @selected_sections = &get_selected_sections();
1.130     raeburn   212:     my @selected_groups = &get_selected_groups();
1.61      matthew   213:     #
1.69      matthew   214:     # Deal with instructors with restricted section access
1.123     albertel  215:     if ($env{'request.course.sec'} !~ /^\s*$/) {
                    216:         @selected_sections = ($env{'request.course.sec'});
1.69      matthew   217:     }
                    218:     #
1.61      matthew   219:     # Set up %StudentData
1.130     raeburn   220:     @StudentDataOrder = qw/fullname username domain id section status groups comments/;
1.61      matthew   221:     foreach my $field (@StudentDataOrder) {
1.108     matthew   222:         $StudentData{$field}->{'title'} = &mt($field);
                    223:         $StudentData{$field}->{'base_width'} = length(&mt($field));
1.61      matthew   224:         $StudentData{$field}->{'width'} = 
                    225:                                $StudentData{$field}->{'base_width'};
                    226:     }
1.59      matthew   227:     #
1.68      matthew   228:     # get the status requested
1.94      matthew   229:     $enrollment_status = 'Active';
1.123     albertel  230:     $enrollment_status = $env{'form.Status'} if (exists($env{'form.Status'}));
1.68      matthew   231:     #
1.130     raeburn   232:     # Get groupmembership
1.133     albertel  233:     my ($classgroups,$studentgroups);
                    234:     my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
                    235:     if (%curr_groups) {
1.130     raeburn   236:         ($classgroups,$studentgroups) = 
1.133     albertel  237: 	    &Apache::loncoursedata::get_group_memberships($classlist,
1.134   ! raeburn   238:                                                           $field_names,
1.133     albertel  239: 							  $cdom,$cnum);
1.130     raeburn   240:     }
                    241:     my $now = time;
                    242: 
1.59      matthew   243:     # Process the classlist
                    244:     while (my ($student,$student_data) = each (%$classlist)) {
                    245:         my $studenthash = ();
                    246:         for (my $i=0; $i< scalar(@$field_names);$i++) {
1.61      matthew   247:             my $field = $field_names->[$i];
                    248:             # Store the data
                    249:             $studenthash->{$field}=$student_data->[$i];
                    250:             # Keep track of the width of the fields
                    251:             next if (! exists($StudentData{$field}));
1.63      matthew   252:             my $length = length($student_data->[$i]);
1.61      matthew   253:             if ($StudentData{$field}->{'width'} < $length) {
                    254:                 $StudentData{$field}->{'width'} = $length; 
                    255:             }
1.59      matthew   256:         }
1.130     raeburn   257:         my @studentsgroups = &Apache::loncoursedata::get_students_groups
                    258:                                                    ($student,$enrollment_status,
                    259:                                                     $classgroups);
                    260:         if (@studentsgroups) {
                    261:             $studenthash->{'groups'} = join(', ',@studentsgroups);
                    262:             $studenthash->{'groupref'} = \@studentsgroups;
                    263:         } else {
                    264:             $studenthash->{'groups'} = 'none';
                    265:             $studenthash->{'groupref'} = []; 
                    266:         }
1.59      matthew   267:         push (@FullClasslist,$studenthash);
                    268:         #
                    269:         # Build up a list of sections
                    270:         my $section = $studenthash->{'section'};
1.60      matthew   271:         if (! defined($section) || $section =~/^\s*$/ || $section == -1) {
                    272:             $studenthash->{'section'} = 'none';
                    273:             $section = $studenthash->{'section'};
                    274:         }
1.59      matthew   275:         $Sections{$section}++;
                    276:         #
                    277:         # Only put in the list those students we are interested in
1.119     matthew   278:         foreach my $sect (@selected_sections) {
1.68      matthew   279:             if ( (($sect eq 'all') || 
                    280:                   ($section eq $sect)) &&
1.94      matthew   281:                  (($studenthash->{'status'} eq $enrollment_status) || 
                    282:                   ($enrollment_status eq 'Any')) 
1.68      matthew   283:                  ){
1.130     raeburn   284:                 my $groupcheck = 0;
1.131     albertel  285:                 if (grep(/^all$/,@selected_groups)) {
                    286:                     push(@Students,$studenthash);
1.130     raeburn   287:                     last;
1.131     albertel  288:                 } elsif (grep(/^none$/,@selected_groups)) {
1.130     raeburn   289:                     if ($studenthash->{'groups'} eq 'none') {
1.131     albertel  290:                         push(@Students,$studenthash);
1.130     raeburn   291:                         last;
                    292:                     }     
                    293:                 } else {
                    294:                     foreach my $group (@selected_groups) {
1.131     albertel  295:                         if (grep(/^$group$/,@studentsgroups)) {
                    296:                             push(@Students,$studenthash);
1.130     raeburn   297:                             $groupcheck = 1;
                    298:                             last;
                    299:                         }
                    300:                     }
                    301:                     if ($groupcheck) {
                    302:                         last;
                    303:                     }
                    304:                 }
1.60      matthew   305:             }
1.59      matthew   306:         }
                    307:     }
                    308:     #
                    309:     # Put the consolidated section data in the right place
1.123     albertel  310:     if ($env{'request.course.sec'} !~ /^\s*$/) {
                    311:         @Sections = ($env{'request.course.sec'});
1.69      matthew   312:     } else {
                    313:         @Sections = sort {$a cmp $b} keys(%Sections);
                    314:         unshift(@Sections,'all'); # Put 'all' at the front of the list
                    315:     }
1.130     raeburn   316:     # Sort the groups
                    317:     @Groups = sort {$a cmp $b} keys(%{$studentgroups});
                    318:     unshift(@Groups,'all'); # Put 'all' at the front of the list
                    319: 
1.59      matthew   320:     #
                    321:     # Sort the Students
                    322:     my $sortby = 'fullname';
1.123     albertel  323:     $sortby = $env{'form.sort'} if (exists($env{'form.sort'}));
1.127     albertel  324:     my @TmpStudents = sort { lc($a->{$sortby}) cmp lc($b->{$sortby}) ||
1.126     albertel  325:                              lc($a->{'fullname'}) cmp lc($b->{'fullname'}) ||
                    326: 			     lc($a->{'username'}) cmp lc($b->{'username'}) } @Students;
1.60      matthew   327:     @Students = @TmpStudents;
1.59      matthew   328:     # 
                    329:     # Now deal with that current student thing....
1.72      matthew   330:     $curr_student = undef;
1.123     albertel  331:     if (exists($env{'form.SelectedStudent'})) {
1.59      matthew   332:         my ($current_uname,$current_dom) = 
1.123     albertel  333:             split(':',$env{'form.SelectedStudent'});
1.59      matthew   334:         my $i;
                    335:         for ($i = 0; $i<=$#Students; $i++) {
                    336:             next if (($Students[$i]->{'username'} ne $current_uname) || 
                    337:                      ($Students[$i]->{'domain'}   ne $current_dom));
1.60      matthew   338:             $curr_student = $Students[$i];
1.59      matthew   339:             last; # If we get here, we have our student.
                    340:         }
1.72      matthew   341:         if (defined($curr_student)) {
                    342:             if ($i == 0) {
                    343:                 $prev_student = undef;
                    344:             } else {
                    345:                 $prev_student = $Students[$i-1];
                    346:             }
                    347:             if ($i == $#Students) {
                    348:                 $next_student = undef;
                    349:             } else {
                    350:                 $next_student = $Students[$i+1];
                    351:             }
1.59      matthew   352:         }
                    353:     }
1.61      matthew   354:     #
1.123     albertel  355:     if (exists($env{'form.StudentData'})) {
1.124     albertel  356: 	@SelectedStudentData = 
                    357: 	    &Apache::loncommon::get_env_multiple('form.StudentData');
1.61      matthew   358:     } else {
1.72      matthew   359:         @SelectedStudentData = ('username');
1.61      matthew   360:     }
                    361:     foreach (@SelectedStudentData) {
                    362:         if ($_ eq 'all') {
                    363:             @SelectedStudentData = ('all');
                    364:             last;
                    365:         }
                    366:     }
                    367:     #
                    368:     return;
                    369: }
                    370: 
1.119     matthew   371: #######################################################
                    372: #######################################################
                    373: 
                    374: =pod
                    375: 
                    376: =item get_selected_sections
                    377: 
                    378: Returns an array of the selected sections
                    379: 
                    380: =cut
                    381: 
                    382: #######################################################
                    383: #######################################################
                    384: sub get_selected_sections {
1.124     albertel  385:     my @selected_sections = 
                    386: 	&Apache::loncommon::get_env_multiple('form.Section');
1.119     matthew   387:     @selected_sections = ('all') if (! @selected_sections);
                    388:     foreach (@selected_sections) {
                    389:         if ($_ eq 'all') {
                    390:             @selected_sections = ('all');
                    391:         }
                    392:     }
                    393:     #
                    394:     # Deal with instructors with restricted section access
1.123     albertel  395:     if ($env{'request.course.sec'} !~ /^\s*$/) {
                    396:         @selected_sections = ($env{'request.course.sec'});
1.119     matthew   397:     }
                    398:     return @selected_sections;
                    399: }
                    400: 
                    401: #######################################################
                    402: #######################################################
1.130     raeburn   403:                                                                                     
                    404: =pod
                    405:                                                                                     
                    406: =item get_selected_groups
                    407:                                                                                     
                    408: Returns an array of the selected groups
                    409:                                                                                     
                    410: =cut
                    411:                                                                                     
                    412: #######################################################
                    413: #######################################################
                    414: sub get_selected_groups {
                    415:     my @selected_groups =
                    416:         &Apache::loncommon::get_env_multiple('form.Group');
                    417:     @selected_groups = ('all') if (! @selected_groups);
                    418:     foreach my $grp (@selected_groups) {
                    419:         if ($grp eq 'all') {
                    420:             @selected_groups = ('all');
                    421:             last;
                    422:         }
                    423:     }
                    424:     return @selected_groups;
                    425: }
                    426:                                                                                     
1.119     matthew   427: =pod
                    428: 
                    429: =item &section_and_enrollment_description
                    430: 
1.130     raeburn   431: Returns a string describing the currently selected section(s), group(s) and 
1.122     matthew   432: enrollment status.  
                    433: 
                    434: Inputs: mode = 'plaintext' or 'localized'  (defaults to 'localized')
                    435:     'plaintext' is used for example in Excel spreadsheets.
                    436: Returns: scalar description string.
                    437: 
1.119     matthew   438: =cut
                    439: 
                    440: #######################################################
                    441: #######################################################
                    442: sub section_and_enrollment_description {
1.122     matthew   443:     my ($mode) = @_;
                    444:     if (! defined($mode)) { $mode = 'localized'; }
1.119     matthew   445:     my @sections = &Apache::lonstatistics::get_selected_sections();
1.130     raeburn   446:     my @groups = &Apache::lonstatistics::get_selected_groups();
1.122     matthew   447:     my $description;
                    448:     if ($mode eq 'localized') {
1.130     raeburn   449:         $description = &mt('Unable to determine section, groups and enrollment');
1.122     matthew   450:     } elsif ($mode eq 'plaintext') {
1.130     raeburn   451:         $description = 'Unable to determine section, groups and enrollment';
1.122     matthew   452:     } else {
                    453:         $description = 'Bad parameter passed to lonstatistics::section_and_enrollment_description';
                    454:         &Apache::lonnet::logthis($description);
                    455:     }
1.130     raeburn   456:     $description = &section_or_group_text($mode,'section',@sections).
1.131     albertel  457: 	' '.&section_or_group_text($mode,'group',@groups);
1.130     raeburn   458:     if ($mode eq 'localized') {
                    459:         $description .= &mt(' [_1] enrollment status.',$env{'form.Status'});
                    460:     } elsif ($mode eq 'plaintext') {
                    461:         $description .= ' '.$env{'form.Status'}.' enrollment status.';
                    462:     }
                    463:     return $description;
                    464: }
                    465: 
                    466: #######################################################
                    467: #######################################################
                    468: 
                    469: sub section_or_group_text {
                    470:     my ($mode,$type,@items) = @_;
                    471:     my $text;
                    472:     my %phrases = ();
                    473:     %{$phrases{'section'}} = (
                    474:                               single => 'Section',
                    475:                               all => 'All sections',
                    476:                               plural => 'Sections',
                    477:                              );
                    478:     %{$phrases{'group'}} = (
                    479:                               single => 'Group',
                    480:                               all => 'All groups',
                    481:                               plural => 'Groups',
                    482:                              );
                    483:     if (scalar(@items) == 1 && $items[0] ne 'all') {
1.122     matthew   484:         if ($mode eq 'localized') {
1.130     raeburn   485:             $text = &mt('[_1] [_2].',$phrases{$type}{single},$items[0]);
1.122     matthew   486:         } elsif ($mode eq 'plaintext') {
1.130     raeburn   487:             $text = $phrases{$type}{single}.' '.$items[0].'.';
                    488: 
1.122     matthew   489:         }
1.130     raeburn   490:     } elsif (scalar(@items) && $items[0] eq 'all') {
1.122     matthew   491:         if ($mode eq 'localized') {
1.130     raeburn   492:             $text = &mt('[_1].',$phrases{$type}{all});
1.122     matthew   493:         } elsif ($mode eq 'plaintext') {
1.130     raeburn   494:             $text = $phrases{$type}{all}.'.';
1.122     matthew   495:         }
1.130     raeburn   496:     } elsif (scalar(@items)) {
                    497:         my $lastitem = pop(@items);
1.122     matthew   498:         if ($mode eq 'localized') {
1.130     raeburn   499:             $text = &mt('[_1] [_2] and [_3].',$phrases{$type}{plural},
                    500:                         join(', ',@items),$lastitem);
1.122     matthew   501:         } elsif ($mode eq 'plaintext') {
1.130     raeburn   502:             $text = $phrases{$type}{plural}.' '.join(', ',@items).' and '.
                    503:                     $lastitem.'.';
1.122     matthew   504:         }
1.119     matthew   505:     }
1.130     raeburn   506:     return $text;
1.119     matthew   507: }
1.71      matthew   508: 
                    509: 
                    510: =pod
                    511: 
                    512: =item get_students
                    513: 
                    514: Returns a list of the selected students
                    515: 
                    516: =cut
                    517: 
                    518: #######################################################
                    519: #######################################################
                    520: sub get_students {
                    521:     if (! @Students) {
                    522:         &PrepareClasslist()
                    523:     }
                    524:     return @Students;
                    525: }
                    526: 
1.61      matthew   527: #######################################################
                    528: #######################################################
                    529: 
                    530: =pod
                    531: 
                    532: =item &current_student()
                    533: 
                    534: Returns a pointer to a hash containing data about the currently
                    535: selected student.
                    536: 
                    537: =cut
                    538: 
                    539: #######################################################
                    540: #######################################################
                    541: sub current_student { 
1.72      matthew   542:     return $curr_student;
1.61      matthew   543: }
                    544: 
                    545: #######################################################
                    546: #######################################################
                    547: 
                    548: =pod
                    549: 
                    550: =item &previous_student()
                    551: 
                    552: Returns a pointer to a hash containing data about the student prior
                    553: in the list of students.  Or something.  
                    554: 
                    555: =cut
                    556: 
                    557: #######################################################
                    558: #######################################################
                    559: sub previous_student { 
1.72      matthew   560:     return $prev_student;
1.59      matthew   561: }
                    562: 
                    563: #######################################################
                    564: #######################################################
1.61      matthew   565: 
                    566: =pod
                    567: 
                    568: =item &next_student()
                    569: 
                    570: Returns a pointer to a hash containing data about the next student
                    571: to be viewed.
                    572: 
                    573: =cut
                    574: 
                    575: #######################################################
                    576: #######################################################
                    577: sub next_student { 
1.72      matthew   578:     return $next_student;
1.61      matthew   579: }
1.60      matthew   580: 
1.61      matthew   581: ##############################################
                    582: ##############################################
                    583: 
                    584: =pod 
                    585: 
                    586: =item &StudentDataSelect($elementname,$status,$numvisible,$selected)
                    587: 
                    588: Returns html for a selection box allowing the user to choose one (or more) 
                    589: of the fields of student data available (fullname, username, id, section, etc)
                    590: 
                    591: =over 4
                    592: 
                    593: =item $elementname The name of the HTML form element
                    594: 
                    595: =item $status 'multiple' or 'single' selection box
                    596: 
                    597: =item $numvisible The number of options to be visible
                    598: 
                    599: =back
1.60      matthew   600: 
                    601: =cut
                    602: 
1.61      matthew   603: ##############################################
                    604: ##############################################
                    605: sub StudentDataSelect {
                    606:     my ($elementname,$status,$numvisible)=@_;
                    607:     if ($numvisible < 1) {
                    608:         return;
                    609:     }
                    610:     #
                    611:     # Build the form element
                    612:     my $Str = "\n";
                    613:     $Str .= '<select name="'.$elementname.'" ';
                    614:     if ($status ne 'single') {
                    615:         $Str .= 'multiple="true" ';
                    616:     }
                    617:     $Str .= 'size="'.$numvisible.'" >'."\n";
                    618:     #
                    619:     # Deal with 'all'
                    620:     $Str .= '    <option value="all" ';
                    621:     foreach (@SelectedStudentData) {
                    622:         if ($_ eq 'all') {
                    623:             $Str .= 'selected ';
                    624:             last;
                    625:         }
                    626:     }
                    627:     $Str .= ">all</option>\n";
                    628:     #
                    629:     # Loop through the student data fields
                    630:     foreach my $item (@StudentDataOrder) {
                    631:         $Str .= '    <option value="'.$item.'" ';
                    632:         foreach (@SelectedStudentData) {
                    633:             if ($item eq $_ ) {
                    634:                 $Str .= 'selected ';
                    635:                 last;
                    636:             }
                    637:         }
                    638:         $Str .= '>'.$item."</option>\n";
                    639:     }
                    640:     $Str .= "</select>\n";
                    641:     return $Str;
1.60      matthew   642: }
                    643: 
1.115     matthew   644: #######################################################
                    645: #######################################################
                    646: 
                    647: =pod
                    648: 
                    649: =item &get_selected_maps($elementname)
                    650: 
                    651: Input: Name of the <select> form element used to specify the maps.
                    652: 
                    653: Returns: Array of symbs of selected maps or the description 'all'.
                    654:    If form.$elementname does not exist, 'all' is returned.
                    655: 
                    656: =cut
                    657: 
                    658: #######################################################
                    659: #######################################################
                    660: sub get_selected_maps {
                    661:     my ($elementname) = @_;
1.124     albertel  662:     my @selected_maps = 
                    663: 	&Apache::loncommon::get_env_multiple('form.'.$elementname);
                    664:     @selected_maps = ('all') if (! @selected_maps);
1.118     matthew   665:     foreach my $map (@selected_maps) {
                    666:         if ($map eq 'all') {
                    667:             @selected_maps = ('all');
                    668:             last;
                    669:         }
                    670:     }
1.115     matthew   671:     return @selected_maps;
                    672: }
                    673: 
                    674: 
                    675: #######################################################
                    676: #######################################################
                    677: 
                    678: =pod
                    679: 
1.116     matthew   680: =item &selected_sequences_with_assessments
1.115     matthew   681: 
                    682: Retrieve the sequences which were selected by the user to show.  
                    683: 
                    684: Input: $mode: scalar.  Either 'selected' or 'all'.  If not specified,
                    685:     'selected' is used.
                    686: 
                    687: Returns: an array containing a navmap object and navmap resources, 
                    688:     or an array containing a scalar with an error message.
                    689: 
                    690: =cut
                    691: 
                    692: #######################################################
                    693: #######################################################
1.116     matthew   694: sub selected_sequences_with_assessments {
1.115     matthew   695:     my ($mode) = @_;
                    696:     $mode = 'selected' if (! defined($mode));
                    697:     my $navmap = Apache::lonnavmaps::navmap->new();
                    698:     if (!defined($navmap)) {
                    699:         return ('Can not open Coursemap');
                    700:     }
                    701:     #
                    702:     my @sequences = $navmap->retrieveResources(undef,
                    703:                                                sub { shift->is_map(); },1,0,1);
                    704:     my @sequences_with_assessments;
                    705:     for my $sequence ($navmap->getById('0.0'), @sequences) {
1.120     matthew   706: 	if ($navmap->hasResource($sequence,sub { shift->is_problem(); },0,1)){
1.115     matthew   707:             push(@sequences_with_assessments,$sequence);
                    708:         }
                    709:     }
                    710:     #
                    711:     my @sequences_to_show;
                    712:     foreach my $sequence (@sequences_with_assessments) {
                    713:         if ($mode eq 'all') {
                    714:             push (@sequences_to_show,$sequence);
                    715:         } elsif ($mode eq 'selected') {
1.116     matthew   716:             foreach my $map_symb (&get_selected_maps('Maps')) {
1.115     matthew   717:                 if ($sequence->symb eq $map_symb || $map_symb eq 'all'){
                    718:                     push (@sequences_to_show,$sequence);
                    719:                     last; # Only put it in once
                    720:                 }
                    721:             }
                    722:         }
                    723: 
                    724:     }
                    725:     return $navmap,@sequences_to_show;
                    726: }
                    727: 
1.60      matthew   728: ##############################################
                    729: ##############################################
                    730: 
                    731: =pod 
                    732: 
1.115     matthew   733: =item &map_select($elementname,$status,$numvisible,$restriction) 
1.60      matthew   734: 
                    735: Returns html for a selection box allowing the user to choose one (or more) 
                    736: of the sequences in the course.  The values of the sequences are the symbs.
                    737: If the top sequence is selected, the value 'top' will result.
                    738: 
                    739: =over 4
                    740: 
                    741: =item $elementname The name of the HTML form element
                    742: 
                    743: =item $status 'multiple' or 'single' selection box
                    744: 
                    745: =item $numvisible The number of options to be visible
                    746: 
                    747: =back
                    748: 
                    749: =cut
                    750: 
                    751: ##############################################
                    752: ##############################################
1.115     matthew   753: sub map_select {
                    754:     my ($elementname,$status,$numvisible)=@_;
1.60      matthew   755:     if ($numvisible < 1) {
                    756:         return;
                    757:     }
                    758:     #
                    759:     # Set up array of selected items
1.115     matthew   760:     my @selected_maps = &get_selected_maps($elementname);
1.60      matthew   761:     #
                    762:     # Build the form element
1.115     matthew   763:     my $form = "\n";
                    764:     $form .= '<select name="'.$elementname.'" ';
1.60      matthew   765:     if ($status ne 'single') {
1.115     matthew   766:         $form .= 'multiple="true" ';
1.60      matthew   767:     }
1.115     matthew   768:     $form .= 'size="'.$numvisible.'" >'."\n";
1.60      matthew   769:     #
1.61      matthew   770:     # Put in option for 'all'
1.115     matthew   771:     $form .= '    <option value="all" ';
1.118     matthew   772:     if ($selected_maps[0] eq 'all') {
                    773:         $form .= 'selected ';
1.61      matthew   774:     }
1.115     matthew   775:     $form .= ">all</option>\n";
1.61      matthew   776:     #
1.60      matthew   777:     # Loop through the sequences
1.117     matthew   778:     my @sequences = &selected_sequences_with_assessments('all');
1.115     matthew   779:     my $navmap;
                    780:     if (!ref($sequences[0])) {
                    781:         return $sequences[0];
                    782:     } else {
                    783:         $navmap = shift(@sequences);
                    784:     }
                    785:     foreach my $seq (@sequences){
                    786:         $form .= '    <option value="'.$seq->symb.'" ';
                    787:         foreach (@selected_maps) {
                    788:             if ($seq->symb eq $_) {
                    789:                 $form .= 'selected ';
1.60      matthew   790:                 last;
                    791:             }
                    792:         }
1.115     matthew   793:         $form .= '>'.$seq->compTitle."</option>\n";
1.60      matthew   794:     }
1.115     matthew   795:     $form .= "</select>\n";
                    796:     return $form;
1.60      matthew   797: }
                    798: 
                    799: ##############################################
                    800: ##############################################
                    801: 
                    802: =pod 
                    803: 
                    804: =item &SectionSelect($elementname,$status,$numvisible) 
                    805: 
                    806: Returns html for a selection box allowing the user to choose one (or more) 
                    807: of the sections in the course.  
                    808: 
1.119     matthew   809: Uses the package variables @Sections
1.60      matthew   810: =over 4
                    811: 
                    812: =item $elementname The name of the HTML form element
                    813: 
                    814: =item $status 'multiple' or 'single' selection box
                    815: 
                    816: =item $numvisible The number of options to be visible
                    817: 
                    818: =back
                    819: 
                    820: =cut
                    821: 
                    822: ##############################################
                    823: ##############################################
                    824: sub SectionSelect {
                    825:     my ($elementname,$status,$numvisible)=@_;
                    826:     if ($numvisible < 1) {
                    827:         return;
                    828:     }
                    829:     #
1.71      matthew   830:     # Make sure we have the data we need to continue
                    831:     if (! @Sections) {
                    832:         &PrepareClasslist()
                    833:     }
                    834:     #
1.60      matthew   835:     # Build the form element
                    836:     my $Str = "\n";
                    837:     $Str .= '<select name="'.$elementname.'" ';
                    838:     if ($status ne 'single') {
                    839:         $Str .= 'multiple="true" ';
                    840:     }
                    841:     $Str .= 'size="'.$numvisible.'" >'."\n";
                    842:     #
                    843:     # Loop through the sequences
                    844:     foreach my $s (@Sections) {
                    845:         $Str .= '    <option value="'.$s.'" ';
1.119     matthew   846:         foreach (&get_selected_sections()) {
1.61      matthew   847:             if ($s eq $_) {
1.60      matthew   848:                 $Str .= 'selected ';
                    849:                 last;
                    850:             }
                    851:         }
                    852:         $Str .= '>'.$s."</option>\n";
                    853:     }
                    854:     $Str .= "</select>\n";
                    855:     return $Str;
1.80      matthew   856: }
                    857: 
1.130     raeburn   858: ##############################################
                    859: ##############################################
                    860:                                                                                     
                    861: =pod
                    862:                                                                                     
                    863: =item &GroupSelect($elementname,$status,$numvisible)
                    864:                                                                                     
                    865: Returns html for a selection box allowing the user to choose one (or more)
                    866: of the groups in the course.
                    867:                                                                                     
                    868: Uses the package variables @Groups
                    869: =over 4
                    870:                                                                                     
                    871: =item $elementname The name of the HTML form element
                    872:                                                                                     
                    873: =item $status 'multiple' or 'single' selection box
                    874:                                                                                     
                    875: =item $numvisible The number of options to be visible
                    876:                                                                                     
                    877: =back
                    878:                                                                                     
                    879: =cut
                    880:                                                                                     
                    881: ##############################################
                    882: ##############################################
                    883: sub GroupSelect {
                    884:     my ($elementname,$status,$numvisible)=@_;
                    885:     if ($numvisible < 1) {
                    886:         return;
                    887:     }
                    888:     #
                    889:     # Make sure we have the data we need to continue
                    890:     if (! @Groups) {
                    891:         &PrepareClasslist();
                    892:     }
                    893:     #
                    894:     # Build the form element
                    895:     my $Str = "\n";
                    896:     $Str .= '<select name="'.$elementname.'" ';
                    897:     if ($status ne 'single') {
                    898:         $Str .= 'multiple="true" ';
                    899:     }
                    900:     $Str .= 'size="'.$numvisible.'" >'."\n";
                    901:     #
                    902:     # Loop through the groups
                    903:     foreach my $s (@Groups) {
                    904:         $Str .= '    <option value="'.$s.'" ';
                    905:         foreach my $group (&get_selected_groups()) {
                    906:             if ($s eq $group) {
                    907:                 $Str .= 'selected ';
                    908:                 last;
                    909:             }
                    910:         }
                    911:         $Str .= '>'.$s."</option>\n";
                    912:     }
                    913:     $Str .= "</select>\n";
                    914: }
                    915: 
                    916: 
1.61      matthew   917: ##################################################
                    918: ##################################################
1.60      matthew   919: sub DisplayClasslist {
                    920:     my ($r)=@_;
1.107     matthew   921:     &Apache::lonhtmlcommon::add_breadcrumb
                    922:         ({text=>'Select One Student'});
1.60      matthew   923:     #
1.105     matthew   924:     # Output some of the standard interface components
                    925:     my $Str;
1.132     albertel  926:     $Str .= &Apache::lonhtmlcommon::breadcrumbs('Select One Student');
1.105     matthew   927:     $Str .= '<p><table cellspacing="5">'."\n";
                    928:     $Str .= '<tr>';
                    929:     $Str .= '<th align="center"><b>'.&mt('Sections').'</b></th>';
1.130     raeburn   930:     $Str .= '<th align="center"><b>'.&mt('Groups').'</b></th>';
1.105     matthew   931:     $Str .= '<th align="center"><b>'.&mt('Enrollment Status').'</b></th>';
                    932:     $Str .= '</tr>'.$/;
                    933:     $Str .= '<tr>';
                    934:     $Str .= '<td>'.
                    935:         &Apache::lonstatistics::SectionSelect('Section','multiple',5).
                    936:         '</td>';
1.130     raeburn   937:     $Str .=  '<td>'.
                    938:         &Apache::lonstatistics::GroupSelect('Group','multiple',5).
                    939:         '</td>';
1.105     matthew   940:     $Str .= '<td>'.
                    941:         &Apache::lonhtmlcommon::StatusOptions(undef,undef,5).
                    942:         '</td>';
                    943:     
                    944:     $Str .= '</tr>'.$/;
                    945:     $Str .= '</table></p>';
                    946:     $Str .= '<input type="submit" name="selectstudent" value="'.
                    947:         &mt('Update Display').'" />';
                    948:     $r->print($Str);
                    949:     $r->rflush();
                    950:     #
1.130     raeburn   951:     my @Fields = ('fullname','username','domain','id','section','status','groups');
1.60      matthew   952:     #
1.105     matthew   953:     $Str = '';
1.119     matthew   954:     my @selected_sections = &get_selected_sections();
1.78      matthew   955:     if (! @Students) {
1.119     matthew   956:         if ($selected_sections[0] eq 'all') { 
1.123     albertel  957:             if (lc($env{'form.Status'}) eq 'any') {
1.106     matthew   958:                 $Str .= '<h2>'.
                    959:                     &mt('There are no students in the course.').
                    960:                     '</h2>';
1.123     albertel  961:             } elsif (lc($env{'form.Status'}) eq 'active') {
1.106     matthew   962:                 $Str .= '<h2>'.
                    963:                 &mt('There are no currently enrolled students in the course.').
                    964:                     '</h2>';
1.123     albertel  965:             } elsif (lc($env{'form.Status'}) eq 'expired') {
1.106     matthew   966:                 $Str .= '<h2>'.
                    967:                     &mt('There are no previously enrolled students in the course.').
                    968:                         '</h2>';
1.78      matthew   969:             }
                    970:         } else { 
                    971:             my $sections;
1.123     albertel  972:             if (lc($env{'form.Status'}) eq 'any') {
1.106     matthew   973:                 $Str .= '<h2>'.
                    974:                     &mt('There are no students in the selected sections.').
                    975:                     '</h2>';
1.123     albertel  976:             } elsif (lc($env{'form.Status'}) eq 'active') {
1.106     matthew   977:                 $Str .= '<h2>'.
                    978:                     &mt('There are no currently enrolled students in the selected sections.').
                    979:                     '</h2>';
1.123     albertel  980:             } elsif (lc($env{'form.Status'}) eq 'expired') {
1.106     matthew   981:                 $Str .= '<h2>'.
                    982:                     &mt('There are no previously enrolled students in the selected sections.').
                    983:                     '</h2>';
1.78      matthew   984:             }
                    985:         }
                    986:         $Str.= '<a href="/adm/statistics?reportSelected=student_assessment">'.
1.106     matthew   987:             &mt('Click here to return to the chart').'</a>';
1.78      matthew   988:         $r->print($Str);
                    989:         $r->rflush();
                    990:         return;
                    991:     }
                    992: 
1.76      matthew   993:     # "Click" is asinine but it is probably not my place to change the world.
1.78      matthew   994:     $Str .= '<h2>Click on a students name or username to view their chart</h2>';
1.60      matthew   995:     $Str .= '<table border="0"><tr><td bgcolor="#777777">'."\n";
                    996:     $Str .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n";
                    997:     foreach my $field (@Fields) {
1.101     matthew   998:         $Str .= '<th><a href="/adm/statistics?'.
                    999:             'reportSelected=student_assessment&'.
                   1000:             'selectstudent=1&'.
1.106     matthew  1001:             'sort='.$field.'">'.&mt($field).
1.60      matthew  1002:             '</a></th>';
                   1003:     }
                   1004:     $Str .= '</tr>'."\n";
                   1005:     #
                   1006:     my $alternate = 0;
1.65      matthew  1007:     foreach my $student (@Students) { # @Students is a package variable
1.60      matthew  1008:         my $sname = $student->{'username'}.':'.$student->{'domain'};
                   1009:         if($alternate) {
                   1010:             $Str .= '<tr bgcolor="#ffffe6">';
                   1011:         } else {
                   1012:             $Str .= '<tr bgcolor="#ffffc6">';
                   1013:         }
                   1014:         $alternate = ($alternate + 1) % 2;
                   1015:         #
                   1016:         foreach my $field (@Fields) {
                   1017:             $Str .= '<td>';
1.78      matthew  1018:             if ($field eq 'fullname' || $field eq 'username') {
1.60      matthew  1019:                 $Str .= '<a href="/adm/statistics?reportSelected=';
1.65      matthew  1020:                 $Str .= &Apache::lonnet::escape('student_assessment');
1.123     albertel 1021:                 $Str .= '&sort='.&Apache::lonnet::escape($env{'form.sort'});
1.72      matthew  1022:                 $Str .= '&SelectedStudent=';
1.61      matthew  1023:                 $Str .= &Apache::lonnet::escape($sname).'">';
1.60      matthew  1024:                 $Str .= $student->{$field}.'&nbsp';
                   1025:                 $Str .= '</a>';
1.106     matthew  1026:             } elsif ($field eq 'status') {
                   1027:                 $Str .= &mt($student->{$field});
1.60      matthew  1028:             } else {
                   1029:                 $Str .= $student->{$field};
                   1030:             }
                   1031:             $Str .= '</td>';
                   1032:         }
                   1033:         $Str .= "</tr>\n";
                   1034:     }
                   1035:     $Str .= '</table></td></tr></table>'."\n";
                   1036:     #
                   1037:     $r->print($Str);
                   1038:     $r->rflush();
                   1039:     #
                   1040:     return;
                   1041: }
                   1042: 
1.65      matthew  1043: ##############################################
                   1044: ##############################################
1.33      stredwic 1045: sub CreateMainMenu {
1.65      matthew  1046:     #
1.85      matthew  1047:     # Define menu data
                   1048:     my @reports = ({ internal_name => 'problem_statistics',
                   1049:                      name => &mt('Overall Problem Statistics'),
                   1050:                      short_description => 
                   1051:     &mt('Student performance statistics on all problems.'),
                   1052:                  },
                   1053:                    { internal_name => 'problem_analysis',
                   1054:                      name => &mt('Detailed Problem Analysis'),
                   1055:                      short_description => 
                   1056:     &mt('Detailed statistics and graphs of student performance on problems.'),
                   1057:                  },
1.89      matthew  1058:                    { internal_name => 'submissiontime_analysis',
1.94      matthew  1059:                      name => &mt('Submission Time Plots'),
1.89      matthew  1060:                      short_description => 
                   1061:     &mt('Display and analysis of submission times on assessments.'),
                   1062:                  },
1.97      matthew  1063:                    { internal_name => 'student_submission_reports',
                   1064:                      name => &mt('Student Submission Reports'),
                   1065:                      short_description => 
1.111     matthew  1066:     &mt('Prepare reports of student submissions.'),
1.97      matthew  1067:                  },
1.104     matthew  1068:                    { internal_name => 'survey_reports',
                   1069:                      name => &mt('Survey Reports'),
                   1070:                      short_description => 
                   1071:     &mt('Prepare reports on survey results.'),
                   1072:                  },
1.94      matthew  1073:                    { internal_name => 'correct_problems_plot',
                   1074:                      name => &mt('Correct Problems Plot'),
                   1075:                      short_description => 
                   1076:     &mt('Display a histogram of student performance in the course.'),
                   1077:                  },
1.128     albertel 1078: #                   { internal_name => 'grading_analysis',
                   1079: #                     name => &mt('Detailed Grading Analysis'),
                   1080: #                     short_description => 
                   1081: #    &mt('Display statistics about who graded who.'),
                   1082: #                 },
1.88      matthew  1083: #                   { internal_name => 'student_assessment',
                   1084: #                     name => &mt('Problem Status Chart'),
                   1085: #                     short_description => 
                   1086: #    &mt('Brief view of each students performance in course.'),
                   1087: #                 },
1.85      matthew  1088:                    # 'percentage'  => 'Correct-problems Plot',
                   1089:                    # 'activitylog' => 'Activity Log',
                   1090:                    );
1.65      matthew  1091:     #
1.85      matthew  1092:     # Create the menu
                   1093:     my $Str;
1.98      matthew  1094:     $Str .= '<h2>'.&mt('Please select a report to generate').'</h2>';
1.85      matthew  1095:     foreach my $reportdata (@reports) {
1.87      matthew  1096:         $Str .='    <h3><a href="/adm/statistics?reportSelected='.
1.85      matthew  1097:             $reportdata->{'internal_name'}.'" >'.
1.87      matthew  1098:             $reportdata->{'name'}."</a></h3>\n";
                   1099:         $Str .= '    '.('&nbsp;'x8).$reportdata->{'short_description'}.
                   1100:             "\n";
1.85      matthew  1101:     }
                   1102:     $Str .="</dl>\n";
1.65      matthew  1103:     #
1.33      stredwic 1104:     return $Str;
                   1105: }
                   1106: 
1.65      matthew  1107: ##############################################
                   1108: ##############################################
1.1       albertel 1109: sub handler {
1.31      minaeibi 1110:     my $r=shift;
1.65      matthew  1111:     my $c = $r->connection();
                   1112:     #
                   1113:     # Check for overloading
1.51      www      1114:     my $loaderror=&Apache::lonnet::overloaderror($r);
                   1115:     if ($loaderror) { return $loaderror; }
                   1116:     $loaderror=
                   1117:        &Apache::lonnet::overloaderror($r,
1.123     albertel 1118:          $env{'course.'.$env{'request.course.id'}.'.home'});
1.51      www      1119:     if ($loaderror) { return $loaderror; }
1.65      matthew  1120:     #
                   1121:     # Check for access
1.123     albertel 1122:     if (! &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
                   1123:         $env{'user.error.msg'}=
1.69      matthew  1124:             $r->uri.":vgr:0:0:Cannot view grades for complete course";
                   1125:         if (! &Apache::lonnet::allowed('vgr',
1.123     albertel 1126:                       $env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
                   1127:             $env{'user.error.msg'}=
1.69      matthew  1128:                 $r->uri.":vgr:0:0:Cannot view grades with given role";
                   1129:             return HTTP_NOT_ACCEPTABLE;
                   1130:         }
1.27      stredwic 1131:     }
1.65      matthew  1132:     #
                   1133:     # Send the header
1.92      www      1134:     &Apache::loncommon::no_cache($r);
                   1135:     &Apache::loncommon::content_type($r,'text/html');
1.27      stredwic 1136:     $r->send_http_header;
1.92      www      1137:     if ($r->header_only) { return OK; }
1.65      matthew  1138:     #
                   1139:     # Extract form elements from query string
1.60      matthew  1140:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.65      matthew  1141:                                             ['sort','reportSelected',
1.72      matthew  1142:                                              'SelectedStudent']);
1.65      matthew  1143:     #
                   1144:     # Give the LON-CAPA page header
1.109     matthew  1145:     my $style = <<ENDSTYLE;
                   1146: <style type="text/css">
                   1147:     ul.sub_studentans { list-style-type: none }
                   1148:     ul.sub_correctans { list-style-type: none }
1.110     matthew  1149:     tr.even           { background-color: \#CCCCCC }
                   1150:     td.essay          { border: 1px solid gray; }
1.109     matthew  1151: </style>
                   1152: ENDSTYLE
1.129     albertel 1153:       
                   1154:     $r->print(&Apache::loncommon::start_page('Course Statistics and Charts',
                   1155: 					     $style));
1.65      matthew  1156:     $r->rflush();
1.85      matthew  1157:     # 
                   1158:     # Either print out a menu for them or send them to a report
1.98      matthew  1159:     &Apache::lonhtmlcommon::clear_breadcrumbs();
                   1160:     &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/statistics',
1.100     matthew  1161:                                             title=>'Statistics',
                   1162:                                             text =>'Statistics',
1.98      matthew  1163:                                             faq=>139,
                   1164:                                             bug=>'Statistics and Charts'});
1.123     albertel 1165:     if (! exists($env{'form.reportSelected'}) || 
                   1166:         $env{'form.reportSelected'} eq '') {
1.132     albertel 1167:         $r->print(&Apache::lonhtmlcommon::breadcrumbs('Statistics Main Page').
1.98      matthew  1168:                   &CreateMainMenu());
1.85      matthew  1169:     } else {
1.65      matthew  1170:     #
1.85      matthew  1171:         if (! &Apache::lonmysql::verify_sql_connection()) {
                   1172:             my $serveradmin = $r->dir_config('lonAdmEMail');
                   1173:             $r->print('<h2><font color="Red">'.
                   1174:                       &mt('Unable to connect to database!').
                   1175:                       '</font></h2>');
                   1176:             $r->print('<p>'.
                   1177:                       &mt('Please notify the server administrator ').
                   1178:                       '<b>'.$serveradmin.'</b></p>');
                   1179:             $r->print('<p>'.
                   1180:                       &mt('Course Statistics and Charts cannot be '.
                   1181:                           'retrieved until the database is restarted.  '.
                   1182:                           'Your data is intact but cannot be displayed '.
                   1183:                           'at this time.').'</p>');
1.129     albertel 1184:             $r->print(&Apache::loncommon::end_page());
1.85      matthew  1185:             return;
                   1186:         }
                   1187:         #
                   1188:         # Clean out the caches
1.123     albertel 1189:         if (exists($env{'form.ClearCache'})) {
                   1190:             &Apache::loncoursedata::delete_caches($env{'requres.course.id'});
1.85      matthew  1191:         }
                   1192:         #
                   1193:         # Begin form output
                   1194:         $r->print('<form name="Statistics" ');
                   1195:         $r->print('method="post" action="/adm/statistics">');
                   1196:         $r->rflush();
                   1197:         #
1.123     albertel 1198:         my $GoToPage = $env{'form.reportSelected'};
1.90      matthew  1199:         #
1.85      matthew  1200:         $r->print('<input type="hidden" name="reportSelected" value="'.
                   1201:                   $GoToPage.'">');
                   1202:         if($GoToPage eq 'activitylog') {
1.65      matthew  1203: #        &Apache::lonproblemstatistics::Activity();
1.85      matthew  1204:         } elsif($GoToPage eq 'problem_statistics') {
1.98      matthew  1205:             &Apache::lonhtmlcommon::add_breadcrumb
                   1206:                 ({href=>'/adm/statistics?reportselected=problem_statistics',
1.100     matthew  1207:                   text=>'Overall Problem Statistics'});
1.85      matthew  1208:             &Apache::lonproblemstatistics::BuildProblemStatisticsPage($r,$c);
                   1209:         } elsif($GoToPage eq 'problem_analysis') {
1.98      matthew  1210:             &Apache::lonhtmlcommon::add_breadcrumb
                   1211:                 ({href=>'/adm/statistics?reportselected=problem_analysis',
1.100     matthew  1212:                   text=>'Detailed Problem Analysis'});
1.85      matthew  1213:             &Apache::lonproblemanalysis::BuildProblemAnalysisPage($r,$c);
1.89      matthew  1214:         } elsif($GoToPage eq 'submissiontime_analysis') {
1.98      matthew  1215:             &Apache::lonhtmlcommon::add_breadcrumb
                   1216:                 ({href=>
                   1217:                       '/adm/statistics?reportselected=submissiontime_analysis',
1.100     matthew  1218:                       text=>'Submission Time Plots'});
1.89      matthew  1219:             &Apache::lonsubmissiontimeanalysis::BuildSubmissionTimePage($r,$c);
1.97      matthew  1220:         } elsif($GoToPage eq 'student_submission_reports') {
1.98      matthew  1221:             &Apache::lonhtmlcommon::add_breadcrumb
                   1222:                 ({href=>
                   1223:                   '/adm/statistics?reportselected=student_submission_reports',
1.100     matthew  1224:                   text=>'Student Submission Reports'});
1.97      matthew  1225:             &Apache::lonstudentsubmissions::BuildStudentSubmissionsPage($r,$c);
1.104     matthew  1226:         } elsif($GoToPage eq 'survey_reports') {
                   1227:             &Apache::lonhtmlcommon::add_breadcrumb
                   1228:                 ({href=>
                   1229:                   '/adm/statistics?reportselected=survey_reports',
                   1230:                   text=>'Survey Reports'});
                   1231:             &Apache::lonsurveyreports::BuildSurveyReportsPage($r,$c);
1.94      matthew  1232:         } elsif($GoToPage eq 'correct_problems_plot') {
1.98      matthew  1233:             &Apache::lonhtmlcommon::add_breadcrumb
                   1234:                 ({href=>'/adm/statistics?reportselected=correct_problems_plot',
1.100     matthew  1235:                   text=>'Correct Problems Plot'});
1.94      matthew  1236:             &Apache::loncorrectproblemplot::BuildCorrectProblemsPage($r,$c);
1.85      matthew  1237:         } elsif($GoToPage eq 'student_assessment') {
1.98      matthew  1238:             &Apache::lonhtmlcommon::clear_breadcrumbs();
                   1239:             &Apache::lonhtmlcommon::add_breadcrumb
                   1240:                 ({href=>'/adm/statistics?reportselected=student_assessment',
1.100     matthew  1241:                   text=>'Chart'});
1.85      matthew  1242:             &Apache::lonstudentassessment::BuildStudentAssessmentPage($r,$c);
1.128     albertel 1243:         } elsif($GoToPage eq 'grading_analysis') {
                   1244:             &Apache::lonhtmlcommon::add_breadcrumb
                   1245:                 ({href=>'/adm/statistics?reportselected=grading_anaylsis',
                   1246:                   text=>'Grading Analysis'});
                   1247:             &Apache::longradinganalysis::build_grading_analysis_page($r,$c);
                   1248: 	}
1.85      matthew  1249:         #
                   1250:         $r->print("</form>\n");
1.65      matthew  1251:     }
1.129     albertel 1252:     $r->print(&Apache::loncommon::end_page());
1.65      matthew  1253:     $r->rflush();
                   1254:     #
1.27      stredwic 1255:     return OK;
1.1       albertel 1256: }
1.65      matthew  1257: 
1.1       albertel 1258: 1;
1.59      matthew  1259: 
1.65      matthew  1260: #######################################################
                   1261: #######################################################
                   1262: 
1.59      matthew  1263: =pod
                   1264: 
                   1265: =back
                   1266: 
                   1267: =cut
1.65      matthew  1268: 
                   1269: #######################################################
                   1270: #######################################################
1.59      matthew  1271: 
1.1       albertel 1272: __END__
1.31      minaeibi 1273: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>