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

1.1       stredwic    1: # The LearningOnline Network with CAPA
                      2: #
1.121   ! albertel    3: # $Id: lonstudentassessment.pm,v 1.120 2005/03/21 19:47:54 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.121   ! albertel  156:     $single_student_mode = 1 if ($env{'form.SelectedStudent'});
1.100     matthew   157:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    158:                                             ['selectstudent']);
1.121   ! albertel  159:     if ($env{'form.selectstudent'}) {
1.59      matthew   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="'.
1.121   ! albertel  170:               $env{'form.sort'}.'" />');
1.7       stredwic  171:     $r->rflush();
1.58      matthew   172:     #
1.121   ! albertel  173:     if (! exists($env{'form.notfirstrun'}) && ! $single_student_mode) {
1.31      matthew   174:         return;
                    175:     }
1.119     matthew   176:     $r->print('<h4>'.
                    177:               &Apache::lonstatistics::section_and_enrollment_description().
                    178:               '</h4>');
1.31      matthew   179:     #
                    180:     my $initialize     = \&html_initialize;
                    181:     my $output_student = \&html_outputstudent;
                    182:     my $finish         = \&html_finish;
                    183:     #
                    184:     if ($output_mode eq 'excel') {
                    185:         $initialize     = \&excel_initialize;
                    186:         $output_student = \&excel_outputstudent;
                    187:         $finish         = \&excel_finish;
                    188:     } elsif ($output_mode eq 'csv') {
                    189:         $initialize     = \&csv_initialize;
                    190:         $output_student = \&csv_outputstudent;
                    191:         $finish         = \&csv_finish;
                    192:     }
1.30      matthew   193:     #
                    194:     if($c->aborted()) {  return ; }
1.31      matthew   195:     #
1.49      matthew   196:     # Determine which students we want to look at
                    197:     my @Students;
                    198:     if ($single_student_mode) {
                    199:         @Students = (&Apache::lonstatistics::current_student());
                    200:         $r->print(&next_and_previous_buttons());
                    201:         $r->rflush();
                    202:     } else {
                    203:         @Students = @Apache::lonstatistics::Students;
                    204:     }
1.56      matthew   205:     #
                    206:     # Perform generic initialization tasks
                    207:     #       Since we use lonnet::EXT to retrieve problem weights,
                    208:     #       to ensure current data we must clear the caches out.
                    209:     #       This makes sure that parameter changes at the student level
                    210:     #       are immediately reflected in the chart.
                    211:     &Apache::lonnet::clear_EXT_cache_status();
1.69      matthew   212:     #
                    213:     # Clean out loncoursedata's package data, just to be safe.
                    214:     &Apache::loncoursedata::clear_internal_caches();
1.49      matthew   215:     #
1.31      matthew   216:     # Call the initialize routine selected above
                    217:     $initialize->($r);
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="'.
1.121   ! albertel  237:         $env{'form.SelectedStudent'}.'" />';
1.49      matthew   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.120     matthew   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.121   ! albertel  434:     if (exists($env{'form.'.$elementname})) {
        !           435:         if (ref($env{'form.'.$elementname} eq 'ARRAY')) {
        !           436:             $selected = $env{'form.'.$elementname}->[0];
1.31      matthew   437:         } else {
1.121   ! albertel  438:             $selected = $env{'form.'.$elementname};
1.31      matthew   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';
1.121   ! albertel  555:     if (exists($env{'form.'.$elementname})) {
        !           556:         if (ref($env{'form.'.$elementname} eq 'ARRAY')) {
        !           557:             $selected = $env{'form.'.$elementname}->[0];
1.54      matthew   558:         } else {
1.121   ! albertel  559:             $selected = $env{'form.'.$elementname};
1.54      matthew   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.115     matthew   584: sub count_parts {
                    585:     my ($navmap,$sequence) = @_;
                    586:     my @resources = &get_resources($navmap,$sequence);
                    587:     my $count = 0;
                    588:     foreach my $res (@resources) {
                    589:         $count += scalar(@{$res->parts});
                    590:     }
                    591:     return $count;
                    592: }
                    593: 
                    594: sub get_resources {
                    595:     my ($navmap,$sequence) = @_;
                    596:     my @resources = $navmap->retrieveResources($sequence,
                    597:                                                sub { shift->is_problem(); },
                    598:                                                0,0,0);
                    599:     return @resources;
                    600: }
                    601: 
                    602: #######################################################
                    603: #######################################################
1.1       stredwic  604: 
1.28      matthew   605: =pod
                    606: 
1.31      matthew   607: =head2 HTML output routines
1.28      matthew   608: 
1.31      matthew   609: =item &html_initialize($r)
1.28      matthew   610: 
1.31      matthew   611: Create labels for the columns of student data to show.
1.28      matthew   612: 
1.31      matthew   613: =item &html_outputstudent($r,$student)
1.28      matthew   614: 
1.31      matthew   615: Return a line of the chart for a student.
1.28      matthew   616: 
1.31      matthew   617: =item &html_finish($r)
1.28      matthew   618: 
                    619: =cut
                    620: 
                    621: #######################################################
                    622: #######################################################
1.31      matthew   623: {
                    624:     my $padding;
                    625:     my $count;
                    626: 
1.39      matthew   627:     my $nodata_count; # The number of students for which there is no data
                    628:     my %prog_state;   # progress state used by loncommon PrgWin routines
1.102     matthew   629:     my $total_sum_width;
1.39      matthew   630: 
1.112     matthew   631:     my %width; # Holds sequence width information
                    632:     my @sequences;
                    633:     my $navmap; # Have to keep this around since weakref is a bit zealous
                    634: 
1.31      matthew   635: sub html_initialize {
                    636:     my ($r) = @_;
1.30      matthew   637:     #
                    638:     $padding = ' 'x3;
1.35      matthew   639:     $count = 0;
1.39      matthew   640:     $nodata_count = 0;
1.66      matthew   641:     undef(%prog_state);
1.112     matthew   642:     undef(%width);
1.115     matthew   643:     #
1.112     matthew   644:     undef($navmap);
                    645:     undef(@sequences);
1.115     matthew   646:     ($navmap,@sequences) = 
                    647:         &Apache::lonstatistics::selected_sequences_with_assessments();
                    648:     if (! ref($navmap)) {
                    649:         # Unable to get data, so bail out
                    650:         $r->print("<h3>".
                    651:                   &mt('Unable to retrieve course information.').
                    652:                   '</h3>');
                    653:     }
1.30      matthew   654:     #
1.121   ! albertel  655:     $r->print("<h3>".$env{'course.'.$env{'request.course.id'}.'.description'}.
1.38      matthew   656:               "&nbsp;&nbsp;".localtime(time)."</h3>");
1.112     matthew   657:     #
1.87      matthew   658:     if ($chosen_output->{'base'} !~ /^final table/) {
                    659:         $r->print("<h3>".$chosen_output->{'shortdesc'}."</h3>");        
1.39      matthew   660:     }
1.31      matthew   661:     my $Str = "<pre>\n";
1.30      matthew   662:     # First, the @StudentData fields need to be listed
1.31      matthew   663:     my @to_show = &get_student_fields_to_show();
1.30      matthew   664:     foreach my $field (@to_show) {
                    665:         my $title=$Apache::lonstatistics::StudentData{$field}->{'title'};
                    666:         my $base =$Apache::lonstatistics::StudentData{$field}->{'base_width'};
                    667:         my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
                    668:         $Str .= $title.' 'x($width-$base).$padding;
                    669:     }
1.89      matthew   670:     #
                    671:     # Compute the column widths and output the sequence titles
1.102     matthew   672:     my $total_count;
1.112     matthew   673:     #
                    674:     # Compute sequence widths
                    675:     my $starttime = Time::HiRes::time;
                    676:     foreach my $seq (@sequences) {
                    677:         my $symb = $seq->symb;
                    678:         my $title = $seq->compTitle;
                    679:         $width{$symb}->{'width_sum'} = 0;
                    680:         # Compute width of sum
1.89      matthew   681:         if ($chosen_output->{'sequence_sum'}) {
1.99      matthew   682:             if ($chosen_output->{'every_problem'}) {
                    683:                 # Use 1 digit for a space
1.112     matthew   684:                 $width{$symb}->{'width_sum'} += 1;            
1.99      matthew   685:             }
1.118     matthew   686: 	    $total_count += &count_parts($navmap,$seq);
1.89      matthew   687:             # Use 3 digits for the sum
1.112     matthew   688:             $width{$symb}->{'width_sum'} += 3;
1.89      matthew   689:         }
1.112     matthew   690:         # Compute width of maximum
1.89      matthew   691:         if ($chosen_output->{'sequence_max'}) {
1.112     matthew   692:             if ($width{$symb}->{'width_sum'}>0) {
1.89      matthew   693:                 # One digit for the '/'
1.112     matthew   694:                 $width{$symb}->{'width_sum'} +=1;
1.89      matthew   695:             }
                    696:             # Use 3 digits for the total
1.112     matthew   697:             $width{$symb}->{'width_sum'}+=3;
1.89      matthew   698:         }
1.94      matthew   699: 	#
1.89      matthew   700:         if ($chosen_output->{'every_problem'}) {
                    701:             # one problem per digit
1.115     matthew   702:             $width{$symb}->{'width_parts'}= &count_parts($navmap,$seq);
                    703:             $width{$symb}->{'width_problem'} += $width{$symb}->{'width_parts'};
1.89      matthew   704:         } else {
1.112     matthew   705:             $width{$symb}->{'width_problem'} = 0;
1.89      matthew   706:         }
1.112     matthew   707:         $width{$symb}->{'width_total'} = $width{$symb}->{'width_problem'} + 
                    708:                                      $width{$symb}->{'width_sum'};
                    709:         if ($width{$symb}->{'width_total'} < length(&HTML::Entities::decode($title))) {
                    710:             $width{$symb}->{'width_total'} = length(&HTML::Entities::decode($title));
1.89      matthew   711:         }
                    712:         #
                    713:         # Output the sequence titles
1.112     matthew   714:         $Str .= $title.(' 'x($width{$symb}->{'width_total'}-
                    715:                             length($title)
                    716:                             )).$padding;
1.30      matthew   717:     }
1.102     matthew   718:     $total_sum_width = length($total_count)+1;
                    719:     $Str .= "    total</pre>\n";
1.31      matthew   720:     $Str .= "<pre>";
                    721:     $r->print($Str);
                    722:     $r->rflush();
                    723:     return;
1.30      matthew   724: }
                    725: 
1.31      matthew   726: sub html_outputstudent {
                    727:     my ($r,$student) = @_;
1.2       stredwic  728:     my $Str = '';
1.112     matthew   729:     return if (! defined($navmap));
1.35      matthew   730:     #
1.87      matthew   731:     if($count++ % 5 == 0 && $count > 0) {
1.35      matthew   732:         $r->print("</pre><pre>");
                    733:     }
1.30      matthew   734:     # First, the @StudentData fields need to be listed
1.31      matthew   735:     my @to_show = &get_student_fields_to_show();
1.30      matthew   736:     foreach my $field (@to_show) {
                    737:         my $title=$student->{$field};
1.103     matthew   738:         # Deal with 'comments' - how I love special cases
                    739:         if ($field eq 'comments') {
                    740:             $title = '<a href="/adm/'.$student->{'domain'}.'/'.$student->{'username'}.'/'.'aboutme#coursecomment">'.&mt('Comments').'</a>';
                    741:         }
1.31      matthew   742:         my $base = length($title);
1.30      matthew   743:         my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
                    744:         $Str .= $title.' 'x($width-$base).$padding;
                    745:     }
                    746:     # Get ALL the students data
                    747:     my %StudentsData;
                    748:     my @tmp = &Apache::loncoursedata::get_current_state
                    749:         ($student->{'username'},$student->{'domain'},undef,
1.121   ! albertel  750:          $env{'request.course.id'});
1.30      matthew   751:     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
                    752:         %StudentsData = @tmp;
                    753:     }
                    754:     if (scalar(@tmp) < 1) {
1.39      matthew   755:         $nodata_count++;
1.30      matthew   756:         $Str .= '<font color="blue">No Course Data</font>'."\n";
1.31      matthew   757:         $r->print($Str);
                    758:         $r->rflush();
                    759:         return;
1.30      matthew   760:     }
                    761:     #
                    762:     # By sequence build up the data
                    763:     my $studentstats;
1.31      matthew   764:     my $PerformanceStr = '';
1.112     matthew   765:     foreach my $seq (@sequences) {
1.118     matthew   766:         my $symb = $seq->symb;
1.54      matthew   767:         my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87      matthew   768:         if ($chosen_output->{'tries'}) {
1.54      matthew   769:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.112     matthew   770:                 &student_tries_on_sequence($student,\%StudentsData,
                    771:                                            $navmap,$seq,$show_links);
1.54      matthew   772:         } else {
                    773:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.112     matthew   774:                 &student_performance_on_sequence($student,\%StudentsData,
                    775:                                                  $navmap,$seq,$show_links);
1.54      matthew   776:         }
1.89      matthew   777:         my $ratio='';
1.118     matthew   778:         if ($chosen_output->{'every_problem'} && 
                    779:             $chosen_output->{'sequence_sum'}) {
1.99      matthew   780:             $ratio .= ' ';
                    781:         }
1.97      matthew   782:         if ($chosen_output->{'sequence_sum'} && $score ne ' ') {
1.115     matthew   783:             my $score .= sprintf("%3.0f",$score);
                    784:             $ratio .= (' 'x(3-length($score))).$score;
1.98      matthew   785:         } elsif($chosen_output->{'sequence_sum'}) {
1.97      matthew   786:             $ratio .= ' 'x3;
1.89      matthew   787:         }
                    788:         if ($chosen_output->{'sequence_max'}) {
                    789:             if ($chosen_output->{'sequence_sum'}) {
                    790:                 $ratio .= '/';
                    791:             }
1.99      matthew   792:             $ratio .= sprintf("%3.0f",$seq_max);
1.89      matthew   793:         }
1.31      matthew   794:         #
1.89      matthew   795:         if (! $chosen_output->{'every_problem'}) {
                    796:             $performance = '';
1.94      matthew   797: 	    $performance_length=0;
1.30      matthew   798:         }
1.118     matthew   799:         $performance .= ' 'x($width{$symb}->{'width_total'} -
1.112     matthew   800:                              $performance_length -
1.118     matthew   801:                              $width{$symb}->{'width_sum'}).
1.89      matthew   802:             $ratio;
1.31      matthew   803:         #
                    804:         $Str .= $performance.$padding;
                    805:         #
1.118     matthew   806:         $studentstats->{$symb}->{'score'}= $score;
                    807:         $studentstats->{$symb}->{'max'}  = $seq_max;
1.30      matthew   808:     }
                    809:     #
                    810:     # Total it up and store the statistics info.
1.97      matthew   811:     my ($score,$max);
1.30      matthew   812:     while (my ($symb,$seq_stats) = each (%{$studentstats})) {
                    813:         $Statistics->{$symb}->{'score'} += $seq_stats->{'score'};
1.54      matthew   814:         if ($Statistics->{$symb}->{'max'} < $seq_stats->{'max'}) {
                    815:             $Statistics->{$symb}->{'max'} = $seq_stats->{'max'};
                    816:         }
1.97      matthew   817:         if ($seq_stats->{'score'} ne ' ') {
                    818:             $score += $seq_stats->{'score'};
                    819:             $Statistics->{$symb}->{'num_students'}++;
                    820:         }
1.30      matthew   821:         $max   += $seq_stats->{'max'};
                    822:     }
1.97      matthew   823:     if (! defined($score)) {
1.102     matthew   824:         $score = ' ' x $total_sum_width;
1.105     matthew   825:     } else {
                    826:         $score = sprintf("%.0f",$score);
1.115     matthew   827:         $score = (' 'x(3-length($score))).$score;
1.97      matthew   828:     }
1.102     matthew   829:     $Str .= ' '.' 'x($total_sum_width-length($score)).$score.' / '.$max;
1.30      matthew   830:     $Str .= " \n";
1.39      matthew   831:     #
1.31      matthew   832:     $r->print($Str);
                    833:     #
                    834:     $r->rflush();
                    835:     return;
1.30      matthew   836: }    
1.2       stredwic  837: 
1.31      matthew   838: sub html_finish {
                    839:     my ($r) = @_;
1.112     matthew   840:     return if (! defined($navmap));
1.39      matthew   841:     #
                    842:     # Check for suppressed output and close the progress window if so
1.87      matthew   843:     $r->print("</pre>\n"); 
1.90      matthew   844:     if ($chosen_output->{'summary_table'}) {
                    845:         if ($single_student_mode) {
                    846:             $r->print(&SingleStudentTotal());
                    847:         } else {
                    848:             $r->print(&StudentAverageTotal());
                    849:         }
1.49      matthew   850:     }
1.31      matthew   851:     $r->rflush();
1.112     matthew   852:     undef($navmap);
1.31      matthew   853:     return;
                    854: }
                    855: 
1.39      matthew   856: sub StudentAverageTotal {
1.105     matthew   857:     my $Str = '<h3>'.&mt('Summary Tables').'</h3>'.$/;
1.39      matthew   858:     $Str .= '<table border=2 cellspacing="1">'."\n";
1.105     matthew   859:     $Str .= '<tr>'.
                    860:         '<th>'.&mt('Title').'</th>'.
                    861:         '<th>'.&mt('Average').'</th>'.
                    862:         '<th>'.&mt('Maximum').'</th>'.
                    863:         '</tr>'.$/;
1.112     matthew   864:     foreach my $seq (@sequences) {
                    865:         my $symb = $seq->symb;
1.42      matthew   866:         my $ave;
1.112     matthew   867:         my $num_students = $Statistics->{$symb}->{'num_students'};
1.97      matthew   868:         if ($num_students > 0) {
                    869:             $ave = int(100*
1.112     matthew   870:                        ($Statistics->{$symb}->{'score'}/$num_students)
1.97      matthew   871:                        )/100;
1.42      matthew   872:         } else {
                    873:             $ave = 0;
                    874:         }
1.112     matthew   875:         my $max = $Statistics->{$symb}->{'max'};
1.82      matthew   876:         $ave = sprintf("%.2f",$ave);
1.112     matthew   877:         $Str .= '<tr><td>'.$seq->compTitle.'</td>'.
1.82      matthew   878:             '<td align="right">'.$ave.'&nbsp;</td>'.
                    879:             '<td align="right">'.$max.'&nbsp;'.'</td></tr>'."\n";
1.39      matthew   880:     }
                    881:     $Str .= "</table>\n";
                    882:     return $Str;
                    883: }
                    884: 
1.49      matthew   885: sub SingleStudentTotal {
1.115     matthew   886:     return if (! defined($navmap));
1.49      matthew   887:     my $student = &Apache::lonstatistics::current_student();
1.105     matthew   888:     my $Str = '<h3>'.&mt('Summary table for [_1] ([_2]@[_3])',
                    889:                          $student->{'fullname'},
                    890:                          $student->{'username'},$student->{'domain'}).'</h3>';
                    891:     $Str .= $/;
1.49      matthew   892:     $Str .= '<table border=2 cellspacing="1">'."\n";
                    893:     $Str .= 
1.105     matthew   894:         '<tr>'.
                    895:         '<th>'.&mt('Sequence or Folder').'</th>';
                    896:     if ($chosen_output->{'base'} eq 'tries') {
                    897:         $Str .= '<th>'.&mt('Parts Correct').'</th>';
                    898:     } else {
                    899:         $Str .= '<th>'.&mt('Score').'</th>';
                    900:     }
                    901:     $Str .= '<th>'.&mt('Maximum').'</th>'."</tr>\n";
1.49      matthew   902:     my $total = 0;
                    903:     my $total_max = 0;
1.115     matthew   904:     foreach my $seq (@sequences) {
1.112     matthew   905:         my $value = $Statistics->{$seq->symb}->{'score'};
                    906:         my $max = $Statistics->{$seq->symb}->{'max'};
                    907:         $Str .= '<tr><td>'.&HTML::Entities::encode($seq->compTitle).'</td>'.
1.49      matthew   908:             '<td align="right">'.$value.'</td>'.
                    909:                 '<td align="right">'.$max.'</td></tr>'."\n";
                    910:         $total += $value;
                    911:         $total_max +=$max;
                    912:     }
1.105     matthew   913:     $Str .= '<tr><td><b>'.&mt('Total').'</b></td>'.
1.49      matthew   914:         '<td align="right">'.$total.'</td>'.
                    915:         '<td align="right">'.$total_max."</td></tr>\n";
                    916:     $Str .= "</table>\n";
                    917:     return $Str;
                    918: }
                    919: 
1.31      matthew   920: }
                    921: 
                    922: #######################################################
                    923: #######################################################
                    924: 
                    925: =pod
                    926: 
                    927: =head2 EXCEL subroutines
                    928: 
                    929: =item &excel_initialize($r)
                    930: 
                    931: =item &excel_outputstudent($r,$student)
                    932: 
                    933: =item &excel_finish($r)
                    934: 
                    935: =cut
                    936: 
                    937: #######################################################
                    938: #######################################################
                    939: {
                    940: 
                    941: my $excel_sheet;
1.32      matthew   942: my $excel_workbook;
1.117     matthew   943: my $format;
1.32      matthew   944: 
                    945: my $filename;
                    946: my $rows_output;
                    947: my $cols_output;
                    948: 
1.36      matthew   949: my %prog_state; # progress window state
1.54      matthew   950: my $request_aborted;
1.31      matthew   951: 
1.76      matthew   952: my $total_formula;
1.101     matthew   953: my $maximum_formula;
1.115     matthew   954: my %formula_data;
                    955: 
                    956: my $navmap;
                    957: my @sequences;
1.76      matthew   958: 
1.31      matthew   959: sub excel_initialize {
                    960:     my ($r) = @_;
                    961:     #
1.66      matthew   962:     undef ($excel_sheet);
                    963:     undef ($excel_workbook);
                    964:     undef ($filename);
                    965:     undef ($rows_output);
                    966:     undef ($cols_output);
                    967:     undef (%prog_state);
                    968:     undef ($request_aborted);
1.76      matthew   969:     undef ($total_formula);
1.101     matthew   970:     undef ($maximum_formula);
1.66      matthew   971:     #
1.115     matthew   972:     undef(%formula_data);
                    973:     #
                    974:     undef($navmap);
                    975:     undef(@sequences);
                    976:     ($navmap,@sequences) = 
                    977:         &Apache::lonstatistics::selected_sequences_with_assessments();
                    978:     if (! ref($navmap)) {
                    979:         # Unable to get data, so bail out
                    980:         $r->print("<h3>".
                    981:                   &mt('Unable to retrieve course information.').
                    982:                   '</h3>');
                    983:     }
                    984:     #
1.54      matthew   985:     my $total_columns = scalar(&get_student_fields_to_show());
1.90      matthew   986:     my $num_students = scalar(@Apache::lonstatistics::Students);
                    987:     #
1.115     matthew   988:     foreach my $seq (@sequences) {
1.88      matthew   989:         if ($chosen_output->{'every_problem'}) {
1.115     matthew   990:             $total_columns+=&count_parts($navmap,$seq);
1.88      matthew   991:         }
1.87      matthew   992:         # Add 2 because we need a 'sequence_sum' and 'total' column for each
1.88      matthew   993:         $total_columns += 2;
1.54      matthew   994:     }
1.105     matthew   995:     my $too_many_cols_error_message = 
                    996:         '<h2>'.&mt('Unable to Complete Request').'</h2>'.$/.
                    997:         '<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>'.$/.
                    998:         '<p>'.&mt('You may consider reducing the number of <b>Sequences or Folders</b> you have selected.').'</p>'.$/.
                    999:         '<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  1000:     if ($chosen_output->{'base'} eq 'tries' && $total_columns > 255) {
1.105     matthew  1001:         $r->print($too_many_cols_error_message);
                   1002:         $request_aborted = 1;
1.54      matthew  1003:     }
1.87      matthew  1004:     if ($chosen_output->{'base'} eq 'scores' && $total_columns > 255) {
1.105     matthew  1005:         $r->print($too_many_cols_error_message);
                   1006:         $request_aborted = 1;
1.54      matthew  1007:     }
                   1008:     return if ($request_aborted);
                   1009:     #
1.32      matthew  1010:     #
                   1011:     $excel_workbook = undef;
                   1012:     $excel_sheet = undef;
                   1013:     #
                   1014:     $rows_output = 0;
                   1015:     $cols_output = 0;
                   1016:     #
1.90      matthew  1017:     # Determine rows 
                   1018:     my $header_row = $rows_output++;
                   1019:     my $description_row = $rows_output++;
1.109     matthew  1020:     my $notes_row = $rows_output++;
1.90      matthew  1021:     $rows_output++;        # blank row
                   1022:     my $summary_header_row;
                   1023:     if ($chosen_output->{'summary_table'}) {
                   1024:         $summary_header_row = $rows_output++;
1.115     matthew  1025:         $rows_output+= scalar(@sequences);
1.90      matthew  1026:         $rows_output++;
                   1027:     }
                   1028:     my $sequence_name_row = $rows_output++;
                   1029:     my $resource_name_row = $rows_output++;
                   1030:     my $maximum_data_row = $rows_output++;
                   1031:     if (! $chosen_output->{'maximum_row'}) {
                   1032:         $rows_output--;
                   1033:     }
                   1034:     my $first_data_row = $rows_output++;
                   1035:     #
1.32      matthew  1036:     # Create sheet
1.117     matthew  1037:     ($excel_workbook,$filename,$format)=
                   1038:         &Apache::loncommon::create_workbook($r);
                   1039:     return if (! defined($excel_workbook));
1.91      matthew  1040:     #
1.32      matthew  1041:     # Add a worksheet
1.121   ! albertel 1042:     my $sheetname = $env{'course.'.$env{'request.course.id'}.'.description'};
1.67      matthew  1043:     $sheetname = &Apache::loncommon::clean_excel_name($sheetname);
1.33      matthew  1044:     $excel_sheet = $excel_workbook->addworksheet($sheetname);
1.85      matthew  1045:     #
1.34      matthew  1046:     # Put the course description in the header
1.90      matthew  1047:     $excel_sheet->write($header_row,$cols_output++,
1.121   ! albertel 1048:                    $env{'course.'.$env{'request.course.id'}.'.description'},
1.85      matthew  1049:                         $format->{'h1'});
1.34      matthew  1050:     $cols_output += 3;
                   1051:     #
                   1052:     # Put a description of the sections listed
                   1053:     my $sectionstring = '';
1.119     matthew  1054:     my @Sections = &Apache::lonstatistics::get_selected_sections();
1.120     matthew  1055:     $excel_sheet->write($header_row,$cols_output++,
                   1056:                         &Apache::lonstatistics::section_and_enrollment_description('plain text'),
1.85      matthew  1057:                         $format->{'h3'});
1.34      matthew  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.115     matthew  1087:     foreach my $seq (@sequences) {
                   1088:         my $symb = $seq->symb;
1.86      matthew  1089:         $excel_sheet->write($sequence_name_row,,
1.115     matthew  1090:                             $cols_output,$seq->compTitle,$format->{'bold'});
1.86      matthew  1091:         # Determine starting cell
1.115     matthew  1092:         $formula_data{$symb}->{'Excel:startcell'}=
1.86      matthew  1093:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90      matthew  1094:             ($first_data_row,$cols_output);
1.115     matthew  1095:         $formula_data{$symb}->{'Excel:startcol'}=$cols_output;
1.87      matthew  1096:         my $count = 0;
                   1097:         if ($chosen_output->{'every_problem'}) {
1.76      matthew  1098:             # Put the names of the problems and parts into the sheet
1.115     matthew  1099:             foreach my $res (&get_resources($navmap,$seq)) {
                   1100:                 if (scalar(@{$res->parts}) > 1) {
                   1101:                     foreach my $part (@{$res->parts}) {
1.86      matthew  1102:                         $excel_sheet->write($resource_name_row,
1.54      matthew  1103:                                             $cols_output++,
1.115     matthew  1104:                                             $res->compTitle.' part '.$res->part_display($part),
1.85      matthew  1105:                                             $format->{'bold'});
1.106     matthew  1106:                         $count++;
1.54      matthew  1107:                     }
                   1108:                 } else {
1.86      matthew  1109:                     $excel_sheet->write($resource_name_row,
1.54      matthew  1110:                                         $cols_output++,
1.115     matthew  1111:                                         $res->compTitle,$format->{'bold'});
1.106     matthew  1112:                     $count++;
1.54      matthew  1113:                 }
                   1114:             }
1.79      matthew  1115:         }
1.87      matthew  1116:         # Determine ending cell
                   1117:         if ($count <= 1) {
1.115     matthew  1118:             $formula_data{$symb}->{'Excel:endcell'} = $formula_data{$symb}->{'Excel:startcell'};
                   1119:             $formula_data{$symb}->{'Excel:endcol'}  = $formula_data{$symb}->{'Excel:startcol'};
1.87      matthew  1120:         } else {
1.115     matthew  1121:             $formula_data{$symb}->{'Excel:endcell'} = 
1.87      matthew  1122:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90      matthew  1123:                 ($first_data_row,$cols_output-1);
1.115     matthew  1124:             $formula_data{$symb}->{'Excel:endcol'} = $cols_output-1;
1.87      matthew  1125:         }
                   1126:         # Create the formula for summing up this sequence
1.115     matthew  1127:         if (! exists($formula_data{$symb}->{'Excel:endcell'}) ||
                   1128:             ! defined($formula_data{$symb}->{'Excel:endcell'})) {
                   1129:             $formula_data{$symb}->{'Excel:endcell'} = $formula_data{$symb}->{'Excel:startcell'};
                   1130:         }
                   1131:         $formula_data{$symb}->{'Excel:sum'}= $excel_sheet->store_formula
                   1132:             ('=SUM('.$formula_data{$symb}->{'Excel:startcell'}.
                   1133:              ':'.$formula_data{$symb}->{'Excel:endcell'}.')');
1.79      matthew  1134:         # Determine cell the score is held in
1.115     matthew  1135:         $formula_data{$symb}->{'Excel:scorecell'} = 
1.79      matthew  1136:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90      matthew  1137:             ($first_data_row,$cols_output);
1.115     matthew  1138:         $formula_data{$symb}->{'Excel:scorecol'}=$cols_output;
1.87      matthew  1139:         if ($chosen_output->{'base'} eq 'parts correct total') {
1.86      matthew  1140:             $excel_sheet->write($resource_name_row,$cols_output++,
                   1141:                                 'parts correct',
1.85      matthew  1142:                                 $format->{'bold'});
1.87      matthew  1143:         } elsif ($chosen_output->{'sequence_sum'}) {
                   1144:             if ($chosen_output->{'correct'}) {
                   1145:                 # Only reporting the number correct, so do not call it score
                   1146:                 $excel_sheet->write($resource_name_row,$cols_output++,
                   1147:                                     'sum',
                   1148:                                     $format->{'bold'});
                   1149:             } else {
                   1150:                 $excel_sheet->write($resource_name_row,$cols_output++,
                   1151:                                     'score',
                   1152:                                     $format->{'bold'});
                   1153:             }
1.32      matthew  1154:         }
1.79      matthew  1155:         #
                   1156:         $total_formula_string.='+'.
                   1157:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90      matthew  1158:             ($first_data_row,$cols_output-1);
1.87      matthew  1159:         if ($chosen_output->{'sequence_max'}) {
1.101     matthew  1160:             $excel_sheet->write($resource_name_row,$cols_output,
1.87      matthew  1161:                                 'maximum',
                   1162:                                 $format->{'bold'});
1.115     matthew  1163:             $formula_data{$symb}->{'Excel:maxcell'} = 
1.101     matthew  1164:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1165:                 ($first_data_row,$cols_output);
1.115     matthew  1166:             $formula_data{$symb}->{'Excel:maxcol'}=$cols_output;
1.101     matthew  1167:             $maximum_formula_string.='+'.
                   1168:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                   1169:                 ($first_data_row,$cols_output);
                   1170:             $cols_output++;
                   1171: 
1.87      matthew  1172:         }
                   1173:     }
                   1174:     if ($chosen_output->{'grand_total'}) {
                   1175:         $excel_sheet->write($resource_name_row,$cols_output++,'Total',
1.85      matthew  1176:                             $format->{'bold'});
1.32      matthew  1177:     }
1.101     matthew  1178:     if ($chosen_output->{'grand_maximum'}) {
                   1179:         $excel_sheet->write($resource_name_row,$cols_output++,'Max. Total',
                   1180:                             $format->{'bold'});
                   1181:     }
1.76      matthew  1182:     $total_formula = $excel_sheet->store_formula($total_formula_string);
1.101     matthew  1183:     $maximum_formula = $excel_sheet->store_formula($maximum_formula_string);
1.90      matthew  1184:     ##############################################
1.87      matthew  1185:     # Output a row for MAX, if appropriate
1.90      matthew  1186:     ##############################################
                   1187:     if ($chosen_output->{'maximum_row'}) {
1.87      matthew  1188:         $cols_output = 0;
                   1189:         foreach my $field (&get_student_fields_to_show()) {
                   1190:             if ($field eq 'username' || $field eq 'fullname' || 
                   1191:                 $field eq 'id') {
                   1192:                 $excel_sheet->write($maximum_data_row,$cols_output++,'Maximum',
                   1193:                                     $format->{'bold'});
                   1194:             } else {
                   1195:                 $excel_sheet->write($maximum_data_row,$cols_output++,'');
                   1196:             }
1.54      matthew  1197:         }
1.87      matthew  1198:         #
                   1199:         # Add the maximums for each sequence or assessment
                   1200:         my %total_cell_translation;
1.101     matthew  1201:         my %maximum_cell_translation;
1.115     matthew  1202:         foreach my $seq (@sequences) {
                   1203:             my $symb = $seq->symb;
                   1204:             $cols_output=$formula_data{$symb}->{'Excel:startcol'};
                   1205:             $total_cell_translation{$formula_data{$symb}->{'Excel:scorecell'}}=
1.87      matthew  1206:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115     matthew  1207:                 ($maximum_data_row,$formula_data{$symb}->{'Excel:scorecol'});
                   1208:             $maximum_cell_translation{$formula_data{$symb}->{'Excel:maxcell'}}=
1.101     matthew  1209:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115     matthew  1210:                 ($maximum_data_row,$formula_data{$symb}->{'Excel:maxcol'});
1.87      matthew  1211:             my $weight;
                   1212:             my $max = 0;
1.115     matthew  1213:             foreach my $resource (&get_resources($navmap,$seq)) {
                   1214:                 foreach my $part (@{$resource->parts}){
1.87      matthew  1215:                     $weight = 1;
                   1216:                     if ($chosen_output->{'scores'}) {
                   1217:                         $weight = &Apache::lonnet::EXT
                   1218:                             ('resource.'.$part.'.weight',$resource->{'symb'},
                   1219:                              undef,undef,undef);
                   1220:                         if (!defined($weight) || ($weight eq '')) { 
                   1221:                             $weight=1;
                   1222:                         }
                   1223:                     }
                   1224:                     if ($chosen_output->{'scores'} &&
                   1225:                         $chosen_output->{'every_problem'}) {
                   1226:                         $excel_sheet->write($maximum_data_row,$cols_output++,
                   1227:                                             $weight);
1.54      matthew  1228:                     }
1.87      matthew  1229:                     $max += $weight;
1.54      matthew  1230:                 }
1.87      matthew  1231:             } 
                   1232:             #
                   1233:             if ($chosen_output->{'sequence_sum'} && 
                   1234:                 $chosen_output->{'every_problem'}) {
1.110     albertel 1235: 		my %replaceCells=
1.115     matthew  1236: 		    ('^'.$formula_data{$symb}->{'Excel:startcell'}.':'.
                   1237: 		         $formula_data{$symb}->{'Excel:endcell'}.'$' =>
                   1238: 		     &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($maximum_data_row,$formula_data{$symb}->{'Excel:startcol'}).':'.
                   1239: 		     &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($maximum_data_row,$formula_data{$symb}->{'Excel:endcol'}));
1.87      matthew  1240:                 $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
1.115     matthew  1241:                                              $formula_data{$symb}->{'Excel:sum'},undef,
1.110     albertel 1242: 					     %replaceCells);
                   1243: 			
1.87      matthew  1244:             } elsif ($chosen_output->{'sequence_sum'}) {
                   1245:                 $excel_sheet->write($maximum_data_row,$cols_output++,$max);
                   1246:             }
                   1247:             if ($chosen_output->{'sequence_max'}) {
                   1248:                 $excel_sheet->write($maximum_data_row,$cols_output++,$max);
1.45      matthew  1249:             }
1.87      matthew  1250:             #
1.45      matthew  1251:         }
1.87      matthew  1252:         if ($chosen_output->{'grand_total'}) {
1.86      matthew  1253:             $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
1.87      matthew  1254:                                          $total_formula,undef,
                   1255:                                          %total_cell_translation);
1.79      matthew  1256:         }
1.101     matthew  1257:         if ($chosen_output->{'grand_maximum'}) {
                   1258:             $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
                   1259:                                          $maximum_formula,undef,
1.107     matthew  1260:                                          %maximum_cell_translation);
1.101     matthew  1261:         }
1.90      matthew  1262:     } # End of MAXIMUM row output  if ($chosen_output->{'maximum_row'}) {
1.86      matthew  1263:     $rows_output = $first_data_row;
1.90      matthew  1264:     ##############################################
                   1265:     # Output summary table, which actually is above the sequence name row.
                   1266:     ##############################################
                   1267:     if ($chosen_output->{'summary_table'}) {
                   1268:         $cols_output = 0;
                   1269:         $excel_sheet->write($summary_header_row,$cols_output++,
                   1270:                             'Summary Table',$format->{'bold'});
                   1271:         if ($chosen_output->{'maximum_row'}) {
                   1272:             $excel_sheet->write($summary_header_row,$cols_output++,
                   1273:                                 'Maximum',$format->{'bold'});
                   1274:         }
                   1275:         $excel_sheet->write($summary_header_row,$cols_output++,
                   1276:                             'Average',$format->{'bold'});
                   1277:         $excel_sheet->write($summary_header_row,$cols_output++,
                   1278:                             'Median',$format->{'bold'});
                   1279:         $excel_sheet->write($summary_header_row,$cols_output++,
                   1280:                             'Std Dev',$format->{'bold'});
                   1281:         my $row = $summary_header_row+1;
1.115     matthew  1282:         foreach my $seq (@sequences) {
                   1283:             my $symb = $seq->symb;
1.90      matthew  1284:             $cols_output = 0;
                   1285:             $excel_sheet->write($row,$cols_output++,
1.115     matthew  1286:                                 $seq->compTitle,
1.90      matthew  1287:                                 $format->{'bold'});
                   1288:             if ($chosen_output->{'maximum_row'}) {
                   1289:                 $excel_sheet->write
                   1290:                     ($row,$cols_output++,
                   1291:                      '='.
                   1292:                      &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115     matthew  1293:                      ($maximum_data_row,$formula_data{$symb}->{'Excel:scorecol'})
1.90      matthew  1294:                      );
                   1295:             }
                   1296:             my $range = 
                   1297:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115     matthew  1298:                 ($first_data_row,$formula_data{$symb}->{'Excel:scorecol'}).
1.90      matthew  1299:                 ':'.
                   1300:                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115     matthew  1301:                 ($first_data_row+$num_students-1,$formula_data{$symb}->{'Excel:scorecol'});
1.90      matthew  1302:             $excel_sheet->write($row,$cols_output++,
                   1303:                                 '=AVERAGE('.$range.')');
                   1304:             $excel_sheet->write($row,$cols_output++,
                   1305:                                 '=MEDIAN('.$range.')');
                   1306:             $excel_sheet->write($row,$cols_output++,
                   1307:                                 '=STDEV('.$range.')');
                   1308:             $row++;
                   1309:         }
                   1310:     }
                   1311:     ##############################################
                   1312:     #   Take care of non-excel initialization
                   1313:     ##############################################
1.32      matthew  1314:     #
                   1315:     # Let the user know what we are doing
                   1316:     my $studentcount = scalar(@Apache::lonstatistics::Students); 
1.121   ! albertel 1317:     if ($env{'form.SelectedStudent'}) {
1.85      matthew  1318:         $studentcount = '1';
                   1319:     }
                   1320:     if ($studentcount > 1) {
                   1321:         $r->print('<h1>'.&mt('Compiling Excel spreadsheet for [_1] students',
                   1322:                              $studentcount)."</h1>\n");
                   1323:     } else {
                   1324:         $r->print('<h1>'.
                   1325:                   &mt('Compiling Excel spreadsheet for 1 student').
                   1326:                   "</h1>\n");
                   1327:     }
1.32      matthew  1328:     $r->rflush();
1.31      matthew  1329:     #
1.36      matthew  1330:     # Initialize progress window
                   1331:     %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
                   1332:         ($r,'Excel File Compilation Status',
1.108     matthew  1333:          'Excel File Compilation Progress', $studentcount,
                   1334:          'inline',undef,'Statistics','stats_status');
1.36      matthew  1335:     #
1.62      matthew  1336:     &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,
                   1337:                                           'Processing first student');
1.31      matthew  1338:     return;
                   1339: }
                   1340: 
                   1341: sub excel_outputstudent {
                   1342:     my ($r,$student) = @_;
1.115     matthew  1343:     if ($request_aborted || ! defined($navmap) || ! defined($excel_sheet)) {
                   1344:         return;
                   1345:     }
1.32      matthew  1346:     $cols_output=0;
                   1347:     #
                   1348:     # Write out student data
                   1349:     my @to_show = &get_student_fields_to_show();
                   1350:     foreach my $field (@to_show) {
1.103     matthew  1351:         my $value = $student->{$field};
                   1352:         if ($field eq 'comments') {
                   1353:             $value = &Apache::lonmsg::retrieve_instructor_comments
                   1354:                 ($student->{'username'},$student->{'domain'});
                   1355:         }
                   1356:         $excel_sheet->write($rows_output,$cols_output++,$value);
1.32      matthew  1357:     }
                   1358:     #
                   1359:     # Get student assessment data
                   1360:     my %StudentsData;
                   1361:     my @tmp = &Apache::loncoursedata::get_current_state($student->{'username'},
                   1362:                                                         $student->{'domain'},
                   1363:                                                         undef,
1.121   ! albertel 1364:                                                    $env{'request.course.id'});
1.32      matthew  1365:     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
                   1366:         %StudentsData = @tmp;
                   1367:     }
                   1368:     #
                   1369:     # Write out sequence scores and totals data
1.76      matthew  1370:     my %total_cell_translation;
1.101     matthew  1371:     my %maximum_cell_translation;
1.115     matthew  1372:     foreach my $seq (@sequences) {
                   1373:         my $symb = $seq->symb;
                   1374:         $cols_output = $formula_data{$symb}->{'Excel:startcol'};
1.76      matthew  1375:         # Keep track of cells to translate in total cell
1.115     matthew  1376:         $total_cell_translation{$formula_data{$symb}->{'Excel:scorecell'}} = 
1.76      matthew  1377:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115     matthew  1378:                         ($rows_output,$formula_data{$symb}->{'Excel:scorecol'});
1.107     matthew  1379:         # and maximum cell
1.115     matthew  1380:         $maximum_cell_translation{$formula_data{$symb}->{'Excel:maxcell'}} = 
1.107     matthew  1381:             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115     matthew  1382:             ($rows_output,$formula_data{$symb}->{'Excel:maxcol'});
1.76      matthew  1383:         #
1.54      matthew  1384:         my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87      matthew  1385:         if ($chosen_output->{'tries'} || $chosen_output->{'correct'}){
1.54      matthew  1386:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.115     matthew  1387:                 &student_tries_on_sequence($student,\%StudentsData,
                   1388:                                            $navmap,$seq,'no');
1.54      matthew  1389:         } else {
                   1390:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.115     matthew  1391:                 &student_performance_on_sequence($student,\%StudentsData,
                   1392:                                                  $navmap,$seq,'no');
1.87      matthew  1393:         } 
                   1394:         if ($chosen_output->{'every_problem'}) {
                   1395:             if ($chosen_output->{'correct'}) {
                   1396:                 # only indiciate if each item is correct or not
                   1397:                 foreach my $value (@$rawdata) {
                   1398:                     # nonzero means correct
                   1399:                     $value = 1 if ($value > 0);
                   1400:                     $excel_sheet->write($rows_output,$cols_output++,$value);
                   1401:                 }
                   1402:             } else {
                   1403:                 foreach my $value (@$rawdata) {
1.97      matthew  1404:                     if ($score eq ' ' || !defined($value)) {
                   1405:                         $cols_output++;
                   1406:                     } else {                        
                   1407:                         $excel_sheet->write($rows_output,$cols_output++,
                   1408:                                             $value);
                   1409:                     }
1.87      matthew  1410:                 }
                   1411:             }
1.54      matthew  1412:         }
1.87      matthew  1413:         if ($chosen_output->{'sequence_sum'} && 
                   1414:             $chosen_output->{'every_problem'}) {
1.76      matthew  1415:             # Write a formula for the sum of this sequence
1.110     albertel 1416:             my %replaceCells=
1.115     matthew  1417: 		('^'.$formula_data{$symb}->{'Excel:startcell'}.':'.$formula_data{$symb}->{'Excel:endcell'}.'$'
1.110     albertel 1418: 		 => 
1.115     matthew  1419: 		 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($rows_output,$formula_data{$symb}->{'Excel:startcol'}).':'.
                   1420: 		 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($rows_output,$formula_data{$symb}->{'Excel:endcol'})
1.110     albertel 1421: 		 );
                   1422:             # The undef is for the format	    
                   1423: 	    $excel_sheet->repeat_formula($rows_output,$cols_output++,
1.115     matthew  1424: 					 $formula_data{$symb}->{'Excel:sum'},undef,
1.110     albertel 1425: 					 %replaceCells);
1.87      matthew  1426:         } elsif ($chosen_output->{'sequence_sum'}) {
1.97      matthew  1427:             if ($score eq ' ') {
                   1428:                 $cols_output++;
                   1429:             } else {
                   1430:                 $excel_sheet->write($rows_output,$cols_output++,$score);
                   1431:             }
1.32      matthew  1432:         }
1.87      matthew  1433:         if ($chosen_output->{'sequence_max'}) {
1.32      matthew  1434:             $excel_sheet->write($rows_output,$cols_output++,$seq_max);
                   1435:         }
                   1436:     }
1.76      matthew  1437:     #
1.87      matthew  1438:     if ($chosen_output->{'grand_total'}) {
                   1439:         $excel_sheet->repeat_formula($rows_output,$cols_output++,
                   1440:                                      $total_formula,undef,
                   1441:                                      %total_cell_translation);
                   1442:     }
1.101     matthew  1443:     if ($chosen_output->{'grand_maximum'}) {
                   1444:         $excel_sheet->repeat_formula($rows_output,$cols_output++,
                   1445:                                      $maximum_formula,undef,
1.107     matthew  1446:                                      %maximum_cell_translation);
1.101     matthew  1447:     }
1.32      matthew  1448:     #
                   1449:     # Bookkeeping
                   1450:     $rows_output++; 
                   1451:     $cols_output=0;
                   1452:     #
1.36      matthew  1453:     # Update the progress window
                   1454:     &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
1.32      matthew  1455:     return;
1.31      matthew  1456: }
                   1457: 
                   1458: sub excel_finish {
                   1459:     my ($r) = @_;
1.115     matthew  1460:     if ($request_aborted || ! defined($navmap) || ! defined($excel_sheet)) {
                   1461:         return;
                   1462:     }
1.32      matthew  1463:     #
                   1464:     # Write the excel file
                   1465:     $excel_workbook->close();
                   1466:     my $c = $r->connection();
                   1467:     #
                   1468:     return if($c->aborted());
                   1469:     #
1.36      matthew  1470:     # Close the progress window
                   1471:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
                   1472:     #
1.32      matthew  1473:     # Tell the user where to get their excel file
1.36      matthew  1474:     $r->print('<br />'.
1.32      matthew  1475:               '<a href="'.$filename.'">Your Excel spreadsheet.</a>'."\n");
                   1476:     $r->rflush();
                   1477:     return;
1.31      matthew  1478: }
                   1479: 
                   1480: }
1.30      matthew  1481: #######################################################
                   1482: #######################################################
                   1483: 
                   1484: =pod
                   1485: 
1.31      matthew  1486: =head2 CSV output routines
                   1487: 
                   1488: =item &csv_initialize($r)
                   1489: 
                   1490: =item &csv_outputstudent($r,$student)
                   1491: 
                   1492: =item &csv_finish($r)
1.30      matthew  1493: 
                   1494: =cut
                   1495: 
                   1496: #######################################################
                   1497: #######################################################
1.31      matthew  1498: {
                   1499: 
1.37      matthew  1500: my $outputfile;
                   1501: my $filename;
1.54      matthew  1502: my $request_aborted;
1.37      matthew  1503: my %prog_state; # progress window state
1.115     matthew  1504: my $navmap;
                   1505: my @sequences;
1.37      matthew  1506: 
1.31      matthew  1507: sub csv_initialize{
                   1508:     my ($r) = @_;
1.37      matthew  1509:     # 
                   1510:     # Clean up
1.66      matthew  1511:     undef($outputfile);
                   1512:     undef($filename);
                   1513:     undef($request_aborted);
1.37      matthew  1514:     undef(%prog_state);
                   1515:     #
1.115     matthew  1516:     undef($navmap);
                   1517:     undef(@sequences);
                   1518:     ($navmap,@sequences) = 
                   1519:         &Apache::lonstatistics::selected_sequences_with_assessments();
                   1520:     if (! ref($navmap)) {
                   1521:         # Unable to get data, so bail out
                   1522:         $r->print("<h3>".
                   1523:                   &mt('Unable to retrieve course information.').
                   1524:                   '</h3>');
                   1525:     }
                   1526:     #
1.54      matthew  1527:     # Deal with unimplemented requests
                   1528:     $request_aborted = undef;
1.87      matthew  1529:     if ($chosen_output->{'base'} =~ /final table/) {
1.54      matthew  1530:         $r->print(<<END);
                   1531: <h2>Unable to Complete Request</h2>
                   1532: <p>
                   1533: The <b>Summary Table (Scores)</b> option is not available for non-HTML output.
                   1534: </p>
                   1535: END
                   1536:        $request_aborted = 1;
                   1537:     }
                   1538:     return if ($request_aborted);
1.87      matthew  1539:     #
                   1540:     # Initialize progress window
                   1541:     my $studentcount = scalar(@Apache::lonstatistics::Students);
                   1542:     %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
                   1543:         ($r,'CSV File Compilation Status',
1.108     matthew  1544:          'CSV File Compilation Progress', $studentcount,
                   1545:          'inline',undef,'Statistics','stats_status');
1.54      matthew  1546:     #
1.37      matthew  1547:     # Open a file
1.120     matthew  1548:     ($outputfile,$filename) = &Apache::loncommon::create_text_file($r,'csv');
                   1549:     if (! defined($outputfile)) { return ''; }
1.38      matthew  1550:     #
                   1551:     # Datestamp
1.121   ! albertel 1552:     my $description = $env{'course.'.$env{'request.course.id'}.'.description'};
1.38      matthew  1553:     print $outputfile '"'.&Apache::loncommon::csv_translate($description).'",'.
                   1554:         '"'.&Apache::loncommon::csv_translate(scalar(localtime(time))).'"'.
                   1555:             "\n";
1.120     matthew  1556:     print $outputfile '"'.
                   1557:         &Apache::loncommon::csv_translate
                   1558:         (&Apache::lonstatistics::section_and_enrollment_description()).
                   1559:         '"'."\n";
1.109     matthew  1560:     foreach my $item ('shortdesc','non_html_notes') {
                   1561:         next if (! exists($chosen_output->{$item}));
                   1562:         print $outputfile 
                   1563:             '"'.&Apache::loncommon::csv_translate($chosen_output->{$item}).'"'.
                   1564:             "\n";
                   1565:     }
1.37      matthew  1566:     #
                   1567:     # Print out the headings
1.87      matthew  1568:     my $sequence_row = '';
                   1569:     my $resource_row = undef;
1.37      matthew  1570:     foreach my $field (&get_student_fields_to_show()) {
1.87      matthew  1571:         $sequence_row .='"",';
                   1572:         $resource_row .= '"'.&Apache::loncommon::csv_translate($field).'",';
1.37      matthew  1573:     }
1.115     matthew  1574:     foreach my $seq (@sequences) {
1.87      matthew  1575:         $sequence_row .= '"'.
1.115     matthew  1576:             &Apache::loncommon::csv_translate($seq->compTitle).'",';
1.87      matthew  1577:         my $count = 0;
                   1578:         if ($chosen_output->{'every_problem'}) {
1.116     matthew  1579:             foreach my $res (&get_resources($navmap,$seq)) {
1.115     matthew  1580:                 if (scalar(@{$res->parts}) < 1) {
1.87      matthew  1581:                     next;
                   1582:                 }
1.115     matthew  1583:                 foreach my $part (@{$res->parts}) {
1.87      matthew  1584:                     $resource_row .= '"'.
1.115     matthew  1585:                         &Apache::loncommon::csv_translate
                   1586:                         ($res->compTitle.', Part '.$res->part_display($part)).'",';
1.87      matthew  1587:                     $count++;
1.53      matthew  1588:                 }
                   1589:             }
1.37      matthew  1590:         }
1.87      matthew  1591:         $sequence_row.='"",'x$count;
                   1592:         if ($chosen_output->{'sequence_sum'}) {
                   1593:             if($chosen_output->{'correct'}) {
                   1594:                 $resource_row .= '"sum",';
                   1595:             } else {
                   1596:                 $resource_row .= '"score",';
                   1597:             }
                   1598:         }
                   1599:         if ($chosen_output->{'sequence_max'}) {
                   1600:             $sequence_row.= '"",';
                   1601:             $resource_row .= '"maximum possible",';
                   1602:         }
1.37      matthew  1603:     }
1.87      matthew  1604:     if ($chosen_output->{'grand_total'}) {
                   1605:         $sequence_row.= '"",';
                   1606:         $resource_row.= '"Total",';
                   1607:     } 
1.101     matthew  1608:     if ($chosen_output->{'grand_maximum'}) {
                   1609:         $sequence_row.= '"",';
                   1610:         $resource_row.= '"Maximum",';
                   1611:     } 
1.87      matthew  1612:     chomp($sequence_row);
                   1613:     chomp($resource_row);
                   1614:     print $outputfile $sequence_row."\n";
                   1615:     print $outputfile $resource_row."\n";
1.31      matthew  1616:     return;
                   1617: }
                   1618: 
                   1619: sub csv_outputstudent {
                   1620:     my ($r,$student) = @_;
1.115     matthew  1621:     if ($request_aborted || ! defined($navmap) || ! defined($outputfile)) {
                   1622:         return;
                   1623:     }
1.37      matthew  1624:     my $Str = '';
                   1625:     #
                   1626:     # Output student fields
                   1627:     my @to_show = &get_student_fields_to_show();
                   1628:     foreach my $field (@to_show) {
1.103     matthew  1629:         my $value = $student->{$field};
                   1630:         if ($field eq 'comments') {
                   1631:             $value = &Apache::lonmsg::retrieve_instructor_comments
                   1632:                 ($student->{'username'},$student->{'domain'});
                   1633:         }        
                   1634:         $Str .= '"'.&Apache::loncommon::csv_translate($value).'",';
1.37      matthew  1635:     }
                   1636:     #
                   1637:     # Get student assessment data
                   1638:     my %StudentsData;
                   1639:     my @tmp = &Apache::loncoursedata::get_current_state($student->{'username'},
                   1640:                                                         $student->{'domain'},
                   1641:                                                         undef,
1.121   ! albertel 1642:                                                    $env{'request.course.id'});
1.37      matthew  1643:     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
                   1644:         %StudentsData = @tmp;
                   1645:     }
                   1646:     #
                   1647:     # Output performance data
1.87      matthew  1648:     my $total = 0;
1.101     matthew  1649:     my $maximum = 0;
1.115     matthew  1650:     foreach my $seq (@sequences) {
1.54      matthew  1651:         my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87      matthew  1652:         if ($chosen_output->{'tries'}){
1.54      matthew  1653:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.115     matthew  1654:                 &student_tries_on_sequence($student,\%StudentsData,
                   1655:                                            $navmap,$seq,'no');
1.54      matthew  1656:         } else {
                   1657:             ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.115     matthew  1658:                 &student_performance_on_sequence($student,\%StudentsData,
                   1659:                                                  $navmap,$seq,'no');
1.54      matthew  1660:         }
1.87      matthew  1661:         if ($chosen_output->{'every_problem'}) {
                   1662:             if ($chosen_output->{'correct'}) {
                   1663:                 $score = 0;
                   1664:                 # Deal with number of parts correct data
                   1665:                 $Str .= '"'.join('","',( map { if ($_>0) { 
                   1666:                                                    $score += 1;
                   1667:                                                    1; 
                   1668:                                                } else { 
                   1669:                                                    0; 
                   1670:                                                }
                   1671:                                              } @$rawdata)).'",';
                   1672:             } else {
                   1673:                 $Str .= '"'.join('","',(@$rawdata)).'",';
                   1674:             }
                   1675:         }
                   1676:         if ($chosen_output->{'sequence_sum'}) {
1.37      matthew  1677:             $Str .= '"'.$score.'",';
1.87      matthew  1678:         } 
                   1679:         if ($chosen_output->{'sequence_max'}) {
                   1680:             $Str .= '"'.$seq_max.'",';
1.37      matthew  1681:         }
1.87      matthew  1682:         $total+=$score;
1.101     matthew  1683:         $maximum += $seq_max;
1.87      matthew  1684:     }
                   1685:     if ($chosen_output->{'grand_total'}) {
                   1686:         $Str .= '"'.$total.'",';
1.101     matthew  1687:     }
                   1688:     if ($chosen_output->{'grand_maximum'}) {
                   1689:         $Str .= '"'.$maximum.'",';
1.37      matthew  1690:     }
                   1691:     chop($Str);
                   1692:     $Str .= "\n";
                   1693:     print $outputfile $Str;
                   1694:     #
                   1695:     # Update the progress window
                   1696:     &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
                   1697:     return;
1.31      matthew  1698: }
                   1699: 
                   1700: sub csv_finish {
                   1701:     my ($r) = @_;
1.115     matthew  1702:     if ($request_aborted || ! defined($navmap) || ! defined($outputfile)) {
                   1703:         return;
                   1704:     }
1.37      matthew  1705:     close($outputfile);
                   1706:     #
                   1707:     my $c = $r->connection();
                   1708:     return if ($c->aborted());
                   1709:     #
                   1710:     # Close the progress window
                   1711:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
                   1712:     #
                   1713:     # Tell the user where to get their csv file
                   1714:     $r->print('<br />'.
1.95      matthew  1715:               '<a href="'.$filename.'">'.&mt('Your csv file.').'</a>'."\n");
1.37      matthew  1716:     $r->rflush();
                   1717:     return;
                   1718:     
1.31      matthew  1719: }
1.2       stredwic 1720: 
                   1721: }
                   1722: 
1.28      matthew  1723: #######################################################
                   1724: #######################################################
                   1725: 
1.2       stredwic 1726: =pod
                   1727: 
1.54      matthew  1728: =item &StudentTriesOnSequence()
1.2       stredwic 1729: 
1.30      matthew  1730: Inputs:
1.2       stredwic 1731: 
                   1732: =over 4
                   1733: 
1.30      matthew  1734: =item $student
1.28      matthew  1735: 
1.30      matthew  1736: =item $studentdata Hash ref to all student data
1.2       stredwic 1737: 
1.30      matthew  1738: =item $seq Hash ref, the sequence we are working on
1.2       stredwic 1739: 
1.30      matthew  1740: =item $links if defined we will output links to each resource.
1.2       stredwic 1741: 
1.28      matthew  1742: =back
1.2       stredwic 1743: 
                   1744: =cut
1.1       stredwic 1745: 
1.28      matthew  1746: #######################################################
                   1747: #######################################################
1.112     matthew  1748: sub student_tries_on_sequence {
                   1749:     my ($student,$studentdata,$navmap,$seq,$links) = @_;
1.31      matthew  1750:     $links = 'no' if (! defined($links));
1.1       stredwic 1751:     my $Str = '';
1.30      matthew  1752:     my ($sum,$max) = (0,0);
1.51      matthew  1753:     my $performance_length = 0;
1.54      matthew  1754:     my @TriesData = ();
                   1755:     my $tries;
1.97      matthew  1756:     my $hasdata = 0; # flag - true if the student has any data on the sequence
1.115     matthew  1757:     foreach my $resource (&get_resources($navmap,$seq)) {
1.112     matthew  1758:         my $resource_data = $studentdata->{$resource->symb};
1.30      matthew  1759:         my $value = '';
1.112     matthew  1760:         foreach my $partnum (@{$resource->parts()}) {
1.54      matthew  1761:             $tries = undef;
1.30      matthew  1762:             $max++;
1.51      matthew  1763:             $performance_length++;
1.30      matthew  1764:             my $symbol = ' '; # default to space
                   1765:             #
1.78      matthew  1766:             my $awarded = 0;
                   1767:             if (exists($resource_data->{'resource.'.$partnum.'.awarded'})) {
                   1768:                 $awarded = $resource_data->{'resource.'.$partnum.'.awarded'};
                   1769:                 $awarded = 0 if (! $awarded);
                   1770:             }
                   1771:             #
                   1772:             my $status = '';
1.30      matthew  1773:             if (exists($resource_data->{'resource.'.$partnum.'.solved'})) {
1.78      matthew  1774:                 $status = $resource_data->{'resource.'.$partnum.'.solved'};
                   1775:             }
                   1776:             #
                   1777:             my $tries = 0;
                   1778:             if(exists($resource_data->{'resource.'.$partnum.'.tries'})) {
                   1779:                 $tries = $resource_data->{'resource.'.$partnum.'.tries'};
1.97      matthew  1780:                 $hasdata =1;
1.78      matthew  1781:             }
                   1782:             #
                   1783:             if ($awarded > 0) {
                   1784:                 # The student has gotten the problem correct to some degree
                   1785:                 if ($status eq 'excused') {
                   1786:                     $symbol = 'x';
                   1787:                     $max--;
                   1788:                 } elsif ($status eq 'correct_by_override') {
1.30      matthew  1789:                     $symbol = '+';
                   1790:                     $sum++;
1.78      matthew  1791:                 } elsif ($tries > 0) {
1.54      matthew  1792:                     if ($tries > 9) {
1.30      matthew  1793:                         $symbol = '*';
1.78      matthew  1794:                     } else {
1.54      matthew  1795:                         $symbol = $tries;
1.30      matthew  1796:                     }
                   1797:                     $sum++;
                   1798:                 } else {
1.78      matthew  1799:                     $symbol = '+';
                   1800:                     $sum++;
1.2       stredwic 1801:                 }
1.30      matthew  1802:             } else {
1.78      matthew  1803:                 # The student has the problem incorrect or it is ungraded
                   1804:                 if ($status eq 'excused') {
                   1805:                     $symbol = 'x';
                   1806:                     $max--;
                   1807:                 } elsif ($status eq 'incorrect_by_override') {
                   1808:                     $symbol = '-';
                   1809:                 } elsif ($status eq 'ungraded_attempted') {
                   1810:                     $symbol = '#';
                   1811:                 } elsif ($status eq 'incorrect_attempted' ||
                   1812:                          $tries > 0)  {
1.30      matthew  1813:                     $symbol = '.';
                   1814:                 } else {
1.78      matthew  1815:                     # Problem is wrong and has not been attempted.
                   1816:                     $symbol=' ';
1.18      matthew  1817:                 }
1.2       stredwic 1818:             }
1.54      matthew  1819:             #
1.109     matthew  1820:             if (! defined($tries)) {
                   1821:                 $tries = 0;
                   1822:             }
                   1823:             if ($status =~ /^(incorrect|ungraded)/) {
                   1824:                 # Bug 3390: show '-' for tries on incorrect problems 
                   1825:                 # (csv & excel only)
                   1826:                 push(@TriesData,-$tries);
                   1827:             } else {
                   1828:                 push (@TriesData,$tries);
1.54      matthew  1829:             }
1.30      matthew  1830:             #
1.47      matthew  1831:             if ( ($links eq 'yes' && $symbol ne ' ') ||
                   1832:                  ($links eq 'all')) {
1.49      matthew  1833:                 if (length($symbol) > 1) {
                   1834:                     &Apache::lonnet::logthis('length of symbol "'.$symbol.'" > 1');
                   1835:                 }
1.30      matthew  1836:                 $symbol = '<a href="/adm/grades'.
1.112     matthew  1837:                     '?symb='.&Apache::lonnet::escape($resource->symb).
1.30      matthew  1838:                         '&student='.$student->{'username'}.
1.64      albertel 1839:                             '&userdom='.$student->{'domain'}.
1.30      matthew  1840:                                 '&command=submission">'.$symbol.'</a>';
                   1841:             }
                   1842:             $value .= $symbol;
1.2       stredwic 1843:         }
1.30      matthew  1844:         $Str .= $value;
1.17      minaeibi 1845:     }
1.112     matthew  1846:     if ($seq->randompick()) {
                   1847:         $max = $seq->randompick();
1.51      matthew  1848:     }
1.97      matthew  1849:     if (! $hasdata && $sum == 0) {
                   1850:         $sum = ' ';
                   1851:     }
1.54      matthew  1852:     return ($Str,$performance_length,$sum,$max,\@TriesData);
                   1853: }
                   1854: 
                   1855: #######################################################
                   1856: #######################################################
                   1857: 
                   1858: =pod
                   1859: 
1.115     matthew  1860: =item &student_performance_on_sequence
1.54      matthew  1861: 
                   1862: Inputs:
                   1863: 
                   1864: =over 4
                   1865: 
                   1866: =item $student
                   1867: 
                   1868: =item $studentdata Hash ref to all student data
                   1869: 
                   1870: =item $seq Hash ref, the sequence we are working on
                   1871: 
                   1872: =item $links if defined we will output links to each resource.
                   1873: 
                   1874: =back
                   1875: 
                   1876: =cut
                   1877: 
                   1878: #######################################################
                   1879: #######################################################
1.112     matthew  1880: sub student_performance_on_sequence {
                   1881:     my ($student,$studentdata,$navmap,$seq,$links) = @_;
1.54      matthew  1882:     $links = 'no' if (! defined($links));
                   1883:     my $Str = ''; # final result string
                   1884:     my ($score,$max) = (0,0);
                   1885:     my $performance_length = 0;
                   1886:     my $symbol;
                   1887:     my @ScoreData = ();
                   1888:     my $partscore;
1.97      matthew  1889:     my $hasdata = 0; # flag, 0 if there were no submissions on the sequence
1.115     matthew  1890:     foreach my $resource (&get_resources($navmap,$seq)) {
1.112     matthew  1891:         my $symb = $resource->symb;
                   1892:         my $resource_data = $studentdata->{$symb};
                   1893:         foreach my $part (@{$resource->parts()}) {
1.54      matthew  1894:             $partscore = undef;
                   1895:             my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',
1.112     matthew  1896:                                               $symb,
1.54      matthew  1897:                                               $student->{'domain'},
                   1898:                                               $student->{'username'},
                   1899:                                               $student->{'section'});
                   1900:             if (!defined($weight) || ($weight eq '')) { 
                   1901:                 $weight=1;
                   1902:             }
                   1903:             #
                   1904:             $max += $weight; # see the 'excused' branch below...
                   1905:             $performance_length++; # one character per part
                   1906:             $symbol = ' '; # default to space
                   1907:             #
1.97      matthew  1908:             my $awarded;
1.54      matthew  1909:             if (exists($resource_data->{'resource.'.$part.'.awarded'})) {
                   1910:                 $awarded = $resource_data->{'resource.'.$part.'.awarded'};
1.67      matthew  1911:                 $awarded = 0 if (! $awarded);
1.97      matthew  1912:                 $hasdata = 1;
1.54      matthew  1913:             }
                   1914:             #
                   1915:             $partscore = $weight*$awarded;
1.97      matthew  1916:             if (! defined($awarded)) {
                   1917:                 $partscore = undef;
                   1918:             }
1.54      matthew  1919:             $score += $partscore;
1.63      matthew  1920:             $symbol = $partscore; 
1.70      matthew  1921:             if (abs($symbol - sprintf("%.0f",$symbol)) < 0.001) {
                   1922:                 $symbol = sprintf("%.0f",$symbol);
                   1923:             }
1.54      matthew  1924:             if (length($symbol) > 1) {
                   1925:                 $symbol = '*';
                   1926:             }
                   1927:             if (exists($resource_data->{'resource.'.$part.'.solved'})) {
                   1928:                 my $status = $resource_data->{'resource.'.$part.'.solved'};
                   1929:                 if ($status eq 'excused') {
                   1930:                     $symbol = 'x';
                   1931:                     $max -= $weight; # Do not count 'excused' problems.
                   1932:                 }
1.97      matthew  1933:                 $hasdata = 1;
1.111     matthew  1934:             } elsif (!exists($resource_data->{'resource.'.$part.'.awarded'})){
1.54      matthew  1935:                 # Unsolved.  Did they try?
                   1936:                 if (exists($resource_data->{'resource.'.$part.'.tries'})){
                   1937:                     $symbol = '.';
1.97      matthew  1938:                     $hasdata = 1;
1.54      matthew  1939:                 } else {
                   1940:                     $symbol = ' ';
                   1941:                 }
                   1942:             }
                   1943:             #
1.60      matthew  1944:             if (! defined($partscore)) {
                   1945:                 $partscore = $symbol;
                   1946:             }
                   1947:             push (@ScoreData,$partscore);
                   1948:             #
1.54      matthew  1949:             if ( ($links eq 'yes' && $symbol ne ' ') || ($links eq 'all')) {
                   1950:                 $symbol = '<a href="/adm/grades'.
1.112     matthew  1951:                     '?symb='.&Apache::lonnet::escape($symb).
1.54      matthew  1952:                     '&student='.$student->{'username'}.
1.64      albertel 1953:                     '&userdom='.$student->{'domain'}.
1.54      matthew  1954:                     '&command=submission">'.$symbol.'</a>';
                   1955:             }
1.60      matthew  1956:             $Str .= $symbol;
1.54      matthew  1957:         }
1.97      matthew  1958:     }
                   1959:     if (! $hasdata && $score == 0) {
                   1960:         $score = ' ';
1.54      matthew  1961:     }
                   1962:     return ($Str,$performance_length,$score,$max,\@ScoreData);
1.1       stredwic 1963: }
1.23      minaeibi 1964: 
1.28      matthew  1965: #######################################################
                   1966: #######################################################
1.23      minaeibi 1967: 
1.2       stredwic 1968: =pod
                   1969: 
                   1970: =item &CreateLegend()
                   1971: 
                   1972: This function returns a formatted string containing the legend for the
                   1973: chart.  The legend describes the symbols used to represent grades for
                   1974: problems.
                   1975: 
                   1976: =cut
                   1977: 
1.28      matthew  1978: #######################################################
                   1979: #######################################################
1.2       stredwic 1980: sub CreateLegend {
                   1981:     my $Str = "<p><pre>".
1.13      minaeibi 1982:               "   1  correct by student in 1 try\n".
                   1983:               "   7  correct by student in 7 tries\n".
1.12      minaeibi 1984:               "   *  correct by student in more than 9 tries\n".
1.20      minaeibi 1985: 	      "   +  correct by hand grading or override\n".
1.12      minaeibi 1986:               "   -  incorrect by override\n".
                   1987: 	      "   .  incorrect attempted\n".
                   1988: 	      "   #  ungraded attempted\n".
1.13      minaeibi 1989:               "      not attempted (blank field)\n".
1.12      minaeibi 1990: 	      "   x  excused".
1.17      minaeibi 1991:               "</pre><p>";
1.2       stredwic 1992:     return $Str;
                   1993: }
                   1994: 
1.28      matthew  1995: #######################################################
                   1996: #######################################################
                   1997: 
1.30      matthew  1998: =pod 
1.2       stredwic 1999: 
                   2000: =back
                   2001: 
                   2002: =cut
                   2003: 
1.28      matthew  2004: #######################################################
                   2005: #######################################################
1.2       stredwic 2006: 
1.28      matthew  2007: 1;
1.2       stredwic 2008: 
1.1       stredwic 2009: __END__

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