Annotation of loncom/interface/statistics/lonstudentassessment.pm, revision 1.113

1.1       stredwic    1: # The LearningOnline Network with CAPA
                      2: #
1.113   ! matthew     3: # $Id: lonstudentassessment.pm,v 1.112 2005/02/25 02:37:49 matthew Exp $
1.1       stredwic    4: #
                      5: # Copyright Michigan State University Board of Trustees
                      6: #
                      7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      8: # LON-CAPA is free software; you can redistribute it and/or modify
                      9: # it under the terms of the GNU General Public License as published by
                     10: # the Free Software Foundation; either version 2 of the License, or
                     11: # (at your option) any later version.
                     12: #
                     13: # LON-CAPA is distributed in the hope that it will be useful,
                     14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     16: # GNU General Public License for more details.
                     17: #
                     18: # You should have received a copy of the GNU General Public License
                     19: # along with LON-CAPA; if not, write to the Free Software
                     20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     21: #
                     22: # /home/httpd/html/adm/gpl.txt
                     23: #
                     24: # http://www.lon-capa.org/
                     25: #
                     26: # (Navigate problems for statistical reports
1.28      matthew    27: #
                     28: #######################################################
                     29: #######################################################
                     30: 
                     31: =pod
                     32: 
                     33: =head1 NAME
                     34: 
                     35: lonstudentassessment
                     36: 
                     37: =head1 SYNOPSIS
                     38: 
                     39: Presents assessment data about a student or a group of students.
                     40: 
                     41: =head1 Subroutines
                     42: 
                     43: =over 4 
                     44: 
                     45: =cut
                     46: 
                     47: #######################################################
                     48: #######################################################
1.1       stredwic   49: 
1.21      minaeibi   50: package Apache::lonstudentassessment;
1.1       stredwic   51: 
                     52: use strict;
1.28      matthew    53: use Apache::lonstatistics;
1.1       stredwic   54: use Apache::lonhtmlcommon;
1.77      matthew    55: use Apache::loncommon();
1.1       stredwic   56: use Apache::loncoursedata;
1.28      matthew    57: use Apache::lonnet; # for logging porpoises
1.75      matthew    58: use Apache::lonlocal;
1.112     matthew    59: use Time::HiRes;
1.31      matthew    60: use Spreadsheet::WriteExcel;
1.76      matthew    61: use Spreadsheet::WriteExcel::Utility();
1.31      matthew    62: 
                     63: #######################################################
                     64: #######################################################
                     65: =pod
                     66: 
                     67: =item Package Variables
                     68: 
                     69: =over 4
                     70: 
                     71: =item $Statistics Hash ref to store student data.  Indexed by symb,
                     72:       contains hashes with keys 'score' and 'max'.
                     73: 
                     74: =cut
                     75: 
                     76: #######################################################
                     77: #######################################################
1.1       stredwic   78: 
1.30      matthew    79: my $Statistics;
                     80: 
1.28      matthew    81: #######################################################
                     82: #######################################################
                     83: 
                     84: =pod
                     85: 
1.31      matthew    86: =item $show_links 'yes' or 'no' for linking to student performance data
                     87: 
                     88: =item $output_mode 'html', 'excel', or 'csv' for output mode
                     89: 
1.32      matthew    90: =item $show 'all', 'totals', or 'scores' determines how much data is output
1.31      matthew    91: 
1.49      matthew    92: =item $single_student_mode evaluates to true if we are showing only one
                     93: student.
                     94: 
1.31      matthew    95: =cut
                     96: 
                     97: #######################################################
                     98: #######################################################
                     99: my $show_links;
                    100: my $output_mode;
1.87      matthew   101: my $chosen_output;
1.49      matthew   102: my $single_student_mode;
1.28      matthew   103: 
1.31      matthew   104: #######################################################
                    105: #######################################################
                    106: # End of package variable declarations
1.28      matthew   107: 
1.31      matthew   108: =pod
1.28      matthew   109: 
1.31      matthew   110: =back
1.28      matthew   111: 
1.31      matthew   112: =cut
1.28      matthew   113: 
1.31      matthew   114: #######################################################
                    115: #######################################################
1.28      matthew   116: 
1.31      matthew   117: =pod
1.28      matthew   118: 
1.31      matthew   119: =item &BuildStudentAssessmentPage()
1.28      matthew   120: 
1.31      matthew   121: Inputs: 
1.4       stredwic  122: 
1.31      matthew   123: =over 4
1.28      matthew   124: 
                    125: =item $r Apache Request
                    126: 
                    127: =item $c Apache Connection 
                    128: 
                    129: =back
                    130: 
                    131: =cut
                    132: 
                    133: #######################################################
                    134: #######################################################
1.1       stredwic  135: sub BuildStudentAssessmentPage {
1.30      matthew   136:     my ($r,$c)=@_;
1.74      matthew   137:     #
1.30      matthew   138:     undef($Statistics);
1.66      matthew   139:     undef($show_links);
                    140:     undef($output_mode);
1.87      matthew   141:     undef($chosen_output);
1.66      matthew   142:     undef($single_student_mode);
1.74      matthew   143:     #
                    144:     my %Saveable_Parameters = ('Status' => 'scalar',
                    145:                                'chartoutputmode' => 'scalar',
                    146:                                'chartoutputdata' => 'scalar',
                    147:                                'Section' => 'array',
                    148:                                'StudentData' => 'array',
                    149:                                'Maps' => 'array');
                    150:     &Apache::loncommon::store_course_settings('chart',\%Saveable_Parameters);
                    151:     &Apache::loncommon::restore_course_settings('chart',\%Saveable_Parameters);
                    152:     #
                    153:     &Apache::lonstatistics::PrepareClasslist();
                    154:     #
1.65      matthew   155:     $single_student_mode = 0;
1.49      matthew   156:     $single_student_mode = 1 if ($ENV{'form.SelectedStudent'});
1.100     matthew   157:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    158:                                             ['selectstudent']);
1.59      matthew   159:     if ($ENV{'form.selectstudent'}) {
                    160:         &Apache::lonstatistics::DisplayClasslist($r);
                    161:         return;
                    162:     }
1.30      matthew   163:     #
1.31      matthew   164:     # Print out the HTML headers for the interface
                    165:     #    This also parses the output mode selector
1.54      matthew   166:     #    This step must *always* be done.
1.30      matthew   167:     $r->print(&CreateInterface());
1.31      matthew   168:     $r->print('<input type="hidden" name="notfirstrun" value="true" />');
1.49      matthew   169:     $r->print('<input type="hidden" name="sort" value="'.
                    170:               $ENV{'form.sort'}.'" />');
1.7       stredwic  171:     $r->rflush();
1.58      matthew   172:     #
1.49      matthew   173:     if (! exists($ENV{'form.notfirstrun'}) && ! $single_student_mode) {
1.31      matthew   174:         return;
                    175:     }
                    176:     #
                    177:     my $initialize     = \&html_initialize;
                    178:     my $output_student = \&html_outputstudent;
                    179:     my $finish         = \&html_finish;
1.112     matthew   180:     &Apache::lonnet::logthis('got here! 1');
1.31      matthew   181:     #
                    182:     if ($output_mode eq 'excel') {
                    183:         $initialize     = \&excel_initialize;
                    184:         $output_student = \&excel_outputstudent;
                    185:         $finish         = \&excel_finish;
                    186:     } elsif ($output_mode eq 'csv') {
                    187:         $initialize     = \&csv_initialize;
                    188:         $output_student = \&csv_outputstudent;
                    189:         $finish         = \&csv_finish;
                    190:     }
1.30      matthew   191:     #
1.112     matthew   192:     &Apache::lonnet::logthis('got here! 2');
1.30      matthew   193:     if($c->aborted()) {  return ; }
1.31      matthew   194:     #
1.49      matthew   195:     # Determine which students we want to look at
                    196:     my @Students;
                    197:     if ($single_student_mode) {
                    198:         @Students = (&Apache::lonstatistics::current_student());
                    199:         $r->print(&next_and_previous_buttons());
                    200:         $r->rflush();
                    201:     } else {
                    202:         @Students = @Apache::lonstatistics::Students;
                    203:     }
1.56      matthew   204:     #
                    205:     # Perform generic initialization tasks
                    206:     #       Since we use lonnet::EXT to retrieve problem weights,
                    207:     #       to ensure current data we must clear the caches out.
                    208:     #       This makes sure that parameter changes at the student level
                    209:     #       are immediately reflected in the chart.
                    210:     &Apache::lonnet::clear_EXT_cache_status();
1.69      matthew   211:     #
                    212:     # Clean out loncoursedata's package data, just to be safe.
                    213:     &Apache::loncoursedata::clear_internal_caches();
1.49      matthew   214:     #
1.31      matthew   215:     # Call the initialize routine selected above
                    216:     $initialize->($r);
1.112     matthew   217:     &Apache::lonnet::logthis('got here! 3');
1.49      matthew   218:     foreach my $student (@Students) {
1.31      matthew   219:         if($c->aborted()) { 
                    220:             $finish->($r);
                    221:             return ; 
1.1       stredwic  222:         }
1.31      matthew   223:         # Call the output_student routine selected above
                    224:         $output_student->($r,$student);
                    225:     }
                    226:     # Call the "finish" routine selected above
                    227:     $finish->($r);
                    228:     #
                    229:     return;
                    230: }
                    231: 
                    232: #######################################################
                    233: #######################################################
1.49      matthew   234: sub next_and_previous_buttons {
                    235:     my $Str = '';
                    236:     $Str .= '<input type="hidden" name="SelectedStudent" value="'.
                    237:         $ENV{'form.SelectedStudent'}.'" />';
                    238:     #
                    239:     # Build the previous student link
                    240:     my $previous = &Apache::lonstatistics::previous_student();
                    241:     my $previousbutton = '';
                    242:     if (defined($previous)) {
                    243:         my $sname = $previous->{'username'}.':'.$previous->{'domain'};
                    244:         $previousbutton .= '<input type="button" value="'.
                    245:             'Previous Student ('.
                    246:             $previous->{'username'}.'@'.$previous->{'domain'}.')'.
                    247:             '" onclick="document.Statistics.SelectedStudent.value='.
                    248:             "'".$sname."'".';'.
                    249:             'document.Statistics.submit();" />';
                    250:     } else {
                    251:         $previousbutton .= '<input type="button" value="'.
                    252:             'Previous student (none)'.'" />';
                    253:     }
                    254:     #
                    255:     # Build the next student link
                    256:     my $next = &Apache::lonstatistics::next_student();
                    257:     my $nextbutton = '';
                    258:     if (defined($next)) {
                    259:         my $sname = $next->{'username'}.':'.$next->{'domain'};
                    260:         $nextbutton .= '<input type="button" value="'.
                    261:             'Next Student ('.
                    262:             $next->{'username'}.'@'.$next->{'domain'}.')'.
                    263:             '" onclick="document.Statistics.SelectedStudent.value='.
                    264:             "'".$sname."'".';'.
                    265:             'document.Statistics.submit();" />';
                    266:     } else {
                    267:         $nextbutton .= '<input type="button" value="'.
                    268:             'Next student (none)'.'" />';
                    269:     }
                    270:     #
                    271:     # Build the 'all students' button
                    272:     my $all = '';
                    273:     $all .= '<input type="button" value="All Students" '.
                    274:             '" onclick="document.Statistics.SelectedStudent.value='.
                    275:             "''".';'.'document.Statistics.submit();" />';
                    276:     $Str .= $previousbutton.('&nbsp;'x5).$all.('&nbsp;'x5).$nextbutton;
                    277:     return $Str;
                    278: }
                    279: 
                    280: #######################################################
                    281: #######################################################
1.30      matthew   282: 
1.31      matthew   283: sub get_student_fields_to_show {
                    284:     my @to_show = @Apache::lonstatistics::SelectedStudentData;
                    285:     foreach (@to_show) {
                    286:         if ($_ eq 'all') {
                    287:             @to_show = @Apache::lonstatistics::StudentDataOrder;
                    288:             last;
                    289:         }
                    290:     }
                    291:     return @to_show;
                    292: }
                    293: 
1.28      matthew   294: #######################################################
                    295: #######################################################
                    296: 
                    297: =pod
1.2       stredwic  298: 
1.28      matthew   299: =item &CreateInterface()
1.21      minaeibi  300: 
1.28      matthew   301: Called by &BuildStudentAssessmentPage to create the top part of the
                    302: page which displays the chart.
                    303: 
1.30      matthew   304: Inputs: None
1.28      matthew   305: 
                    306: Returns:  A string containing the HTML for the headers and top table for 
                    307: the chart page.
                    308: 
                    309: =cut
                    310: 
                    311: #######################################################
                    312: #######################################################
1.2       stredwic  313: sub CreateInterface {
1.4       stredwic  314:     my $Str = '';
1.95      matthew   315:     $Str .= &Apache::lonhtmlcommon::breadcrumbs(undef,'Chart');
1.30      matthew   316: #    $Str .= &CreateLegend();
                    317:     $Str .= '<table cellspacing="5">'."\n";
                    318:     $Str .= '<tr>';
1.75      matthew   319:     $Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>';
                    320:     $Str .= '<td align="center"><b>'.&mt('Student Data</b>').'</td>';
                    321:     $Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>';
                    322:     $Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>';
                    323:     $Str .= '<td align="center"><b>'.&mt('Output Format').'</b>'.
1.58      matthew   324:         &Apache::loncommon::help_open_topic("Chart_Output_Formats").
                    325:         '</td>';
1.75      matthew   326:     $Str .= '<td align="center"><b>'.&mt('Output Data').'</b>'.
1.58      matthew   327:         &Apache::loncommon::help_open_topic("Chart_Output_Data").
                    328:         '</td>';
1.30      matthew   329:     $Str .= '</tr>'."\n";
                    330:     #
1.4       stredwic  331:     $Str .= '<tr><td align="center">'."\n";
1.29      matthew   332:     $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
1.4       stredwic  333:     $Str .= '</td><td align="center">';
1.30      matthew   334:     $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple',
                    335:                                                       5,undef);
1.46      matthew   336:     $Str .= '</td><td>'."\n";
                    337:     $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
1.4       stredwic  338:     $Str .= '</td><td>'."\n";
1.112     matthew   339:     $Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5);
1.31      matthew   340:     $Str .= '</td><td>'."\n";
                    341:     $Str .= &CreateAndParseOutputSelector();
1.54      matthew   342:     $Str .= '</td><td>'."\n";
                    343:     $Str .= &CreateAndParseOutputDataSelector();
1.30      matthew   344:     $Str .= '</td></tr>'."\n";
                    345:     $Str .= '</table>'."\n";
1.75      matthew   346:     $Str .= '<input type="submit" name="Generate Chart" value="'.
                    347:         &mt('Generate Chart').'" />';
1.59      matthew   348:     $Str .= '&nbsp;'x5;
1.75      matthew   349:     $Str .= '<input type="submit" name="selectstudent" value="'.
                    350:         &mt('Select One Student').'" />';
1.59      matthew   351:     $Str .= '&nbsp;'x5;
1.75      matthew   352:     $Str .= '<input type="submit" name="ClearCache" value="'.
                    353:         &mt('Clear Caches').'" />';
1.61      www       354:     $Str .= '&nbsp;'x5;
1.108     matthew   355:     $Str .= 
1.110     albertel  356:         &mt('Status[_1]',
1.108     matthew   357:             '<input type="text" name="stats_status" size="60" value="" />');
1.61      www       358:     $Str .= '<br />';
1.4       stredwic  359:     return $Str;
1.1       stredwic  360: }
1.30      matthew   361: 
                    362: #######################################################
                    363: #######################################################
                    364: 
                    365: =pod
                    366: 
1.31      matthew   367: =item &CreateAndParseOutputSelector()
1.30      matthew   368: 
                    369: =cut
                    370: 
                    371: #######################################################
                    372: #######################################################
1.32      matthew   373: my @OutputOptions = 
                    374:     ({ name  => 'HTML, with links',
                    375:        value => 'html, with links',
1.33      matthew   376:        description => 'Output HTML with each symbol linked to the problem '.
1.35      matthew   377: 	   'which generated it.',
                    378:        mode => 'html',
                    379:        show_links => 'yes',
                    380:        },
1.47      matthew   381:      { name  => 'HTML, with all links',
                    382:        value => 'html, with all links',
                    383:        description => 'Output HTML with each symbol linked to the problem '.
                    384: 	   'which generated it.  '.
                    385:            'This includes links for unattempted problems.',
                    386:        mode => 'html',
                    387:        show_links => 'all',
                    388:        },
1.32      matthew   389:      { name  => 'HTML, without links',
                    390:        value => 'html, without links',
1.33      matthew   391:        description => 'Output HTML.  By not including links, the size of the'.
                    392: 	   ' web page is greatly reduced.  If your browser crashes on the '.
1.35      matthew   393: 	   'full display, try this.',
                    394:        mode => 'html',
                    395:        show_links => 'no',
                    396:            },
1.54      matthew   397:      { name  => 'Excel',
                    398:        value => 'excel',
                    399:        description => 'Output an Excel file (compatable with Excel 95).',
1.35      matthew   400:        mode => 'excel',
                    401:        show_links => 'no',
1.54      matthew   402:    },
                    403:      { name  => 'CSV',
                    404:        value => 'csv',
1.96      www       405:        description => 'Output a comma separated values file suitable for '.
1.57      matthew   406:            'import into a spreadsheet program.  Using this method as opposed '.
                    407:            'to Excel output allows you to organize your data before importing'.
                    408:            ' it into a spreadsheet program.',
1.35      matthew   409:        mode => 'csv',
                    410:        show_links => 'no',
                    411:            },
1.32      matthew   412:      );
                    413: 
1.33      matthew   414: sub OutputDescriptions {
                    415:     my $Str = '';
1.58      matthew   416:     $Str .= "<h2>Output Formats</h2>\n";
1.33      matthew   417:     $Str .= "<dl>\n";
                    418:     foreach my $outputmode (@OutputOptions) {
                    419: 	$Str .="    <dt>".$outputmode->{'name'}."</dt>\n";
                    420: 	$Str .="        <dd>".$outputmode->{'description'}."</dd>\n";
                    421:     }
                    422:     $Str .= "</dl>\n";
                    423:     return $Str;
                    424: }
                    425: 
1.31      matthew   426: sub CreateAndParseOutputSelector {
                    427:     my $Str = '';
1.44      matthew   428:     my $elementname = 'chartoutputmode';
1.73      matthew   429:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    430:                                             [$elementname]);
1.31      matthew   431:     #
                    432:     # Format for output options is 'mode, restrictions';
1.50      matthew   433:     my $selected = 'html, without links';
1.31      matthew   434:     if (exists($ENV{'form.'.$elementname})) {
                    435:         if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
                    436:             $selected = $ENV{'form.'.$elementname}->[0];
                    437:         } else {
                    438:             $selected = $ENV{'form.'.$elementname};
                    439:         }
                    440:     }
                    441:     #
                    442:     # Set package variables describing output mode
                    443:     $show_links  = 'no';
                    444:     $output_mode = 'html';
1.35      matthew   445:     foreach my $option (@OutputOptions) {
                    446:         next if ($option->{'value'} ne $selected);
                    447:         $output_mode = $option->{'mode'};
                    448:         $show_links  = $option->{'show_links'};
1.31      matthew   449:     }
1.35      matthew   450: 
1.31      matthew   451:     #
                    452:     # Build the form element
                    453:     $Str = qq/<select size="5" name="$elementname">/;
1.32      matthew   454:     foreach my $option (@OutputOptions) {
                    455:         $Str .= "\n".'    <option value="'.$option->{'value'}.'"';
                    456:         $Str .= " selected " if ($option->{'value'} eq $selected);
1.75      matthew   457:         $Str .= ">".&mt($option->{'name'})."<\/option>";
1.31      matthew   458:     }
                    459:     $Str .= "\n</select>";
                    460:     return $Str;
                    461: }
1.30      matthew   462: 
1.54      matthew   463: ##
                    464: ## Data selector stuff
                    465: ##
                    466: my @OutputDataOptions =
1.57      matthew   467:     (
1.72      matthew   468:      { name  => 'Scores Summary',
1.57      matthew   469:        base  => 'scores',
                    470:        value => 'sum and total',
1.87      matthew   471:        scores => 1,
                    472:        tries  => 0,
                    473:        every_problem => 0,
                    474:        sequence_sum => 1,
                    475:        sequence_max => 1,
                    476:        grand_total => 1,
1.101     matthew   477:        grand_maximum => 1,
1.89      matthew   478:        summary_table => 1,
1.90      matthew   479:        maximum_row => 1,
1.57      matthew   480:        shortdesc => 'Total Score and Maximum Possible for each '.
                    481:            'Sequence or Folder',
                    482:        longdesc => 'The score of each student as well as the '.
                    483:            ' maximum possible on each Sequence or Folder.',
                    484:        },
1.71      matthew   485:      { name  => 'Scores Per Problem',
1.57      matthew   486:        base  => 'scores',
1.71      matthew   487:        value => 'scores',
1.87      matthew   488:        scores => 1,
                    489:        tries  => 0,
                    490:        correct => 0,
                    491:        every_problem => 1,
                    492:        sequence_sum => 1,
                    493:        sequence_max => 1,
                    494:        grand_total => 1,
1.101     matthew   495:        grand_maximum => 1,
1.89      matthew   496:        summary_table => 1,
1.90      matthew   497:        maximum_row => 1,
1.71      matthew   498:        shortdesc => 'Score on each Problem Part',
                    499:        longdesc =>'The students score on each problem part, computed as'.
                    500:            'the part weight * part awarded',
1.57      matthew   501:        },
                    502:      { name  =>'Tries',
                    503:        base  =>'tries',
                    504:        value => 'tries',
1.87      matthew   505:        scores => 0,
                    506:        tries  => 1,
                    507:        correct => 0,
                    508:        every_problem => 1,
                    509:        sequence_sum => 0,
                    510:        sequence_max => 0,
                    511:        grand_total => 0,
1.101     matthew   512:        grand_maximum => 0,
1.90      matthew   513:        summary_table => 0,
                    514:        maximum_row => 0,
1.57      matthew   515:        shortdesc => 'Number of Tries before success on each Problem Part',
                    516:        longdesc =>'The number of tries before success on each problem part.',
1.109     matthew   517:        non_html_notes => 'negative values indicate an incorrect problem',
1.57      matthew   518:        },
                    519:      { name  =>'Parts Correct',
                    520:        base  =>'tries',
                    521:        value => 'parts correct total',
1.87      matthew   522:        scores => 0,
                    523:        tries  => 0,
                    524:        correct => 1,
                    525:        every_problem => 1,
                    526:        sequence_sum => 1,
                    527:        sequence_max => 1,
                    528:        grand_total => 1,
1.101     matthew   529:        grand_maximum => 1,
1.89      matthew   530:        summary_table => 1,
1.90      matthew   531:        maximum_row => 0,
1.57      matthew   532:        shortdesc => 'Number of Problem Parts completed successfully.',
                    533:        longdesc => 'The Number of Problem Parts completed successfully and '.
                    534:            'the maximum possible for each student',
                    535:        },
                    536:      );
                    537: 
                    538: sub HTMLifyOutputDataDescriptions {
                    539:     my $Str = '';
1.58      matthew   540:     $Str .= "<h2>Output Data</h2>\n";
1.57      matthew   541:     $Str .= "<dl>\n";
                    542:     foreach my $option (@OutputDataOptions) {
                    543:         $Str .= '    <dt>'.$option->{'name'}.'</dt>';
                    544:         $Str .= '<dd>'.$option->{'longdesc'}.'</dd>'."\n";
                    545:     }
                    546:     $Str .= "</dl>\n";
                    547:     return $Str;
                    548: }
1.54      matthew   549: 
                    550: sub CreateAndParseOutputDataSelector {
                    551:     my $Str = '';
                    552:     my $elementname = 'chartoutputdata';
                    553:     #
                    554:     my $selected = 'scores';
                    555:     if (exists($ENV{'form.'.$elementname})) {
                    556:         if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
                    557:             $selected = $ENV{'form.'.$elementname}->[0];
                    558:         } else {
                    559:             $selected = $ENV{'form.'.$elementname};
                    560:         }
                    561:     }
                    562:     #
1.87      matthew   563:     $chosen_output = $OutputDataOptions[0];
1.54      matthew   564:     foreach my $option (@OutputDataOptions) {
                    565:         if ($option->{'value'} eq $selected) {
1.87      matthew   566:             $chosen_output = $option;
1.54      matthew   567:         }
                    568:     }
                    569:     #
                    570:     # Build the form element
                    571:     $Str = qq/<select size="5" name="$elementname">/;
                    572:     foreach my $option (@OutputDataOptions) {
                    573:         $Str .= "\n".'    <option value="'.$option->{'value'}.'"';
1.87      matthew   574:         $Str .= " selected " if ($option->{'value'} eq $chosen_output->{'value'});
1.75      matthew   575:         $Str .= ">".&mt($option->{'name'})."<\/option>";
1.54      matthew   576:     }
                    577:     $Str .= "\n</select>";
                    578:     return $Str;
                    579: 
                    580: }
                    581: 
1.28      matthew   582: #######################################################
                    583: #######################################################
1.1       stredwic  584: 
1.28      matthew   585: =pod
                    586: 
1.31      matthew   587: =head2 HTML output routines
1.28      matthew   588: 
1.31      matthew   589: =item &html_initialize($r)
1.28      matthew   590: 
1.31      matthew   591: Create labels for the columns of student data to show.
1.28      matthew   592: 
1.31      matthew   593: =item &html_outputstudent($r,$student)
1.28      matthew   594: 
1.31      matthew   595: Return a line of the chart for a student.
1.28      matthew   596: 
1.31      matthew   597: =item &html_finish($r)
1.28      matthew   598: 
                    599: =cut
                    600: 
                    601: #######################################################
                    602: #######################################################
1.31      matthew   603: {
                    604:     my $padding;
                    605:     my $count;
                    606: 
1.39      matthew   607:     my $nodata_count; # The number of students for which there is no data
                    608:     my %prog_state;   # progress state used by loncommon PrgWin routines
1.102     matthew   609:     my $total_sum_width;
1.39      matthew   610: 
1.112     matthew   611:     my %width; # Holds sequence width information
                    612:     my @sequences;
                    613:     my $navmap; # Have to keep this around since weakref is a bit zealous
                    614: 
1.31      matthew   615: sub html_initialize {
                    616:     my ($r) = @_;
1.30      matthew   617:     #
                    618:     $padding = ' 'x3;
1.35      matthew   619:     $count = 0;
1.39      matthew   620:     $nodata_count = 0;
1.66      matthew   621:     undef(%prog_state);
1.112     matthew   622:     undef(%width);
                    623:     undef($navmap);
                    624:     undef(@sequences);
                    625:     &Apache::lonnet::logthis('called html_initialize');
1.30      matthew   626:     #
1.38      matthew   627:     $r->print("<h3>".$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
                    628:               "&nbsp;&nbsp;".localtime(time)."</h3>");
1.112     matthew   629:     #
1.87      matthew   630:     if ($chosen_output->{'base'} !~ /^final table/) {
                    631:         $r->print("<h3>".$chosen_output->{'shortdesc'}."</h3>");        
1.39      matthew   632:     }
1.31      matthew   633:     my $Str = "<pre>\n";
1.30      matthew   634:     # First, the @StudentData fields need to be listed
1.31      matthew   635:     my @to_show = &get_student_fields_to_show();
1.30      matthew   636:     foreach my $field (@to_show) {
                    637:         my $title=$Apache::lonstatistics::StudentData{$field}->{'title'};
                    638:         my $base =$Apache::lonstatistics::StudentData{$field}->{'base_width'};
                    639:         my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
                    640:         $Str .= $title.' 'x($width-$base).$padding;
                    641:     }
1.89      matthew   642:     #
                    643:     # Compute the column widths and output the sequence titles
1.102     matthew   644:     my $total_count;
1.112     matthew   645:     ($navmap,@sequences) = 
                    646:         &Apache::lonstatistics::sequences_with_assessments();
                    647:     if (! ref($navmap)) {
                    648:         # Unable to get data, so bail out
                    649:         $r->print("<h3>".
                    650:                   &mt('Unable to retrieve course information.').
                    651:                   '</h3>');
                    652:     }
                    653:     #
                    654:     # Compute sequence widths
                    655:     my $starttime = Time::HiRes::time;
                    656:     foreach my $seq (@sequences) {
                    657:         my $symb = $seq->symb;
                    658:         my $title = $seq->compTitle;
                    659:         $width{$symb}->{'width_sum'} = 0;
                    660:         # Compute width of sum
1.89      matthew   661:         if ($chosen_output->{'sequence_sum'}) {
1.99      matthew   662:             if ($chosen_output->{'every_problem'}) {
                    663:                 # Use 1 digit for a space
1.112     matthew   664:                 $width{$symb}->{'width_sum'} += 1;            
1.99      matthew   665:             }
1.112     matthew   666: 	    $total_count += $width{$symb}->{'num_assess_parts'};
1.89      matthew   667:             # Use 3 digits for the sum
1.112     matthew   668:             $width{$symb}->{'width_sum'} += 3;
1.89      matthew   669:         }
1.112     matthew   670:         # Compute width of maximum
1.89      matthew   671:         if ($chosen_output->{'sequence_max'}) {
1.112     matthew   672:             if ($width{$symb}->{'width_sum'}>0) {
1.89      matthew   673:                 # One digit for the '/'
1.112     matthew   674:                 $width{$symb}->{'width_sum'} +=1;
1.89      matthew   675:             }
                    676:             # Use 3 digits for the total
1.112     matthew   677:             $width{$symb}->{'width_sum'}+=3;
1.89      matthew   678:         }
1.94      matthew   679: 	#
1.89      matthew   680:         if ($chosen_output->{'every_problem'}) {
                    681:             # one problem per digit
1.112     matthew   682:             $width{$symb}->{'width_parts'}=0;
                    683:             $starttime = Time::HiRes::time;
                    684:             my @resources = 
                    685:                 $navmap->retrieveResources($seq,sub { shift->is_problem(); },
                    686:                                            0,0,0);
                    687:             $starttime = Time::HiRes::time;
                    688:             foreach my $res (@resources) {
1.113   ! matthew   689:                 my @parts = @{$res->parts};
1.112     matthew   690:                 $width{$symb}->{'width_parts'} += scalar(@parts);
                    691:             } 
                    692:             &Apache::lonnet::logthis('2elapsed:'.(Time::HiRes::time-$starttime));            $width{$symb}->{'width_problem'} += 
                    693:                 $width{$symb}->{'width_parts'};
1.89      matthew   694:         } else {
1.112     matthew   695:             $width{$symb}->{'width_problem'} = 0;
1.89      matthew   696:         }
1.112     matthew   697:         $width{$symb}->{'width_total'} = $width{$symb}->{'width_problem'} + 
                    698:                                      $width{$symb}->{'width_sum'};
                    699:         if ($width{$symb}->{'width_total'} < length(&HTML::Entities::decode($title))) {
                    700:             $width{$symb}->{'width_total'} = length(&HTML::Entities::decode($title));
1.89      matthew   701:         }
                    702:         #
                    703:         # Output the sequence titles
1.112     matthew   704:         $Str .= $title.(' 'x($width{$symb}->{'width_total'}-
                    705:                             length($title)
                    706:                             )).$padding;
1.30      matthew   707:     }
1.102     matthew   708:     $total_sum_width = length($total_count)+1;
                    709:     $Str .= "    total</pre>\n";
1.31      matthew   710:     $Str .= "<pre>";
                    711:     $r->print($Str);
                    712:     $r->rflush();
                    713:     return;
1.30      matthew   714: }
                    715: 
1.31      matthew   716: sub html_outputstudent {
                    717:     my ($r,$student) = @_;
1.2       stredwic  718:     my $Str = '';
1.112     matthew   719:     return if (! defined($navmap));
1.35      matthew   720:     #
1.87      matthew   721:     if($count++ % 5 == 0 && $count > 0) {
1.35      matthew   722:         $r->print("</pre><pre>");
                    723:     }
1.30      matthew   724:     # First, the @StudentData fields need to be listed
1.31      matthew   725:     my @to_show = &get_student_fields_to_show();
1.30      matthew   726:     foreach my $field (@to_show) {
                    727:         my $title=$student->{$field};
1.103     matthew   728:         # Deal with 'comments' - how I love special cases
                    729:         if ($field eq 'comments') {
                    730:             $title = '<a href="/adm/'.$student->{'domain'}.'/'.$student->{'username'}.'/'.'aboutme#coursecomment">'.&mt('Comments').'</a>';
                    731:         }
1.31      matthew   732:         my $base = length($title);
1.30      matthew   733:         my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
                    734:         $Str .= $title.' 'x($width-$base).$padding;
                    735:     }
                    736:     # Get ALL the students data
                    737:     my %StudentsData;
                    738:     my @tmp = &Apache::loncoursedata::get_current_state
                    739:         ($student->{'username'},$student->{'domain'},undef,
                    740:          $ENV{'request.course.id'});
                    741:     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
                    742:         %StudentsData = @tmp;
                    743:     }
                    744:     if (scalar(@tmp) < 1) {
1.39      matthew   745:         $nodata_count++;
1.30      matthew   746:         $Str .= '<font color="blue">No Course Data</font>'."\n";
1.31      matthew   747:         $r->print($Str);
                    748:         $r->rflush();
                    749:         return;
1.30      matthew   750:     }
                    751:     #
                    752:     # By sequence build up the data
                    753:     my $studentstats;
1.31      matthew   754:     my $PerformanceStr = '';
1.112     matthew   755:     foreach my $seq (@sequences) {
                    756:         &Apache::lonnet::logthis('computing student data for '.$seq->compTitle);
1.54      matthew   757:         my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87      matthew   758:         if ($chosen_output->{'tries'}) {
1.54      matthew   759:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.112     matthew   760:                 &student_tries_on_sequence($student,\%StudentsData,
                    761:                                            $navmap,$seq,$show_links);
1.54      matthew   762:         } else {
                    763:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.112     matthew   764:                 &student_performance_on_sequence($student,\%StudentsData,
                    765:                                                  $navmap,$seq,$show_links);
1.54      matthew   766:         }
1.89      matthew   767:         my $ratio='';
1.99      matthew   768:         if ($chosen_output->{'every_problem'}) {
                    769:             $ratio .= ' ';
                    770:         }
1.97      matthew   771:         if ($chosen_output->{'sequence_sum'} && $score ne ' ') {
1.99      matthew   772:             $ratio .= sprintf("%3.0f",$score);
1.98      matthew   773:         } elsif($chosen_output->{'sequence_sum'}) {
1.97      matthew   774:             $ratio .= ' 'x3;
1.89      matthew   775:         }
                    776:         if ($chosen_output->{'sequence_max'}) {
                    777:             if ($chosen_output->{'sequence_sum'}) {
                    778:                 $ratio .= '/';
                    779:             }
1.99      matthew   780:             $ratio .= sprintf("%3.0f",$seq_max);
1.89      matthew   781:         }
1.31      matthew   782:         #
1.89      matthew   783:         if (! $chosen_output->{'every_problem'}) {
                    784:             $performance = '';
1.94      matthew   785: 	    $performance_length=0;
1.30      matthew   786:         }
1.112     matthew   787:         $performance .= ' 'x($width{$seq->symb}->{'width_total'} -
                    788:                              $performance_length -
                    789:                              $width{$seq->symb}->{'width_sum'}).
1.89      matthew   790:             $ratio;
1.31      matthew   791:         #
                    792:         $Str .= $performance.$padding;
                    793:         #
1.112     matthew   794:         $studentstats->{$seq->symb}->{'score'}= $score;
                    795:         $studentstats->{$seq->symb}->{'max'}  = $seq_max;
1.30      matthew   796:     }
                    797:     #
                    798:     # Total it up and store the statistics info.
1.97      matthew   799:     my ($score,$max);
1.30      matthew   800:     while (my ($symb,$seq_stats) = each (%{$studentstats})) {
                    801:         $Statistics->{$symb}->{'score'} += $seq_stats->{'score'};
1.54      matthew   802:         if ($Statistics->{$symb}->{'max'} < $seq_stats->{'max'}) {
                    803:             $Statistics->{$symb}->{'max'} = $seq_stats->{'max'};
                    804:         }
1.97      matthew   805:         if ($seq_stats->{'score'} ne ' ') {
                    806:             $score += $seq_stats->{'score'};
                    807:             $Statistics->{$symb}->{'num_students'}++;
                    808:         }
1.30      matthew   809:         $max   += $seq_stats->{'max'};
                    810:     }
1.97      matthew   811:     if (! defined($score)) {
1.102     matthew   812:         $score = ' ' x $total_sum_width;
1.105     matthew   813:     } else {
                    814:         $score = sprintf("%.0f",$score);
1.97      matthew   815:     }
1.102     matthew   816:     $Str .= ' '.' 'x($total_sum_width-length($score)).$score.' / '.$max;
1.30      matthew   817:     $Str .= " \n";
1.39      matthew   818:     #
1.31      matthew   819:     $r->print($Str);
                    820:     #
                    821:     $r->rflush();
                    822:     return;
1.30      matthew   823: }    
1.2       stredwic  824: 
1.31      matthew   825: sub html_finish {
                    826:     my ($r) = @_;
1.112     matthew   827:     return if (! defined($navmap));
1.39      matthew   828:     #
                    829:     # Check for suppressed output and close the progress window if so
1.87      matthew   830:     $r->print("</pre>\n"); 
1.90      matthew   831:     if ($chosen_output->{'summary_table'}) {
                    832:         if ($single_student_mode) {
                    833:             $r->print(&SingleStudentTotal());
                    834:         } else {
                    835:             $r->print(&StudentAverageTotal());
                    836:         }
1.49      matthew   837:     }
1.31      matthew   838:     $r->rflush();
1.112     matthew   839:     undef($navmap);
1.31      matthew   840:     return;
                    841: }
                    842: 
1.39      matthew   843: sub StudentAverageTotal {
1.105     matthew   844:     my $Str = '<h3>'.&mt('Summary Tables').'</h3>'.$/;
1.39      matthew   845:     $Str .= '<table border=2 cellspacing="1">'."\n";
1.105     matthew   846:     $Str .= '<tr>'.
                    847:         '<th>'.&mt('Title').'</th>'.
                    848:         '<th>'.&mt('Average').'</th>'.
                    849:         '<th>'.&mt('Maximum').'</th>'.
                    850:         '</tr>'.$/;
1.112     matthew   851:     foreach my $seq (@sequences) {
                    852:         my $symb = $seq->symb;
1.42      matthew   853:         my $ave;
1.112     matthew   854:         my $num_students = $Statistics->{$symb}->{'num_students'};
1.97      matthew   855:         if ($num_students > 0) {
                    856:             $ave = int(100*
1.112     matthew   857:                        ($Statistics->{$symb}->{'score'}/$num_students)
1.97      matthew   858:                        )/100;
1.42      matthew   859:         } else {
                    860:             $ave = 0;
                    861:         }
1.112     matthew   862:         my $max = $Statistics->{$symb}->{'max'};
1.82      matthew   863:         $ave = sprintf("%.2f",$ave);
1.112     matthew   864:         $Str .= '<tr><td>'.$seq->compTitle.'</td>'.
1.82      matthew   865:             '<td align="right">'.$ave.'&nbsp;</td>'.
                    866:             '<td align="right">'.$max.'&nbsp;'.'</td></tr>'."\n";
1.39      matthew   867:     }
                    868:     $Str .= "</table>\n";
                    869:     return $Str;
                    870: }
                    871: 
1.49      matthew   872: sub SingleStudentTotal {
                    873:     my $student = &Apache::lonstatistics::current_student();
1.105     matthew   874:     my $Str = '<h3>'.&mt('Summary table for [_1] ([_2]@[_3])',
                    875:                          $student->{'fullname'},
                    876:                          $student->{'username'},$student->{'domain'}).'</h3>';
                    877:     $Str .= $/;
1.49      matthew   878:     $Str .= '<table border=2 cellspacing="1">'."\n";
                    879:     $Str .= 
1.105     matthew   880:         '<tr>'.
                    881:         '<th>'.&mt('Sequence or Folder').'</th>';
                    882:     if ($chosen_output->{'base'} eq 'tries') {
                    883:         $Str .= '<th>'.&mt('Parts Correct').'</th>';
                    884:     } else {
                    885:         $Str .= '<th>'.&mt('Score').'</th>';
                    886:     }
                    887:     $Str .= '<th>'.&mt('Maximum').'</th>'."</tr>\n";
1.49      matthew   888:     my $total = 0;
                    889:     my $total_max = 0;
                    890:     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
1.112     matthew   891:         my $value = $Statistics->{$seq->symb}->{'score'};
                    892:         my $max = $Statistics->{$seq->symb}->{'max'};
                    893:         $Str .= '<tr><td>'.&HTML::Entities::encode($seq->compTitle).'</td>'.
1.49      matthew   894:             '<td align="right">'.$value.'</td>'.
                    895:                 '<td align="right">'.$max.'</td></tr>'."\n";
                    896:         $total += $value;
                    897:         $total_max +=$max;
                    898:     }
1.105     matthew   899:     $Str .= '<tr><td><b>'.&mt('Total').'</b></td>'.
1.49      matthew   900:         '<td align="right">'.$total.'</td>'.
                    901:         '<td align="right">'.$total_max."</td></tr>\n";
                    902:     $Str .= "</table>\n";
                    903:     return $Str;
                    904: }
                    905: 
1.31      matthew   906: }
                    907: 
                    908: #######################################################
                    909: #######################################################
                    910: 
                    911: =pod
                    912: 
                    913: =head2 EXCEL subroutines
                    914: 
                    915: =item &excel_initialize($r)
                    916: 
                    917: =item &excel_outputstudent($r,$student)
                    918: 
                    919: =item &excel_finish($r)
                    920: 
                    921: =cut
                    922: 
                    923: #######################################################
                    924: #######################################################
                    925: {
                    926: 
                    927: my $excel_sheet;
1.32      matthew   928: my $excel_workbook;
                    929: 
                    930: my $filename;
                    931: my $rows_output;
                    932: my $cols_output;
                    933: 
1.36      matthew   934: my %prog_state; # progress window state
1.54      matthew   935: my $request_aborted;
1.31      matthew   936: 
1.76      matthew   937: my $total_formula;
1.101     matthew   938: my $maximum_formula;
1.76      matthew   939: 
1.31      matthew   940: sub excel_initialize {
                    941:     my ($r) = @_;
                    942:     #
1.66      matthew   943:     undef ($excel_sheet);
                    944:     undef ($excel_workbook);
                    945:     undef ($filename);
                    946:     undef ($rows_output);
                    947:     undef ($cols_output);
                    948:     undef (%prog_state);
                    949:     undef ($request_aborted);
1.76      matthew   950:     undef ($total_formula);
1.101     matthew   951:     undef ($maximum_formula);
1.66      matthew   952:     #
1.54      matthew   953:     my $total_columns = scalar(&get_student_fields_to_show());
1.90      matthew   954:     my $num_students = scalar(@Apache::lonstatistics::Students);
                    955:     #
1.54      matthew   956:     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
1.88      matthew   957:         if ($chosen_output->{'every_problem'}) {
                    958:             $total_columns += $seq->{'num_assess_parts'};
                    959:         }
1.87      matthew   960:         # Add 2 because we need a 'sequence_sum' and 'total' column for each
1.88      matthew   961:         $total_columns += 2;
1.54      matthew   962:     }
1.105     matthew   963:     my $too_many_cols_error_message = 
                    964:         '<h2>'.&mt('Unable to Complete Request').'</h2>'.$/.
                    965:         '<p>'.&mt('LON-CAPA is unable to produce your Excel spreadsheet because your selections will result in more than 255 columns.  Excel allows only 255 columns in a spreadsheet.').'</p>'.$/.
                    966:         '<p>'.&mt('You may consider reducing the number of <b>Sequences or Folders</b> you have selected.').'</p>'.$/.
                    967:         '<p>'.&mt('LON-CAPA can produce <b>CSV</b> files of this data or Excel files of the <b>Scores Summary</b> data.').'</p>'.$/;
1.87      matthew   968:     if ($chosen_output->{'base'} eq 'tries' && $total_columns > 255) {
1.105     matthew   969:         $r->print($too_many_cols_error_message);
                    970:         $request_aborted = 1;
1.54      matthew   971:     }
1.87      matthew   972:     if ($chosen_output->{'base'} eq 'scores' && $total_columns > 255) {
1.105     matthew   973:         $r->print($too_many_cols_error_message);
                    974:         $request_aborted = 1;
1.54      matthew   975:     }
                    976:     return if ($request_aborted);
                    977:     #
1.32      matthew   978:     $filename = '/prtspool/'.
1.31      matthew   979:         $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
                    980:             time.'_'.rand(1000000000).'.xls';
1.32      matthew   981:     #
                    982:     $excel_workbook = undef;
                    983:     $excel_sheet = undef;
                    984:     #
                    985:     $rows_output = 0;
                    986:     $cols_output = 0;
                    987:     #
1.90      matthew   988:     # Determine rows 
                    989:     my $header_row = $rows_output++;
                    990:     my $description_row = $rows_output++;
1.109     matthew   991:     my $notes_row = $rows_output++;
1.90      matthew   992:     $rows_output++;        # blank row
                    993:     my $summary_header_row;
                    994:     if ($chosen_output->{'summary_table'}) {
                    995:         $summary_header_row = $rows_output++;
                    996:         $rows_output+= scalar(&Apache::lonstatistics::Sequences_with_Assess());
                    997:         $rows_output++;
                    998:     }
                    999:     my $sequence_name_row = $rows_output++;
                   1000:     my $resource_name_row = $rows_output++;
                   1001:     my $maximum_data_row = $rows_output++;
                   1002:     if (! $chosen_output->{'maximum_row'}) {
                   1003:         $rows_output--;
                   1004:     }
                   1005:     my $first_data_row = $rows_output++;
                   1006:     #
1.32      matthew  1007:     # Create sheet
                   1008:     $excel_workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename);
                   1009:     #
                   1010:     # Check for errors
                   1011:     if (! defined($excel_workbook)) {
1.31      matthew  1012:         $r->log_error("Error creating excel spreadsheet $filename: $!");
                   1013:         $r->print("Problems creating new Excel file.  ".
                   1014:                   "This error has been logged.  ".
                   1015:                   "Please alert your LON-CAPA administrator");
1.32      matthew  1016:         return ;
1.31      matthew  1017:     }
                   1018:     #
                   1019:     # The excel spreadsheet stores temporary data in files, then put them
                   1020:     # together.  If needed we should be able to disable this (memory only).
                   1021:     # The temporary directory must be specified before calling 'addworksheet'.
                   1022:     # File::Temp is used to determine the temporary directory.
1.32      matthew  1023:     $excel_workbook->set_tempdir($Apache::lonnet::tmpdir);
                   1024:     #
1.91      matthew  1025:     my $format = &Apache::loncommon::define_excel_formats($excel_workbook);
                   1026:     #
1.32      matthew  1027:     # Add a worksheet
1.33      matthew  1028:     my $sheetname = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1.67      matthew  1029:     $sheetname = &Apache::loncommon::clean_excel_name($sheetname);
1.33      matthew  1030:     $excel_sheet = $excel_workbook->addworksheet($sheetname);
1.85      matthew  1031:     #
1.34      matthew  1032:     # Put the course description in the header
1.90      matthew  1033:     $excel_sheet->write($header_row,$cols_output++,
1.85      matthew  1034:                    $ENV{'course.'.$ENV{'request.course.id'}.'.description'},
                   1035:                         $format->{'h1'});
1.34      matthew  1036:     $cols_output += 3;
                   1037:     #
                   1038:     # Put a description of the sections listed
                   1039:     my $sectionstring = '';
                   1040:     my @Sections = @Apache::lonstatistics::SelectedSections;
                   1041:     if (scalar(@Sections) > 1) {
                   1042:         if (scalar(@Sections) > 2) {
                   1043:             my $last = pop(@Sections);
                   1044:             $sectionstring = "Sections ".join(', ',@Sections).', and '.$last;
                   1045:         } else {
                   1046:             $sectionstring = "Sections ".join(' and ',@Sections);
                   1047:         }
                   1048:     } else {
                   1049:         if ($Sections[0] eq 'all') {
                   1050:             $sectionstring = "All sections";
                   1051:         } else {
                   1052:             $sectionstring = "Section ".$Sections[0];
                   1053:         }
                   1054:     }
1.90      matthew  1055:     $excel_sheet->write($header_row,$cols_output++,$sectionstring,
1.85      matthew  1056:                         $format->{'h3'});
1.34      matthew  1057:     $cols_output += scalar(@Sections);
                   1058:     #
                   1059:     # Put the date in there too
1.90      matthew  1060:     $excel_sheet->write($header_row,$cols_output++,
1.85      matthew  1061:                         'Compiled on '.localtime(time),$format->{'h3'});
1.34      matthew  1062:     #
1.54      matthew  1063:     $cols_output = 0;
1.90      matthew  1064:     $excel_sheet->write($description_row,$cols_output++,
1.87      matthew  1065:                         $chosen_output->{'shortdesc'},
1.109     matthew  1066:                         $format->{'b'});
                   1067:     #
                   1068:     $cols_output = 0;
                   1069:     $excel_sheet->write($notes_row,$cols_output++,
                   1070:                         $chosen_output->{'non_html_notes'},
                   1071:                         $format->{'i'});
                   1072:     
1.90      matthew  1073:     ##############################################
                   1074:     # Output headings for the raw data
                   1075:     ##############################################
1.86      matthew  1076:     #
1.32      matthew  1077:     # Add the student headers
1.34      matthew  1078:     $cols_output = 0;
1.32      matthew  1079:     foreach my $field (&get_student_fields_to_show()) {
1.86      matthew  1080:         $excel_sheet->write($resource_name_row,$cols_output++,$field,
1.85      matthew  1081:                             $format->{'bold'});
1.32      matthew  1082:     }
                   1083:     #
1.54      matthew  1084:     # Add the remaining column headers
1.76      matthew  1085:     my $total_formula_string = '=0';
1.101     matthew  1086:     my $maximum_formula_string = '=0';
1.40      matthew  1087:     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
1.86      matthew  1088:         $excel_sheet->write($sequence_name_row,,
1.90      matthew  1089:                             $cols_output,$seq->{'title'},$format->{'bold'});
1.86      matthew  1090:         # Determine starting cell
                   1091:         $seq->{'Excel:startcell'}=
                   1092:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90      matthew  1093:             ($first_data_row,$cols_output);
1.86      matthew  1094:         $seq->{'Excel:startcol'}=$cols_output;
1.87      matthew  1095:         my $count = 0;
                   1096:         if ($chosen_output->{'every_problem'}) {
1.76      matthew  1097:             # Put the names of the problems and parts into the sheet
1.54      matthew  1098:             foreach my $res (@{$seq->{'contents'}}) {
1.84      matthew  1099:                 if ($res->{'type'} ne 'assessment'  || 
                   1100:                     ! exists($res->{'parts'})       ||
                   1101:                     ref($res->{'parts'}) ne 'ARRAY' ||
                   1102:                     scalar(@{$res->{'parts'}}) < 1) {
                   1103:                     next;
                   1104:                 }
1.54      matthew  1105:                 if (scalar(@{$res->{'parts'}}) > 1) {
                   1106:                     foreach my $part (@{$res->{'parts'}}) {
1.86      matthew  1107:                         $excel_sheet->write($resource_name_row,
1.54      matthew  1108:                                             $cols_output++,
1.85      matthew  1109:                                             $res->{'title'}.' part '.$part,
                   1110:                                             $format->{'bold'});
1.106     matthew  1111:                         $count++;
1.54      matthew  1112:                     }
                   1113:                 } else {
1.86      matthew  1114:                     $excel_sheet->write($resource_name_row,
1.54      matthew  1115:                                         $cols_output++,
1.85      matthew  1116:                                         $res->{'title'},$format->{'bold'});
1.106     matthew  1117:                     $count++;
1.54      matthew  1118:                 }
                   1119:             }
1.79      matthew  1120:         }
1.87      matthew  1121:         # Determine ending cell
                   1122:         if ($count <= 1) {
                   1123:             $seq->{'Excel:endcell'} = $seq->{'Excel:startcell'};
                   1124:             $seq->{'Excel:endcol'}  = $seq->{'Excel:startcol'};
                   1125:         } else {
                   1126:             $seq->{'Excel:endcell'} = 
                   1127:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90      matthew  1128:                 ($first_data_row,$cols_output-1);
1.87      matthew  1129:             $seq->{'Excel:endcol'} = $cols_output-1;
                   1130:         }
                   1131:         # Create the formula for summing up this sequence
                   1132:         if (! exists($seq->{'Excel:endcell'}) ||
                   1133:             ! defined($seq->{'Excel:endcell'})) {
                   1134:             $seq->{'Excel:endcell'} = $seq->{'Excel:startcell'};
                   1135:         }
                   1136:         $seq->{'Excel:sum'}= $excel_sheet->store_formula
                   1137:             ('=SUM('.$seq->{'Excel:startcell'}.
                   1138:              ':'.$seq->{'Excel:endcell'}.')');
1.79      matthew  1139:         # Determine cell the score is held in
                   1140:         $seq->{'Excel:scorecell'} = 
                   1141:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90      matthew  1142:             ($first_data_row,$cols_output);
1.79      matthew  1143:         $seq->{'Excel:scorecol'}=$cols_output;
1.87      matthew  1144:         if ($chosen_output->{'base'} eq 'parts correct total') {
1.86      matthew  1145:             $excel_sheet->write($resource_name_row,$cols_output++,
                   1146:                                 'parts correct',
1.85      matthew  1147:                                 $format->{'bold'});
1.87      matthew  1148:         } elsif ($chosen_output->{'sequence_sum'}) {
                   1149:             if ($chosen_output->{'correct'}) {
                   1150:                 # Only reporting the number correct, so do not call it score
                   1151:                 $excel_sheet->write($resource_name_row,$cols_output++,
                   1152:                                     'sum',
                   1153:                                     $format->{'bold'});
                   1154:             } else {
                   1155:                 $excel_sheet->write($resource_name_row,$cols_output++,
                   1156:                                     'score',
                   1157:                                     $format->{'bold'});
                   1158:             }
1.32      matthew  1159:         }
1.79      matthew  1160:         #
                   1161:         $total_formula_string.='+'.
                   1162:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90      matthew  1163:             ($first_data_row,$cols_output-1);
1.87      matthew  1164:         if ($chosen_output->{'sequence_max'}) {
1.101     matthew  1165:             $excel_sheet->write($resource_name_row,$cols_output,
1.87      matthew  1166:                                 'maximum',
                   1167:                                 $format->{'bold'});
1.101     matthew  1168:             $seq->{'Excel:maxcell'} = 
                   1169:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1170:                 ($first_data_row,$cols_output);
                   1171:             $seq->{'Excel:maxcol'}=$cols_output;
                   1172:             $maximum_formula_string.='+'.
                   1173:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1174:                 ($first_data_row,$cols_output);
                   1175:             $cols_output++;
                   1176: 
1.87      matthew  1177:         }
                   1178:     }
                   1179:     if ($chosen_output->{'grand_total'}) {
                   1180:         $excel_sheet->write($resource_name_row,$cols_output++,'Total',
1.85      matthew  1181:                             $format->{'bold'});
1.32      matthew  1182:     }
1.101     matthew  1183:     if ($chosen_output->{'grand_maximum'}) {
                   1184:         $excel_sheet->write($resource_name_row,$cols_output++,'Max. Total',
                   1185:                             $format->{'bold'});
                   1186:     }
1.76      matthew  1187:     $total_formula = $excel_sheet->store_formula($total_formula_string);
1.101     matthew  1188:     $maximum_formula = $excel_sheet->store_formula($maximum_formula_string);
1.90      matthew  1189:     ##############################################
1.87      matthew  1190:     # Output a row for MAX, if appropriate
1.90      matthew  1191:     ##############################################
                   1192:     if ($chosen_output->{'maximum_row'}) {
1.87      matthew  1193:         $cols_output = 0;
                   1194:         foreach my $field (&get_student_fields_to_show()) {
                   1195:             if ($field eq 'username' || $field eq 'fullname' || 
                   1196:                 $field eq 'id') {
                   1197:                 $excel_sheet->write($maximum_data_row,$cols_output++,'Maximum',
                   1198:                                     $format->{'bold'});
                   1199:             } else {
                   1200:                 $excel_sheet->write($maximum_data_row,$cols_output++,'');
                   1201:             }
1.54      matthew  1202:         }
1.87      matthew  1203:         #
                   1204:         # Add the maximums for each sequence or assessment
                   1205:         my %total_cell_translation;
1.101     matthew  1206:         my %maximum_cell_translation;
1.87      matthew  1207:         foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
                   1208:             $cols_output=$seq->{'Excel:startcol'};
                   1209:             $total_cell_translation{$seq->{'Excel:scorecell'}} = 
                   1210:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1211:                 ($maximum_data_row,$seq->{'Excel:scorecol'});
1.101     matthew  1212:             $maximum_cell_translation{$seq->{'Excel:maxcell'}} = 
                   1213:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1214:                 ($maximum_data_row,$seq->{'Excel:maxcol'});
1.87      matthew  1215:             my $weight;
                   1216:             my $max = 0;
                   1217:             foreach my $resource (@{$seq->{'contents'}}) {
                   1218:                 next if ($resource->{'type'} ne 'assessment');
                   1219:                 foreach my $part (@{$resource->{'parts'}}) {
                   1220:                     $weight = 1;
                   1221:                     if ($chosen_output->{'scores'}) {
                   1222:                         $weight = &Apache::lonnet::EXT
                   1223:                             ('resource.'.$part.'.weight',$resource->{'symb'},
                   1224:                              undef,undef,undef);
                   1225:                         if (!defined($weight) || ($weight eq '')) { 
                   1226:                             $weight=1;
                   1227:                         }
                   1228:                     }
                   1229:                     if ($chosen_output->{'scores'} &&
                   1230:                         $chosen_output->{'every_problem'}) {
                   1231:                         $excel_sheet->write($maximum_data_row,$cols_output++,
                   1232:                                             $weight);
1.54      matthew  1233:                     }
1.87      matthew  1234:                     $max += $weight;
1.54      matthew  1235:                 }
1.87      matthew  1236:             } 
                   1237:             #
                   1238:             if ($chosen_output->{'sequence_sum'} && 
                   1239:                 $chosen_output->{'every_problem'}) {
1.110     albertel 1240: 		my %replaceCells=
                   1241: 		    ('^'.$seq->{'Excel:startcell'}.':'.
                   1242: 		         $seq->{'Excel:endcell'}.'$' =>
                   1243: 		     &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($maximum_data_row,$seq->{'Excel:startcol'}).':'.
                   1244: 		     &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($maximum_data_row,$seq->{'Excel:endcol'}));
1.87      matthew  1245:                 $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
                   1246:                                              $seq->{'Excel:sum'},undef,
1.110     albertel 1247: 					     %replaceCells);
                   1248: 			
1.87      matthew  1249:             } elsif ($chosen_output->{'sequence_sum'}) {
                   1250:                 $excel_sheet->write($maximum_data_row,$cols_output++,$max);
                   1251:             }
                   1252:             if ($chosen_output->{'sequence_max'}) {
                   1253:                 $excel_sheet->write($maximum_data_row,$cols_output++,$max);
1.45      matthew  1254:             }
1.87      matthew  1255:             #
1.45      matthew  1256:         }
1.87      matthew  1257:         if ($chosen_output->{'grand_total'}) {
1.86      matthew  1258:             $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
1.87      matthew  1259:                                          $total_formula,undef,
                   1260:                                          %total_cell_translation);
1.79      matthew  1261:         }
1.101     matthew  1262:         if ($chosen_output->{'grand_maximum'}) {
                   1263:             $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
                   1264:                                          $maximum_formula,undef,
1.107     matthew  1265:                                          %maximum_cell_translation);
1.101     matthew  1266:         }
1.90      matthew  1267:     } # End of MAXIMUM row output  if ($chosen_output->{'maximum_row'}) {
1.86      matthew  1268:     $rows_output = $first_data_row;
1.90      matthew  1269:     ##############################################
                   1270:     # Output summary table, which actually is above the sequence name row.
                   1271:     ##############################################
                   1272:     if ($chosen_output->{'summary_table'}) {
                   1273:         $cols_output = 0;
                   1274:         $excel_sheet->write($summary_header_row,$cols_output++,
                   1275:                             'Summary Table',$format->{'bold'});
                   1276:         if ($chosen_output->{'maximum_row'}) {
                   1277:             $excel_sheet->write($summary_header_row,$cols_output++,
                   1278:                                 'Maximum',$format->{'bold'});
                   1279:         }
                   1280:         $excel_sheet->write($summary_header_row,$cols_output++,
                   1281:                             'Average',$format->{'bold'});
                   1282:         $excel_sheet->write($summary_header_row,$cols_output++,
                   1283:                             'Median',$format->{'bold'});
                   1284:         $excel_sheet->write($summary_header_row,$cols_output++,
                   1285:                             'Std Dev',$format->{'bold'});
                   1286:         my $row = $summary_header_row+1;
                   1287:         foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
                   1288:             $cols_output = 0;
                   1289:             $excel_sheet->write($row,$cols_output++,
                   1290:                                 $seq->{'title'},
                   1291:                                 $format->{'bold'});
                   1292:             if ($chosen_output->{'maximum_row'}) {
                   1293:                 $excel_sheet->write
                   1294:                     ($row,$cols_output++,
                   1295:                      '='.
                   1296:                      &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1297:                      ($maximum_data_row,$seq->{'Excel:scorecol'})
                   1298:                      );
                   1299:             }
                   1300:             my $range = 
                   1301:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1302:                 ($first_data_row,$seq->{'Excel:scorecol'}).
                   1303:                 ':'.
                   1304:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1305:                 ($first_data_row+$num_students-1,$seq->{'Excel:scorecol'});
                   1306:             $excel_sheet->write($row,$cols_output++,
                   1307:                                 '=AVERAGE('.$range.')');
                   1308:             $excel_sheet->write($row,$cols_output++,
                   1309:                                 '=MEDIAN('.$range.')');
                   1310:             $excel_sheet->write($row,$cols_output++,
                   1311:                                 '=STDEV('.$range.')');
                   1312:             $row++;
                   1313:         }
                   1314:     }
                   1315:     ##############################################
                   1316:     #   Take care of non-excel initialization
                   1317:     ##############################################
1.32      matthew  1318:     #
                   1319:     # Let the user know what we are doing
                   1320:     my $studentcount = scalar(@Apache::lonstatistics::Students); 
1.85      matthew  1321:     if ($ENV{'form.SelectedStudent'}) {
                   1322:         $studentcount = '1';
                   1323:     }
                   1324:     if ($studentcount > 1) {
                   1325:         $r->print('<h1>'.&mt('Compiling Excel spreadsheet for [_1] students',
                   1326:                              $studentcount)."</h1>\n");
                   1327:     } else {
                   1328:         $r->print('<h1>'.
                   1329:                   &mt('Compiling Excel spreadsheet for 1 student').
                   1330:                   "</h1>\n");
                   1331:     }
1.32      matthew  1332:     $r->rflush();
1.31      matthew  1333:     #
1.36      matthew  1334:     # Initialize progress window
                   1335:     %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
                   1336:         ($r,'Excel File Compilation Status',
1.108     matthew  1337:          'Excel File Compilation Progress', $studentcount,
                   1338:          'inline',undef,'Statistics','stats_status');
1.36      matthew  1339:     #
1.62      matthew  1340:     &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,
                   1341:                                           'Processing first student');
1.31      matthew  1342:     return;
                   1343: }
                   1344: 
                   1345: sub excel_outputstudent {
                   1346:     my ($r,$student) = @_;
1.54      matthew  1347:     return if ($request_aborted);
1.32      matthew  1348:     return if (! defined($excel_sheet));
                   1349:     $cols_output=0;
                   1350:     #
                   1351:     # Write out student data
                   1352:     my @to_show = &get_student_fields_to_show();
                   1353:     foreach my $field (@to_show) {
1.103     matthew  1354:         my $value = $student->{$field};
                   1355:         if ($field eq 'comments') {
                   1356:             $value = &Apache::lonmsg::retrieve_instructor_comments
                   1357:                 ($student->{'username'},$student->{'domain'});
                   1358:         }
                   1359:         $excel_sheet->write($rows_output,$cols_output++,$value);
1.32      matthew  1360:     }
                   1361:     #
                   1362:     # Get student assessment data
                   1363:     my %StudentsData;
                   1364:     my @tmp = &Apache::loncoursedata::get_current_state($student->{'username'},
                   1365:                                                         $student->{'domain'},
                   1366:                                                         undef,
                   1367:                                                    $ENV{'request.course.id'});
                   1368:     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
                   1369:         %StudentsData = @tmp;
                   1370:     }
                   1371:     #
                   1372:     # Write out sequence scores and totals data
1.76      matthew  1373:     my %total_cell_translation;
1.101     matthew  1374:     my %maximum_cell_translation;
1.40      matthew  1375:     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
1.85      matthew  1376:         $cols_output = $seq->{'Excel:startcol'};
1.76      matthew  1377:         # Keep track of cells to translate in total cell
                   1378:         $total_cell_translation{$seq->{'Excel:scorecell'}} = 
                   1379:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1380:                         ($rows_output,$seq->{'Excel:scorecol'});
1.107     matthew  1381:         # and maximum cell
                   1382:         $maximum_cell_translation{$seq->{'Excel:maxcell'}} = 
                   1383:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1384:             ($rows_output,$seq->{'Excel:maxcol'});
1.76      matthew  1385:         #
1.54      matthew  1386:         my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87      matthew  1387:         if ($chosen_output->{'tries'} || $chosen_output->{'correct'}){
1.54      matthew  1388:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
                   1389:                 &StudentTriesOnSequence($student,\%StudentsData,
                   1390:                                         $seq,'no');
                   1391:         } else {
                   1392:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
                   1393:                 &StudentPerformanceOnSequence($student,\%StudentsData,
                   1394:                                               $seq,'no');
1.87      matthew  1395:         } 
                   1396:         if ($chosen_output->{'every_problem'}) {
                   1397:             if ($chosen_output->{'correct'}) {
                   1398:                 # only indiciate if each item is correct or not
                   1399:                 foreach my $value (@$rawdata) {
                   1400:                     # nonzero means correct
                   1401:                     $value = 1 if ($value > 0);
                   1402:                     $excel_sheet->write($rows_output,$cols_output++,$value);
                   1403:                 }
                   1404:             } else {
                   1405:                 foreach my $value (@$rawdata) {
1.97      matthew  1406:                     if ($score eq ' ' || !defined($value)) {
                   1407:                         $cols_output++;
                   1408:                     } else {                        
                   1409:                         $excel_sheet->write($rows_output,$cols_output++,
                   1410:                                             $value);
                   1411:                     }
1.87      matthew  1412:                 }
                   1413:             }
1.54      matthew  1414:         }
1.87      matthew  1415:         if ($chosen_output->{'sequence_sum'} && 
                   1416:             $chosen_output->{'every_problem'}) {
1.76      matthew  1417:             # Write a formula for the sum of this sequence
1.110     albertel 1418:             my %replaceCells=
                   1419: 		('^'.$seq->{'Excel:startcell'}.':'.$seq->{'Excel:endcell'}.'$'
                   1420: 		 => 
                   1421: 		 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($rows_output,$seq->{'Excel:startcol'}).':'.
                   1422: 		 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($rows_output,$seq->{'Excel:endcol'})
                   1423: 		 );
                   1424:             # The undef is for the format	    
                   1425: 	    $excel_sheet->repeat_formula($rows_output,$cols_output++,
                   1426: 					 $seq->{'Excel:sum'},undef,
                   1427: 					 %replaceCells);
1.87      matthew  1428:         } elsif ($chosen_output->{'sequence_sum'}) {
1.97      matthew  1429:             if ($score eq ' ') {
                   1430:                 $cols_output++;
                   1431:             } else {
                   1432:                 $excel_sheet->write($rows_output,$cols_output++,$score);
                   1433:             }
1.32      matthew  1434:         }
1.87      matthew  1435:         if ($chosen_output->{'sequence_max'}) {
1.32      matthew  1436:             $excel_sheet->write($rows_output,$cols_output++,$seq_max);
                   1437:         }
                   1438:     }
1.76      matthew  1439:     #
1.87      matthew  1440:     if ($chosen_output->{'grand_total'}) {
                   1441:         $excel_sheet->repeat_formula($rows_output,$cols_output++,
                   1442:                                      $total_formula,undef,
                   1443:                                      %total_cell_translation);
                   1444:     }
1.101     matthew  1445:     if ($chosen_output->{'grand_maximum'}) {
                   1446:         $excel_sheet->repeat_formula($rows_output,$cols_output++,
                   1447:                                      $maximum_formula,undef,
1.107     matthew  1448:                                      %maximum_cell_translation);
1.101     matthew  1449:     }
1.32      matthew  1450:     #
                   1451:     # Bookkeeping
                   1452:     $rows_output++; 
                   1453:     $cols_output=0;
                   1454:     #
1.36      matthew  1455:     # Update the progress window
                   1456:     &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
1.32      matthew  1457:     return;
1.31      matthew  1458: }
                   1459: 
                   1460: sub excel_finish {
                   1461:     my ($r) = @_;
1.54      matthew  1462:     return if ($request_aborted);
1.32      matthew  1463:     return if (! defined($excel_sheet));
                   1464:     #
                   1465:     # Write the excel file
                   1466:     $excel_workbook->close();
                   1467:     my $c = $r->connection();
                   1468:     #
                   1469:     return if($c->aborted());
                   1470:     #
1.36      matthew  1471:     # Close the progress window
                   1472:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
                   1473:     #
1.32      matthew  1474:     # Tell the user where to get their excel file
1.36      matthew  1475:     $r->print('<br />'.
1.32      matthew  1476:               '<a href="'.$filename.'">Your Excel spreadsheet.</a>'."\n");
                   1477:     $r->rflush();
                   1478:     return;
1.31      matthew  1479: }
                   1480: 
                   1481: }
1.30      matthew  1482: #######################################################
                   1483: #######################################################
                   1484: 
                   1485: =pod
                   1486: 
1.31      matthew  1487: =head2 CSV output routines
                   1488: 
                   1489: =item &csv_initialize($r)
                   1490: 
                   1491: =item &csv_outputstudent($r,$student)
                   1492: 
                   1493: =item &csv_finish($r)
1.30      matthew  1494: 
                   1495: =cut
                   1496: 
                   1497: #######################################################
                   1498: #######################################################
1.31      matthew  1499: {
                   1500: 
1.37      matthew  1501: my $outputfile;
                   1502: my $filename;
1.54      matthew  1503: my $request_aborted;
1.37      matthew  1504: my %prog_state; # progress window state
                   1505: 
1.31      matthew  1506: sub csv_initialize{
                   1507:     my ($r) = @_;
1.37      matthew  1508:     # 
                   1509:     # Clean up
1.66      matthew  1510:     undef($outputfile);
                   1511:     undef($filename);
                   1512:     undef($request_aborted);
1.37      matthew  1513:     undef(%prog_state);
                   1514:     #
1.54      matthew  1515:     # Deal with unimplemented requests
                   1516:     $request_aborted = undef;
1.87      matthew  1517:     if ($chosen_output->{'base'} =~ /final table/) {
1.54      matthew  1518:         $r->print(<<END);
                   1519: <h2>Unable to Complete Request</h2>
                   1520: <p>
                   1521: The <b>Summary Table (Scores)</b> option is not available for non-HTML output.
                   1522: </p>
                   1523: END
                   1524:        $request_aborted = 1;
                   1525:     }
                   1526:     return if ($request_aborted);
1.87      matthew  1527:     #
                   1528:     # Initialize progress window
                   1529:     my $studentcount = scalar(@Apache::lonstatistics::Students);
                   1530:     %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
                   1531:         ($r,'CSV File Compilation Status',
1.108     matthew  1532:          'CSV File Compilation Progress', $studentcount,
                   1533:          'inline',undef,'Statistics','stats_status');
1.54      matthew  1534:     #
1.37      matthew  1535:     # Open a file
                   1536:     $filename = '/prtspool/'.
                   1537:         $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
                   1538:             time.'_'.rand(1000000000).'.csv';
                   1539:     unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {
                   1540:         $r->log_error("Couldn't open $filename for output $!");
                   1541:         $r->print("Problems occured in writing the csv file.  ".
                   1542:                   "This error has been logged.  ".
                   1543:                   "Please alert your LON-CAPA administrator.");
                   1544:         $outputfile = undef;
                   1545:     }
1.38      matthew  1546:     #
                   1547:     # Datestamp
                   1548:     my $description = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
                   1549:     print $outputfile '"'.&Apache::loncommon::csv_translate($description).'",'.
                   1550:         '"'.&Apache::loncommon::csv_translate(scalar(localtime(time))).'"'.
                   1551:             "\n";
1.109     matthew  1552:     foreach my $item ('shortdesc','non_html_notes') {
                   1553:         next if (! exists($chosen_output->{$item}));
                   1554:         print $outputfile 
                   1555:             '"'.&Apache::loncommon::csv_translate($chosen_output->{$item}).'"'.
                   1556:             "\n";
                   1557:     }
1.37      matthew  1558:     #
                   1559:     # Print out the headings
1.87      matthew  1560:     my $sequence_row = '';
                   1561:     my $resource_row = undef;
1.37      matthew  1562:     foreach my $field (&get_student_fields_to_show()) {
1.87      matthew  1563:         $sequence_row .='"",';
                   1564:         $resource_row .= '"'.&Apache::loncommon::csv_translate($field).'",';
1.37      matthew  1565:     }
1.40      matthew  1566:     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
1.87      matthew  1567:         $sequence_row .= '"'.
                   1568:             &Apache::loncommon::csv_translate($seq->{'title'}).'",';
                   1569:         my $count = 0;
                   1570:         if ($chosen_output->{'every_problem'}) {
1.53      matthew  1571:             foreach my $res (@{$seq->{'contents'}}) {
1.87      matthew  1572:                 if ($res->{'type'} ne 'assessment'  || 
                   1573:                     ! exists($res->{'parts'})       ||
                   1574:                     ref($res->{'parts'}) ne 'ARRAY' ||
                   1575:                     scalar(@{$res->{'parts'}}) < 1) {
                   1576:                     next;
                   1577:                 }
1.53      matthew  1578:                 foreach my $part (@{$res->{'parts'}}) {
1.87      matthew  1579:                     $resource_row .= '"'.
                   1580:                         &Apache::loncommon::csv_translate($res->{'title'}.
                   1581:                                                           ', Part '.$part
                   1582:                                                           ).'",';
                   1583:                     $count++;
1.53      matthew  1584:                 }
                   1585:             }
1.37      matthew  1586:         }
1.87      matthew  1587:         $sequence_row.='"",'x$count;
                   1588:         if ($chosen_output->{'sequence_sum'}) {
                   1589:             if($chosen_output->{'correct'}) {
                   1590:                 $resource_row .= '"sum",';
                   1591:             } else {
                   1592:                 $resource_row .= '"score",';
                   1593:             }
                   1594:         }
                   1595:         if ($chosen_output->{'sequence_max'}) {
                   1596:             $sequence_row.= '"",';
                   1597:             $resource_row .= '"maximum possible",';
                   1598:         }
1.37      matthew  1599:     }
1.87      matthew  1600:     if ($chosen_output->{'grand_total'}) {
                   1601:         $sequence_row.= '"",';
                   1602:         $resource_row.= '"Total",';
                   1603:     } 
1.101     matthew  1604:     if ($chosen_output->{'grand_maximum'}) {
                   1605:         $sequence_row.= '"",';
                   1606:         $resource_row.= '"Maximum",';
                   1607:     } 
1.87      matthew  1608:     chomp($sequence_row);
                   1609:     chomp($resource_row);
                   1610:     print $outputfile $sequence_row."\n";
                   1611:     print $outputfile $resource_row."\n";
1.31      matthew  1612:     return;
                   1613: }
                   1614: 
                   1615: sub csv_outputstudent {
                   1616:     my ($r,$student) = @_;
1.54      matthew  1617:     return if ($request_aborted);
1.37      matthew  1618:     return if (! defined($outputfile));
                   1619:     my $Str = '';
                   1620:     #
                   1621:     # Output student fields
                   1622:     my @to_show = &get_student_fields_to_show();
                   1623:     foreach my $field (@to_show) {
1.103     matthew  1624:         my $value = $student->{$field};
                   1625:         if ($field eq 'comments') {
                   1626:             $value = &Apache::lonmsg::retrieve_instructor_comments
                   1627:                 ($student->{'username'},$student->{'domain'});
                   1628:         }        
                   1629:         $Str .= '"'.&Apache::loncommon::csv_translate($value).'",';
1.37      matthew  1630:     }
                   1631:     #
                   1632:     # Get student assessment data
                   1633:     my %StudentsData;
                   1634:     my @tmp = &Apache::loncoursedata::get_current_state($student->{'username'},
                   1635:                                                         $student->{'domain'},
                   1636:                                                         undef,
                   1637:                                                    $ENV{'request.course.id'});
                   1638:     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
                   1639:         %StudentsData = @tmp;
                   1640:     }
                   1641:     #
                   1642:     # Output performance data
1.87      matthew  1643:     my $total = 0;
1.101     matthew  1644:     my $maximum = 0;
1.40      matthew  1645:     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
1.54      matthew  1646:         my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87      matthew  1647:         if ($chosen_output->{'tries'}){
1.54      matthew  1648:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
                   1649:                 &StudentTriesOnSequence($student,\%StudentsData,
                   1650:                                         $seq,'no');
                   1651:         } else {
                   1652:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
                   1653:                 &StudentPerformanceOnSequence($student,\%StudentsData,
                   1654:                                               $seq,'no');
                   1655:         }
1.87      matthew  1656:         if ($chosen_output->{'every_problem'}) {
                   1657:             if ($chosen_output->{'correct'}) {
                   1658:                 $score = 0;
                   1659:                 # Deal with number of parts correct data
                   1660:                 $Str .= '"'.join('","',( map { if ($_>0) { 
                   1661:                                                    $score += 1;
                   1662:                                                    1; 
                   1663:                                                } else { 
                   1664:                                                    0; 
                   1665:                                                }
                   1666:                                              } @$rawdata)).'",';
                   1667:             } else {
                   1668:                 $Str .= '"'.join('","',(@$rawdata)).'",';
                   1669:             }
                   1670:         }
                   1671:         if ($chosen_output->{'sequence_sum'}) {
1.37      matthew  1672:             $Str .= '"'.$score.'",';
1.87      matthew  1673:         } 
                   1674:         if ($chosen_output->{'sequence_max'}) {
                   1675:             $Str .= '"'.$seq_max.'",';
1.37      matthew  1676:         }
1.87      matthew  1677:         $total+=$score;
1.101     matthew  1678:         $maximum += $seq_max;
1.87      matthew  1679:     }
                   1680:     if ($chosen_output->{'grand_total'}) {
                   1681:         $Str .= '"'.$total.'",';
1.101     matthew  1682:     }
                   1683:     if ($chosen_output->{'grand_maximum'}) {
                   1684:         $Str .= '"'.$maximum.'",';
1.37      matthew  1685:     }
                   1686:     chop($Str);
                   1687:     $Str .= "\n";
                   1688:     print $outputfile $Str;
                   1689:     #
                   1690:     # Update the progress window
                   1691:     &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
                   1692:     return;
1.31      matthew  1693: }
                   1694: 
                   1695: sub csv_finish {
                   1696:     my ($r) = @_;
1.54      matthew  1697:     return if ($request_aborted);
1.37      matthew  1698:     return if (! defined($outputfile));
                   1699:     close($outputfile);
                   1700:     #
                   1701:     my $c = $r->connection();
                   1702:     return if ($c->aborted());
                   1703:     #
                   1704:     # Close the progress window
                   1705:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
                   1706:     #
                   1707:     # Tell the user where to get their csv file
                   1708:     $r->print('<br />'.
1.95      matthew  1709:               '<a href="'.$filename.'">'.&mt('Your csv file.').'</a>'."\n");
1.37      matthew  1710:     $r->rflush();
                   1711:     return;
                   1712:     
1.31      matthew  1713: }
1.2       stredwic 1714: 
                   1715: }
                   1716: 
1.28      matthew  1717: #######################################################
                   1718: #######################################################
                   1719: 
1.2       stredwic 1720: =pod
                   1721: 
1.54      matthew  1722: =item &StudentTriesOnSequence()
1.2       stredwic 1723: 
1.30      matthew  1724: Inputs:
1.2       stredwic 1725: 
                   1726: =over 4
                   1727: 
1.30      matthew  1728: =item $student
1.28      matthew  1729: 
1.30      matthew  1730: =item $studentdata Hash ref to all student data
1.2       stredwic 1731: 
1.30      matthew  1732: =item $seq Hash ref, the sequence we are working on
1.2       stredwic 1733: 
1.30      matthew  1734: =item $links if defined we will output links to each resource.
1.2       stredwic 1735: 
1.28      matthew  1736: =back
1.2       stredwic 1737: 
                   1738: =cut
1.1       stredwic 1739: 
1.28      matthew  1740: #######################################################
                   1741: #######################################################
1.112     matthew  1742: sub student_tries_on_sequence {
                   1743:     my ($student,$studentdata,$navmap,$seq,$links) = @_;
1.31      matthew  1744:     $links = 'no' if (! defined($links));
1.1       stredwic 1745:     my $Str = '';
1.30      matthew  1746:     my ($sum,$max) = (0,0);
1.51      matthew  1747:     my $performance_length = 0;
1.54      matthew  1748:     my @TriesData = ();
                   1749:     my $tries;
1.97      matthew  1750:     my $hasdata = 0; # flag - true if the student has any data on the sequence
1.112     matthew  1751:     my @resources = 
                   1752:         $navmap->retrieveResources($seq,sub { shift->is_problem(); },0,0,0);
                   1753:     foreach my $resource (@resources) {
                   1754:         my $resource_data = $studentdata->{$resource->symb};
1.30      matthew  1755:         my $value = '';
1.112     matthew  1756:         foreach my $partnum (@{$resource->parts()}) {
1.54      matthew  1757:             $tries = undef;
1.30      matthew  1758:             $max++;
1.51      matthew  1759:             $performance_length++;
1.30      matthew  1760:             my $symbol = ' '; # default to space
                   1761:             #
1.78      matthew  1762:             my $awarded = 0;
                   1763:             if (exists($resource_data->{'resource.'.$partnum.'.awarded'})) {
                   1764:                 $awarded = $resource_data->{'resource.'.$partnum.'.awarded'};
                   1765:                 $awarded = 0 if (! $awarded);
                   1766:             }
                   1767:             #
                   1768:             my $status = '';
1.30      matthew  1769:             if (exists($resource_data->{'resource.'.$partnum.'.solved'})) {
1.78      matthew  1770:                 $status = $resource_data->{'resource.'.$partnum.'.solved'};
                   1771:             }
                   1772:             #
                   1773:             my $tries = 0;
                   1774:             if(exists($resource_data->{'resource.'.$partnum.'.tries'})) {
                   1775:                 $tries = $resource_data->{'resource.'.$partnum.'.tries'};
1.97      matthew  1776:                 $hasdata =1;
1.78      matthew  1777:             }
                   1778:             #
                   1779:             if ($awarded > 0) {
                   1780:                 # The student has gotten the problem correct to some degree
                   1781:                 if ($status eq 'excused') {
                   1782:                     $symbol = 'x';
                   1783:                     $max--;
                   1784:                 } elsif ($status eq 'correct_by_override') {
1.30      matthew  1785:                     $symbol = '+';
                   1786:                     $sum++;
1.78      matthew  1787:                 } elsif ($tries > 0) {
1.54      matthew  1788:                     if ($tries > 9) {
1.30      matthew  1789:                         $symbol = '*';
1.78      matthew  1790:                     } else {
1.54      matthew  1791:                         $symbol = $tries;
1.30      matthew  1792:                     }
                   1793:                     $sum++;
                   1794:                 } else {
1.78      matthew  1795:                     $symbol = '+';
                   1796:                     $sum++;
1.2       stredwic 1797:                 }
1.30      matthew  1798:             } else {
1.78      matthew  1799:                 # The student has the problem incorrect or it is ungraded
                   1800:                 if ($status eq 'excused') {
                   1801:                     $symbol = 'x';
                   1802:                     $max--;
                   1803:                 } elsif ($status eq 'incorrect_by_override') {
                   1804:                     $symbol = '-';
                   1805:                 } elsif ($status eq 'ungraded_attempted') {
                   1806:                     $symbol = '#';
                   1807:                 } elsif ($status eq 'incorrect_attempted' ||
                   1808:                          $tries > 0)  {
1.30      matthew  1809:                     $symbol = '.';
                   1810:                 } else {
1.78      matthew  1811:                     # Problem is wrong and has not been attempted.
                   1812:                     $symbol=' ';
1.18      matthew  1813:                 }
1.2       stredwic 1814:             }
1.54      matthew  1815:             #
1.109     matthew  1816:             if (! defined($tries)) {
                   1817:                 $tries = 0;
                   1818:             }
                   1819:             if ($status =~ /^(incorrect|ungraded)/) {
                   1820:                 # Bug 3390: show '-' for tries on incorrect problems 
                   1821:                 # (csv & excel only)
                   1822:                 push(@TriesData,-$tries);
                   1823:             } else {
                   1824:                 push (@TriesData,$tries);
1.54      matthew  1825:             }
1.30      matthew  1826:             #
1.47      matthew  1827:             if ( ($links eq 'yes' && $symbol ne ' ') ||
                   1828:                  ($links eq 'all')) {
1.49      matthew  1829:                 if (length($symbol) > 1) {
                   1830:                     &Apache::lonnet::logthis('length of symbol "'.$symbol.'" > 1');
                   1831:                 }
1.30      matthew  1832:                 $symbol = '<a href="/adm/grades'.
1.112     matthew  1833:                     '?symb='.&Apache::lonnet::escape($resource->symb).
1.30      matthew  1834:                         '&student='.$student->{'username'}.
1.64      albertel 1835:                             '&userdom='.$student->{'domain'}.
1.30      matthew  1836:                                 '&command=submission">'.$symbol.'</a>';
                   1837:             }
                   1838:             $value .= $symbol;
1.2       stredwic 1839:         }
1.30      matthew  1840:         $Str .= $value;
1.17      minaeibi 1841:     }
1.112     matthew  1842:     if ($seq->randompick()) {
                   1843:         $max = $seq->randompick();
1.51      matthew  1844:     }
1.97      matthew  1845:     if (! $hasdata && $sum == 0) {
                   1846:         $sum = ' ';
                   1847:     }
1.54      matthew  1848:     return ($Str,$performance_length,$sum,$max,\@TriesData);
                   1849: }
                   1850: 
                   1851: #######################################################
                   1852: #######################################################
                   1853: 
                   1854: =pod
                   1855: 
                   1856: =item &StudentPerformanceOnSequence()
                   1857: 
                   1858: Inputs:
                   1859: 
                   1860: =over 4
                   1861: 
                   1862: =item $student
                   1863: 
                   1864: =item $studentdata Hash ref to all student data
                   1865: 
                   1866: =item $seq Hash ref, the sequence we are working on
                   1867: 
                   1868: =item $links if defined we will output links to each resource.
                   1869: 
                   1870: =back
                   1871: 
                   1872: =cut
                   1873: 
                   1874: #######################################################
                   1875: #######################################################
1.112     matthew  1876: sub student_performance_on_sequence {
                   1877:     my ($student,$studentdata,$navmap,$seq,$links) = @_;
1.54      matthew  1878:     $links = 'no' if (! defined($links));
                   1879:     my $Str = ''; # final result string
                   1880:     my ($score,$max) = (0,0);
                   1881:     my $performance_length = 0;
                   1882:     my $symbol;
                   1883:     my @ScoreData = ();
                   1884:     my $partscore;
1.97      matthew  1885:     my $hasdata = 0; # flag, 0 if there were no submissions on the sequence
1.112     matthew  1886:     my @resources = 
                   1887:         $navmap->retrieveResources($seq,sub { shift->is_problem(); },0,0,0);
                   1888:     foreach my $resource (@resources) {
                   1889:         my $symb = $resource->symb;
                   1890:         my $resource_data = $studentdata->{$symb};
                   1891:         foreach my $part (@{$resource->parts()}) {
1.54      matthew  1892:             $partscore = undef;
                   1893:             my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',
1.112     matthew  1894:                                               $symb,
1.54      matthew  1895:                                               $student->{'domain'},
                   1896:                                               $student->{'username'},
                   1897:                                               $student->{'section'});
                   1898:             if (!defined($weight) || ($weight eq '')) { 
                   1899:                 $weight=1;
                   1900:             }
                   1901:             #
                   1902:             $max += $weight; # see the 'excused' branch below...
                   1903:             $performance_length++; # one character per part
                   1904:             $symbol = ' '; # default to space
                   1905:             #
1.97      matthew  1906:             my $awarded;
1.54      matthew  1907:             if (exists($resource_data->{'resource.'.$part.'.awarded'})) {
                   1908:                 $awarded = $resource_data->{'resource.'.$part.'.awarded'};
1.67      matthew  1909:                 $awarded = 0 if (! $awarded);
1.97      matthew  1910:                 $hasdata = 1;
1.54      matthew  1911:             }
                   1912:             #
                   1913:             $partscore = $weight*$awarded;
1.97      matthew  1914:             if (! defined($awarded)) {
                   1915:                 $partscore = undef;
                   1916:             }
1.54      matthew  1917:             $score += $partscore;
1.63      matthew  1918:             $symbol = $partscore; 
1.70      matthew  1919:             if (abs($symbol - sprintf("%.0f",$symbol)) < 0.001) {
                   1920:                 $symbol = sprintf("%.0f",$symbol);
                   1921:             }
1.54      matthew  1922:             if (length($symbol) > 1) {
                   1923:                 $symbol = '*';
                   1924:             }
                   1925:             if (exists($resource_data->{'resource.'.$part.'.solved'})) {
                   1926:                 my $status = $resource_data->{'resource.'.$part.'.solved'};
                   1927:                 if ($status eq 'excused') {
                   1928:                     $symbol = 'x';
                   1929:                     $max -= $weight; # Do not count 'excused' problems.
                   1930:                 }
1.97      matthew  1931:                 $hasdata = 1;
1.111     matthew  1932:             } elsif (!exists($resource_data->{'resource.'.$part.'.awarded'})){
1.54      matthew  1933:                 # Unsolved.  Did they try?
                   1934:                 if (exists($resource_data->{'resource.'.$part.'.tries'})){
                   1935:                     $symbol = '.';
1.97      matthew  1936:                     $hasdata = 1;
1.54      matthew  1937:                 } else {
                   1938:                     $symbol = ' ';
                   1939:                 }
                   1940:             }
                   1941:             #
1.60      matthew  1942:             if (! defined($partscore)) {
                   1943:                 $partscore = $symbol;
                   1944:             }
                   1945:             push (@ScoreData,$partscore);
                   1946:             #
1.54      matthew  1947:             if ( ($links eq 'yes' && $symbol ne ' ') || ($links eq 'all')) {
                   1948:                 $symbol = '<a href="/adm/grades'.
1.112     matthew  1949:                     '?symb='.&Apache::lonnet::escape($symb).
1.54      matthew  1950:                     '&student='.$student->{'username'}.
1.64      albertel 1951:                     '&userdom='.$student->{'domain'}.
1.54      matthew  1952:                     '&command=submission">'.$symbol.'</a>';
                   1953:             }
1.60      matthew  1954:             $Str .= $symbol;
1.54      matthew  1955:         }
1.97      matthew  1956:     }
                   1957:     if (! $hasdata && $score == 0) {
                   1958:         $score = ' ';
1.54      matthew  1959:     }
                   1960:     return ($Str,$performance_length,$score,$max,\@ScoreData);
1.1       stredwic 1961: }
1.23      minaeibi 1962: 
1.28      matthew  1963: #######################################################
                   1964: #######################################################
1.23      minaeibi 1965: 
1.2       stredwic 1966: =pod
                   1967: 
                   1968: =item &CreateLegend()
                   1969: 
                   1970: This function returns a formatted string containing the legend for the
                   1971: chart.  The legend describes the symbols used to represent grades for
                   1972: problems.
                   1973: 
                   1974: =cut
                   1975: 
1.28      matthew  1976: #######################################################
                   1977: #######################################################
1.2       stredwic 1978: sub CreateLegend {
                   1979:     my $Str = "<p><pre>".
1.13      minaeibi 1980:               "   1  correct by student in 1 try\n".
                   1981:               "   7  correct by student in 7 tries\n".
1.12      minaeibi 1982:               "   *  correct by student in more than 9 tries\n".
1.20      minaeibi 1983: 	      "   +  correct by hand grading or override\n".
1.12      minaeibi 1984:               "   -  incorrect by override\n".
                   1985: 	      "   .  incorrect attempted\n".
                   1986: 	      "   #  ungraded attempted\n".
1.13      minaeibi 1987:               "      not attempted (blank field)\n".
1.12      minaeibi 1988: 	      "   x  excused".
1.17      minaeibi 1989:               "</pre><p>";
1.2       stredwic 1990:     return $Str;
                   1991: }
                   1992: 
1.28      matthew  1993: #######################################################
                   1994: #######################################################
                   1995: 
1.30      matthew  1996: =pod 
1.2       stredwic 1997: 
                   1998: =back
                   1999: 
                   2000: =cut
                   2001: 
1.28      matthew  2002: #######################################################
                   2003: #######################################################
1.2       stredwic 2004: 
1.28      matthew  2005: 1;
1.2       stredwic 2006: 
1.1       stredwic 2007: __END__

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