File:  [LON-CAPA] / loncom / interface / statistics / lonstudentsubmissions.pm
Revision 1.56: download - view: text, annotated - select for diffs
Thu Jan 14 17:20:51 2010 UTC (14 years, 5 months ago) by bisitz
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_99_1, bz6209-base, bz6209, HEAD
Consistent screen ergonomics:
- First checkbox, then option text
- Removed special styles

    1: # The LearningOnline Network with CAPA
    2: #
    3: # $Id: lonstudentsubmissions.pm,v 1.56 2010/01/14 17:20:51 bisitz Exp $
    4: #
    5: # Copyright Michigan State University Board of Trustees
    6: #
    7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    8: #
    9: # LON-CAPA is free software; you can redistribute it and/or modify
   10: # it under the terms of the GNU General Public License as published by
   11: # the Free Software Foundation; either version 2 of the License, or
   12: # (at your option) any later version.
   13: #
   14: # LON-CAPA is distributed in the hope that it will be useful,
   15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17: # GNU General Public License for more details.
   18: #
   19: # You should have received a copy of the GNU General Public License
   20: # along with LON-CAPA; if not, write to the Free Software
   21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22: #
   23: # /home/httpd/html/adm/gpl.txt
   24: #
   25: # http://www.lon-capa.org/
   26: #
   27: package Apache::lonstudentsubmissions;
   28: 
   29: use strict;
   30: use Apache::lonnet;
   31: use Apache::loncommon();
   32: use Apache::lonhtmlcommon();
   33: use Apache::loncoursedata();
   34: use Apache::lonstatistics;
   35: use Apache::lonlocal;
   36: use Apache::lonstathelpers;
   37: use HTML::Entities();
   38: use Time::Local();
   39: use Spreadsheet::WriteExcel();
   40: use lib '/home/httpd/lib/perl/';
   41: use LONCAPA;
   42:   
   43: 
   44: my @SubmitButtons = ({ name => 'SelectAnother',
   45:                        text => 'Choose a different Problem' },
   46:                      { name => 'Generate',
   47:                        text => 'Generate Report'},
   48:                      );
   49: 
   50: sub BuildStudentSubmissionsPage {
   51:     my ($r,$c)=@_;
   52:     #
   53:     my %Saveable_Parameters = ('Status' => 'scalar',
   54:                                'Section' => 'array',
   55:                                'NumPlots' => 'scalar',
   56:                                );
   57:     &Apache::loncommon::store_course_settings('student_submissions',
   58:                                               \%Saveable_Parameters);
   59:     &Apache::loncommon::restore_course_settings('student_submissions',
   60:                                                 \%Saveable_Parameters);
   61:     #
   62:     &Apache::lonstatistics::PrepareClasslist();
   63:     #
   64:     $r->print(&CreateInterface());
   65:     #
   66:     my @Students = @Apache::lonstatistics::Students;
   67:     #
   68:     if (@Students < 1) {
   69:         $r->print('<div class="LC_warning">'
   70:                  .&mt('There are no students in the sections selected.')
   71:                  .'</div>');
   72:     }
   73:     #
   74:     my @CacheButtonHTML = 
   75:         &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status',
   76:                                    '<div class="LC_info">'.&mt('Loading student data...').'</div>');
   77:     $r->rflush();
   78:     #
   79:     if (exists($env{'form.problemchoice'}) && 
   80:         ! exists($env{'form.SelectAnother'})) {
   81:         foreach my $button (@SubmitButtons) {
   82:             if ($button->{'name'} eq 'break') {
   83:                 $r->print("<br />\n");
   84:             } else {
   85:                 $r->print('<input type="submit" name="'.$button->{'name'}.'" '.
   86:                           'value="'.&mt($button->{'text'}).'" />');
   87:                 $r->print('&nbsp;'x5);
   88:             }
   89:         }
   90:         foreach my $html (@CacheButtonHTML) {
   91:             $r->print($html.('&nbsp;'x5));
   92:         }
   93:         #
   94:         $r->print('<hr />'.$/);
   95:         $r->rflush();
   96:         #
   97:         # Determine which problems we are to analyze
   98:         my @Symbs = 
   99:             &Apache::lonstathelpers::get_selected_symbs('problemchoice');
  100:         foreach my $selected (@Symbs) {
  101:             $r->print('<input type="hidden" name="problemchoice" value="'.
  102:                       $selected.'" />'.$/);
  103:         }
  104:         #
  105:         # Get resource objects
  106:         my $navmap = Apache::lonnavmaps::navmap->new();
  107:         if (!defined($navmap)) {
  108:             $r->print('<div class="LC_error">'.&mt("Internal error").'</div>');
  109:             return;
  110:         }
  111:         my %already_seen;
  112:         my @Problems;
  113:         foreach my $symb (@Symbs) {
  114:             my $resource = $navmap->getBySymb($symb);
  115:             push(@Problems,$resource);
  116:         }
  117:         # 
  118:         $r->print('<h4>'.
  119:                   &Apache::lonstatistics::section_and_enrollment_description().
  120:                   '</h4>');
  121:         if (! scalar(@Problems) || ! defined($Problems[0])) {
  122:             $r->print('resource is undefined');
  123:         } else {
  124:             if (scalar(@Problems) == 1) {
  125:                 my $resource = $Problems[0];
  126:                 $r->print('<h1>'.$resource->title.'</h1>');
  127:                 $r->print('<h3>'.$resource->src.'</h3>');
  128:                 if ($env{'form.renderprob'} eq 'true') {
  129:                     $r->print(&Apache::lonstathelpers::render_resource($resource));
  130:                     $r->rflush();
  131:                 }
  132:             }
  133:             if ($env{'form.output'} eq 'excel') {
  134:                 &prepare_excel_output($r,\@Problems,\@Students);
  135:             } elsif ($env{'form.output'} eq 'csv') {
  136:                 &prepare_csv_output($r,\@Problems,\@Students);
  137:             } else {
  138:                 &prepare_html_output($r,\@Problems,\@Students);
  139:             }
  140:         }
  141:         $r->print('<hr />');
  142:     } else {
  143:         $r->print('<input type="submit" name="Generate" value="'.
  144:                   &mt('Prepare Report').'" />');
  145:         $r->print('&nbsp;'x5);
  146:         $r->print('<p>'.
  147:                   &mt('Computing correct answers greatly increasese the amount of time required to prepare a report.').
  148:                   '</p>');
  149:         $r->print('<p>'.
  150:                   &mt('Please select problems and use the [_1]Prepare Report[_2] button to continue.','<b>','</b>').
  151:                   '</p>');
  152:         $r->print(&Apache::lonstathelpers::MultipleProblemSelector
  153:                   (undef,'problemchoice','Statistics'));
  154:     }
  155: }
  156: 
  157: ##
  158: ## get_extra_response_headers
  159: ##
  160: sub get_extra_response_headers {
  161:     my @extra_resp_headers;
  162:     if ($env{'form.correctans'} eq 'true') {
  163:         push(@extra_resp_headers,'Correct');
  164:     } 
  165:     if ($env{'form.prob_status'} eq 'true') {
  166:         push(@extra_resp_headers,'Award Detail'); 
  167:         push(@extra_resp_headers,'Time');
  168:         push(@extra_resp_headers,'Attempt');
  169:         push(@extra_resp_headers,'Awarded');
  170:     }
  171:     return @extra_resp_headers;
  172: }
  173: 
  174: ##
  175: ## get_headers:
  176: ##     return the proper headers for the given response 
  177: sub get_headers {
  178:     my ($prob,$partid,$respid,$resptype,$analysis,$output,$purpose,
  179:         @basic_headers) = @_;
  180:     my @headers;
  181:     if ($resptype eq 'essay' && $purpose eq 'display' &&
  182:         ($output eq 'html')) {# || scalar(@{$prob->parts})!=1)) {
  183:         @headers = ();
  184:     } elsif ($resptype =~ /^(option|match|rank)$/) {
  185:         my $prefix = '_';
  186:         if ($purpose eq 'display') {
  187:             $prefix = '';
  188:         }
  189:         my @foils = 
  190:             map { 
  191:                 $prefix.$_; 
  192:             } sort(keys(%{$analysis->{$partid.'.'.$respid}->{'_Foils'}}));
  193:         if (scalar(@basic_headers) && $basic_headers[0] eq 'Correct') {
  194:             @foils = map { ($_ , $_.' Correct') } @foils;
  195:             shift(@basic_headers);  # Get rid of 'Correct'
  196:         }
  197:         @headers = (@foils,@basic_headers);
  198:     } elsif (lc($resptype) eq 'task') {
  199:         @headers = ('Grader','Status',@basic_headers,'Submission');
  200:     } else {
  201:         @headers = ('Submission',@basic_headers);
  202:     }
  203:     return @headers;
  204: }
  205: 
  206: #########################################################
  207: #########################################################
  208: ##
  209: ##    HTML Output Routines
  210: ##
  211: #########################################################
  212: #########################################################
  213: sub prepare_html_output {
  214:     my ($r,$problems,$students) = @_;
  215:     my $c = $r->connection();
  216:     #
  217:     # Set a flag for the case when there is just one problem
  218:     my $single_response = 0;
  219:     if (scalar(@$problems) == 1 &&
  220:         $problems->[0]->countResponses == 1) {
  221:         $single_response = 1;
  222:     }
  223:     #
  224:     # Compute the number of columns per response
  225:     my @extra_resp_headers = &get_extra_response_headers();
  226:     #
  227:     # Create the table header
  228:     my @student_columns = ('username','domain','id','section');
  229:     #
  230:     my %headers;
  231:     my $student_column_count = scalar(@student_columns);
  232:     $headers{'problem'} = qq{<th colspan="$student_column_count">\&nbsp;</th>};
  233:     foreach (@student_columns) {
  234:         $headers{'student'}.= '<th>'.ucfirst($_).'</th>';
  235:     }
  236:     #
  237:     # we put the headers into the %headers hash
  238:     my $total_col = scalar(@student_columns);
  239:     my $nonempty_part_headers = 0;
  240:     #
  241:     my %problem_analysis;
  242:     foreach my $prob (@$problems) {
  243:         my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
  244:         $problem_analysis{$prob->src}=\%analysis;
  245:         #
  246:         my $prob_span = 0;
  247:         my $single_part = 0;
  248:         if (scalar(@{$prob->parts}) == 1) {
  249:             $single_part = 1;
  250:         }
  251:         foreach my $partid (@{$prob->parts}) {
  252:             my $part_span = 0;
  253:             my $responses = [$prob->responseIds($partid)];
  254:             my $resptypes = [$prob->responseType($partid)];
  255:             for (my $i=0;$i<scalar(@$responses);$i++) {
  256:                 my $respid = $responses->[$i];
  257:                 my @headers = &get_headers($prob,$partid,$respid,
  258:                                            $resptypes->[$i],
  259:                                            $problem_analysis{$prob->src},
  260:                                            'html','display',
  261:                                            @extra_resp_headers);
  262:                 if (scalar(@headers)>0) {
  263:                     $total_col += scalar(@headers);
  264:                     $part_span += scalar(@headers);
  265:                     $headers{'response'} .=
  266:                         '<th colspan="'.scalar(@headers).'">'.
  267:                         &mt('Response [_1]',$responses->[$i]).'</th>';
  268:                     $headers{'student'}.= '<th><span class="LC_nobreak">'.
  269:                                           join('</span></th><th><span class="LC_nobreak">',
  270:                                                       @headers).
  271:                                                           '</span></th>';
  272:                 }
  273:             }
  274:             if ($part_span == 0) {
  275:                 next;
  276:             }
  277:             if (! $single_part) {
  278:                 my $tmpname = $partid;
  279:                 if ($partid =~/^\d+$/) {
  280:                     $tmpname = $prob->part_display($partid);
  281:                 }
  282:                 if ($tmpname !~ /^part/) {
  283:                     $tmpname = 'Part '.$tmpname;
  284:                 }
  285:                 $headers{'part'} .= qq{<th colspan="$part_span">$tmpname</th>};
  286:                 $nonempty_part_headers = 1;
  287:             } else {
  288:                 $headers{'part'} .= qq{<th colspan="$part_span">&nbsp;</th>};
  289:             }
  290:             $prob_span += $part_span;
  291:         }
  292:         my $title = $prob->compTitle;
  293:         if ($prob_span > 0) {
  294:             $headers{'problem'}.= qq{<th colspan="$prob_span">$title</th>};
  295:         } elsif ($single_response) {
  296:             $prob_span = scalar(@student_columns);
  297:             $headers{'problem'} = qq{<th colspan="$prob_span">$title</th>};
  298:         }
  299:     }
  300:     if (exists($headers{'part'})) {
  301:         $headers{'part'} = qq{<th colspan="$student_column_count">\&nbsp;</th>}.
  302:             $headers{'part'};
  303:     }
  304:     if (exists($headers{'response'})) {
  305:         $headers{'response'}=
  306:             qq{<th colspan="$student_column_count">\&nbsp;</th>}.
  307:             $headers{'response'};
  308:     }
  309:     my $full_header = $/.'<table>'.$/;
  310:     $full_header .= '<tr align="left">'.$headers{'problem'}.'</tr>'.$/;
  311:     if ($nonempty_part_headers) {
  312:         $full_header .= '<tr align="left">'.$headers{'part'}.'</tr>'.$/;
  313:     }
  314:     $full_header .= '<tr align="left">'.$headers{'response'}.'</tr>'.$/;
  315:     $full_header .= '<tr align="left">'.$headers{'student'}.'</tr>'.$/;
  316:     #
  317:     # Main loop
  318:     my $count;
  319:     $r->print($/.$full_header.$/);
  320:     my $row_class = 'odd';   # css 
  321:     foreach my $student (@$students) {
  322:         my $student_row_data;
  323:         if ($count++ >= 30) {
  324:             $r->print('</table>'.$/.$full_header.$/);
  325:             $count = 0;
  326:         }
  327:         last if ($c->aborted());
  328:         foreach my $field (@student_columns) {
  329:             $student_row_data .= 
  330:                 '<td valign="top">'.$student->{$field}.'</td>';
  331:         }
  332:         #
  333:         # Figure out what it is we need to output for this student
  334:         my @essays;
  335:         my %prob_data;
  336:         my $maxrow;
  337:         foreach my $prob (@$problems) {
  338:             $prob_data{$prob->symb}={};
  339:             foreach my $partid (@{$prob->parts}) {
  340:                 my @responses = $prob->responseIds($partid);
  341:                 my @response_type = $prob->responseType($partid);
  342:                 for (my $i=0;$i<=$#responses;$i++) {
  343:                     my $respid  = $responses[$i];
  344:                     my $results = 
  345:                         &Apache::loncoursedata::get_response_data_by_student
  346:                         ($student,$prob->symb(),$respid);
  347:                     my $resptype = $response_type[$i];
  348:                     my @headers = &get_headers($prob,$partid,$respid,
  349:                                                $resptype,
  350:                                                $problem_analysis{$prob->src},
  351:                                                'html','normal',
  352:                                                @extra_resp_headers);
  353:                     my $width = scalar(@headers);
  354:                     next if ($width < 1);
  355:                     my $resp_data;
  356:                     $resp_data->{'fake'} = qq{<td colspan="$width">&nbsp;</td>};
  357:                     if (! defined($results)) {
  358:                         $results = [];
  359:                     }
  360:                     # 
  361:                     if (scalar(@$results) > $maxrow && $resptype ne 'essay') {
  362:                         $maxrow = scalar(@$results);
  363:                     }
  364:                     for (my $j=scalar(@$results)-1;$j>=0;$j--) {
  365:                         if ($env{'form.all_sub'} ne 'true') {
  366:                             next if ($j ne scalar(@$results)-1);
  367:                         }
  368:                         my $response = &hashify_response($results->[$j],
  369:                                                          $prob,
  370:                                                          $student,
  371:                                                          $partid,
  372:                                                          $respid);
  373:                         if ($resptype eq 'essay') {
  374:                             push(@essays,
  375:                                  &html_essay_results(\@headers,
  376:                                                      $prob,$partid,$respid,
  377:                                                      $response,
  378:                                                      $single_response).
  379:                                  '</td>');
  380: 			} elsif (lc($resptype) eq 'task') {
  381: 			    my $results = 
  382: 				&html_task_results(\@headers,
  383: 						   $prob,$partid,$respid,
  384: 						   $response,$resptype);
  385: 			    if ($results) {
  386: 				push(@{$resp_data->{'real'}},$results);
  387: 			    }
  388:                         } else {
  389:                             push(@{$resp_data->{'real'}},
  390:                                  &html_non_essay_results(\@headers,
  391:                                                          $prob,$partid,$respid,
  392:                                                          $response,$resptype));
  393:                         }
  394:                     }
  395:                     $prob_data{$prob->symb}->{$partid}->{$respid}=$resp_data;
  396:                 } # end of $i loop
  397:             } # end of partid loop
  398:         } # end of prob loop
  399:         #
  400:         # if there is no data, skip this student.
  401:         next if (! $maxrow && ! scalar(@essays));
  402:         #
  403:         # Go through the problem data and output a row.
  404:         if ($row_class eq 'even') {
  405:             $row_class = 'odd'; 
  406:         } else {
  407:             $row_class = 'even'; 
  408:         }
  409:         my $printed_something;
  410:         for (my $rows_output = 0;$rows_output<$maxrow;$rows_output++) {
  411:             my $html;
  412:             my $no_data = 1;
  413:             foreach my $prob (@$problems) {
  414:                 foreach my $partid (@{$prob->parts}) {
  415:                     my @responses     = $prob->responseIds($partid);
  416:                     my @response_type = $prob->responseType($partid);
  417:                     for (my $i=0;$i<=$#responses;$i++) {
  418:                         my $respid   = $responses[$i];
  419:                         my $resp_data = 
  420:                             $prob_data{$prob->symb}->{$partid}->{$respid};
  421:                         next if ($response_type[$i] eq 'essay');
  422:                         if (defined($resp_data->{'real'}->[$rows_output])) {
  423:                             $html .= $resp_data->{'real'}->[$rows_output];
  424:                             $no_data = 0;
  425:                         } else {
  426:                             $html .= $resp_data->{'fake'};
  427:                         }
  428:                     }
  429:                 }
  430:             }
  431:             if (! $no_data) {
  432:                 $r->print(qq{<tr class="$row_class">$student_row_data$html</tr>}.$/);
  433:                 $printed_something=1;
  434:             }
  435:         }
  436:         if (@essays) {
  437:             my $tr = qq{<tr class="$row_class">};
  438:             my $td = qq{<td  valign="top" class="essay" colspan="$total_col">};
  439:             if (! $printed_something) {
  440:                 $r->print($tr.$student_row_data.'</tr>'.$/);
  441:             }
  442:             $r->print($tr.$td.
  443:                       join('</td></tr>'.$/.$tr.$td,@essays).'</td></tr>'.$/);
  444:             undef(@essays);
  445:         }
  446:     } # end of student loop
  447:     return;
  448: }
  449: 
  450: sub hashify_response {
  451:     my ($response,$prob,$student,$partid,$respid) =@_;
  452:     my $resp_hash = {};
  453:     if ($env{'form.correctans'} eq 'true') {
  454:         $resp_hash->{'Correct'} = 
  455:             &Apache::lonstathelpers::get_student_answer
  456:             ($prob,$student->{'username'},$student->{'domain'},
  457:              $partid,$respid);
  458:     }
  459:     $resp_hash->{'Submission'} = 
  460:         $response->[&Apache::loncoursedata::RDs_submission()];
  461:     $resp_hash->{'Time'} = 
  462:         $response->[&Apache::loncoursedata::RDs_timestamp()];
  463:     $resp_hash->{'Attempt'} =
  464:         $response->[&Apache::loncoursedata::RDs_tries()];
  465:     $resp_hash->{'Awarded'} = 
  466:         $response->[&Apache::loncoursedata::RDs_awarded()];
  467:     if ($prob->is_task()) {
  468: 	$resp_hash->{'Grader'} = 
  469: 	    $response->[&Apache::loncoursedata::RDs_response_eval_2()];
  470: 	if ($resp_hash->{'Attempt'} eq '0') {
  471: 	    $resp_hash->{'Attempt'} = '';
  472: 	}
  473: 	$resp_hash->{'Award Detail'} = 
  474: 	    $response->[&Apache::loncoursedata::RDs_part_award()];
  475: 	$resp_hash->{'Status'} = 
  476: 	    $response->[&Apache::loncoursedata::RDs_response_eval()];
  477:     } else {
  478: 	$resp_hash->{'Award Detail'} = 
  479: 	    $response->[&Apache::loncoursedata::RDs_awarddetail()];
  480:     }
  481: 
  482:     return $resp_hash;
  483: }
  484: 
  485: #####################################################
  486: ##
  487: ##     HTML helper routines
  488: ##
  489: #####################################################
  490: sub html_essay_results {
  491:     my ($headers,$prob,$partid,$respid,$response,$single_response)=@_;
  492:     if (! ref($headers) || ref($headers) ne 'ARRAY') {
  493:         return '';
  494:     }
  495:     # Start of telling them what problem, part, and response
  496:     my $Str;
  497:     if (! $single_response) {
  498:         my $id = $prob->compTitle;
  499:         if (defined($partid) && $partid ne '0') {
  500:             $id .= ' '.$prob->part_display($partid);
  501:         }
  502:         if (defined($respid)) {
  503:             $id .= ' '.$respid;
  504:         }
  505:         $Str .= '<span class="LC_nobreak">'.$id.'</span>'.('&nbsp;'x4);
  506:     }
  507:     #
  508:     shift(@$headers); # Get rid of the Submission header
  509:     my $correct = '';
  510:     if ($headers->[0] eq 'Correct') {
  511:         $correct = &html_format_essay_sub($response->{'Correct'});
  512:         shift(@$headers);
  513:     }
  514:     $Str .= '<span class="LC_nobreak">'.
  515:         join('',
  516:              map {
  517:                  ('&nbsp;'x4).&mt($_.': [_1]',$response->{$_});
  518:              } @$headers).'</span>';
  519:     if (@$headers || ! $single_response) {
  520:         $Str .= '<br />';
  521:     }
  522:     $Str .= &html_format_essay_sub($response->{'Submission'});
  523:     #
  524:     if (defined($correct) && $correct !~ /^\s*$/) {
  525:         $Str .= '<hr /><b>'.&mt('Correct').'</b>'.$correct
  526:     }
  527:     return $Str;
  528: }
  529: 
  530: sub html_format_essay_sub {
  531:     my ($submission) = @_;
  532:     return '' if (! defined($submission) || $submission eq '');
  533:     $submission = &HTML::Entities::decode($submission);
  534:     $submission =~ s/\\\"/\"/g;
  535:     $submission =~ s/\\\'/\'/g;
  536:     $submission =~ s|\\r\\n|$/|g;
  537:     $submission = &HTML::Entities::encode($submission,'<>&"');
  538:     $submission =~ s|$/\s*$/|$/</p><p>$/|g;
  539:     $submission =~ s|\\||g;
  540:     $submission = '<p>'.$submission.'</p>';
  541:     return $submission;
  542: }
  543: 
  544: sub html_task_results {
  545:     my ($headers,$prob,$partid,$respid,$response,$resptype) = @_;
  546:     if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
  547:         return '';
  548:     }
  549: 
  550:     my @values;
  551:     @values = map { $response->{$_}; } @$headers;
  552: 
  553:     my $td = '<td valign="top">';
  554:     my $str = $td.join('</td>'.$td,@values).'</td>';
  555:     return $str;
  556: }
  557: 
  558: sub html_non_essay_results {
  559:     my ($headers,$prob,$partid,$respid,$response,$resptype) = @_;
  560:     if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
  561:         return '';
  562:     }
  563:     # 
  564:     my $submission = &HTML::Entities::decode(&unescape($response->{'Submission'})); 
  565:     return '' if (! defined($submission) || $submission eq '');
  566:     $submission =~ s/\\\"/\"/g;
  567:     $submission =~ s/\\\'/\'/g;
  568:     if ($resptype eq 'radiobutton') {
  569:         $submission = &HTML::Entities::encode($submission,'<>&"');
  570:         $submission =~ s/=([^=])$//;
  571:         $submission = '<span class="LC_nobreak">'.$submission.'</span>';
  572:     }
  573:     $response->{'Submission'} = $submission;
  574:     #
  575:     my @values;
  576:     if ($resptype =~ /^(option|match|rank)$/) {
  577:         my %submission = 
  578:             map { 
  579:                 my ($foil,$value) = split('=',&unescape($_));
  580:                 ($foil,$value);
  581:             } split('&',$response->{'Submission'});
  582:         my %correct;
  583:         if (exists($response->{'Correct'})) {
  584:             %correct = 
  585:                 map { 
  586:                     my ($foil,$value)=split('=',&unescape($_));
  587:                     ($foil,$value);
  588:                 } split('&',$response->{'Correct'});
  589:         }
  590:         #
  591:         foreach my $original_header (@$headers) {
  592:             if ($original_header =~ /^_/) {
  593:                 # '_' denotes a foil column
  594:                 my ($header) = ($original_header =~ m/^_(.*)$/);
  595:                 my $option = '';
  596:                 if ( my ($foil) = ($header =~ /(.*) Correct$/)) {
  597:                     if (exists($correct{$foil})) {
  598:                         $option = $correct{$foil};
  599:                     }
  600:                 } elsif (exists($submission{$header})) {
  601:                     $option = $submission{$header};
  602:                 }
  603:                 push(@values,&HTML::Entities::encode($option));
  604:             } elsif ($original_header eq 'Time') {
  605:                 push(@values,&Apache::lonlocal::locallocaltime($response->{$original_header}));
  606:             } else {
  607:                 # A normal column
  608:                 push(@values,$response->{$original_header});
  609:             }
  610:         }
  611:     } else {
  612:         @values = map { $response->{$_}; } @$headers;
  613:     }
  614:     my $td = '<td valign="top">';
  615:     my $str = $td.join('</td>'.$td,@values).'</td>';
  616:     return $str;
  617: }
  618: 
  619: 
  620: #########################################################
  621: #########################################################
  622: ##
  623: ##    Excel Output Routines
  624: ##
  625: #########################################################
  626: #########################################################
  627: sub prepare_excel_output {
  628:     my ($r,$Problems,$Students) = @_;
  629:     my $c = $r->connection();
  630:     #
  631:     #
  632:     # Determine the number of columns in the spreadsheet
  633:     my $columncount = 3; # username, domain, id
  634:     my @extra_resp_headers = &get_extra_response_headers();
  635:     my $lastprob;
  636:     my %problem_analysis;
  637:     foreach my $prob (@$Problems) {
  638:         my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
  639:         $problem_analysis{$prob->src}=\%analysis;
  640:         foreach my $partid (@{$prob->parts}) {
  641:             my $responses = [$prob->responseIds($partid)];
  642:             my $resptypes = [$prob->responseType($partid)];
  643:             for (my $i=0;$i<scalar(@$responses);$i++) {
  644:                 my @headers = &get_headers($prob,$partid,$responses->[$i],
  645:                                            $resptypes->[$i],
  646:                                            $problem_analysis{$prob->src},
  647:                                            'excel','display',
  648:                                            @extra_resp_headers);
  649:                 $columncount += scalar(@headers);
  650:             }
  651:         }
  652:         last if ($columncount > 255);
  653:         $lastprob = $prob;
  654:     }
  655:     if ($columncount > 255) {
  656:         $r->print('<h1>'.&mt('Unable to complete request').'</h1>'.$/.
  657:                   '<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>'.$/.
  658:                   '<p>'.&mt('Consider selecting fewer problems to generate reports on, or reducing the number of items per problem.  Or use HTML or CSV output.').'</p>'.$/.
  659:                   '<p>'.&mt('The last problem that will fit in the current spreadsheet is [_1].',$lastprob->compTitle).'</p>');
  660:         $r->rflush();
  661:         return;
  662:     }
  663:     #
  664:     # Print out a message telling them what we are doing
  665:     if (scalar(@$Problems) > 1) {
  666:         $r->print('<h2>'.
  667:                   &mt('Preparing Excel spreadsheet of student responses to [_1] problems',
  668:                       scalar(@$Problems)).
  669:                   '</h2>');
  670:     } else {
  671:         $r->print('<h2>'.
  672:                   &mt('Preparing Excel spreadsheet of student responses').
  673:                   '</h2>');
  674:     }
  675:     $r->rflush();
  676:     #
  677:     # Create the excel spreadsheet
  678:     my ($workbook,$filename,$format) = 
  679:         &Apache::loncommon::create_workbook($r);
  680:     return if (! defined($workbook));
  681:     my $worksheet  = $workbook->addworksheet('Student Submission Data');
  682:     #
  683:     # Add headers to the worksheet
  684:     my $rows_output = 0;
  685:     $worksheet->write($rows_output++,0,
  686:                     $env{'course.'.$env{'request.course.id'}.'.description'},
  687:                       $format->{'h1'});
  688:     $rows_output++;
  689:     my $cols_output = 0;
  690:     my $title_row  = $rows_output++;
  691:     my $partid_row = $rows_output++;
  692:     my $respid_row = $rows_output++;
  693:     my $header_row = $rows_output++;
  694:     $worksheet->write($title_row ,0,'Problem Title',$format->{'bold'});
  695:     $worksheet->write($partid_row,0,'Part ID',$format->{'bold'});
  696:     $worksheet->write($respid_row,0,'Response ID',$format->{'bold'});
  697:     # Student headers
  698:     my @StudentColumns = ('username','domain','id','section');
  699:     foreach (@StudentColumns) {
  700:         $worksheet->write($header_row,$cols_output++,ucfirst($_),
  701:                           $format->{'bold'});
  702:     }
  703:     # Problem headers
  704:     my %start_col;
  705:     foreach my $prob (@$Problems) {
  706:         my $title = $prob->compTitle;
  707:         $worksheet->write($title_row,$cols_output,
  708:                           $title,$format->{'h3'});
  709:         foreach my $partid (@{$prob->parts}) {
  710:             $worksheet->write($partid_row,$cols_output,
  711:                               $prob->part_display($partid));
  712:             my $responses = [$prob->responseIds($partid)];
  713:             my $resptypes = [$prob->responseType($partid)];
  714:             for (my $i=0;$i<scalar(@$responses);$i++) {
  715:                 $start_col{$prob->symb}->{$partid}->{$responses->[$i]}=
  716:                     $cols_output;
  717:                 $worksheet->write($respid_row,$cols_output,
  718:                                   $resptypes->[$i].', '.$responses->[$i]);
  719:                 my @headers = &get_headers($prob,$partid,$responses->[$i],
  720:                                            $resptypes->[$i],
  721:                                            $problem_analysis{$prob->src},
  722:                                            'excel','display',
  723:                                            @extra_resp_headers);
  724:                 foreach my $text (@headers) {
  725:                     if ($text eq 'Time') {
  726:                         $worksheet->set_column($cols_output,$cols_output,undef,
  727:                                                $format->{'date'});
  728:                     } 
  729:                     $worksheet->write($header_row,$cols_output++,$text);
  730:                 }
  731:             }
  732:         }
  733:     }
  734:     #
  735:     # Populate the worksheet with the student data
  736:     my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
  737:         ($r,'Excel File Compilation Status',
  738:          'Excel File Compilation Progress', 
  739:          scalar(@$Students),'inline',undef,'Statistics','stats_status');
  740:     my $max_row = $rows_output;
  741:     foreach my $student (@$Students) {
  742:         last if ($c->aborted());
  743:         $cols_output = 0;
  744:         my $student_row = $max_row;
  745:         foreach my $field (@StudentColumns) {
  746:             $worksheet->write($student_row,$cols_output++,
  747:                               $student->{$field});
  748:         }
  749:         my $last_student_col = $cols_output-1;
  750:         foreach my $prob (@$Problems) {
  751:             foreach my $partid (@{$prob->parts}) {
  752:                 my @Response = $prob->responseIds($partid);
  753:                 my @ResponseType = $prob->responseType($partid);
  754:                 for (my $i=0;$i<=$#Response;$i++) {
  755:                     my $respid   = $Response[$i];
  756:                     my $resptype = $ResponseType[$i];
  757:                     my $results = 
  758:                         &Apache::loncoursedata::get_response_data_by_student
  759:                         ($student,$prob->symb(),$respid);
  760:                     my @headers = &get_headers($prob,$partid,$respid,
  761:                                                $resptype,
  762:                                                $problem_analysis{$prob->src},
  763:                                                'excel','normal',
  764:                                                @extra_resp_headers);
  765: 
  766:                     if (! defined($results)) {
  767:                         $results = [];
  768:                     }
  769:                     #
  770:                     $rows_output = $student_row;
  771:                     #
  772:                     my $response_start_col = $start_col{$prob->symb}->{$partid}->{$respid};
  773:                     for (my $j=scalar(@$results)-1;$j>=0;$j--) {
  774:                         $cols_output = $response_start_col;
  775:                         if ($env{'form.all_sub'} ne 'true') {
  776:                             next if ($j ne scalar(@$results)-1);
  777:                         }
  778:                         my $response = &hashify_response($results->[$j],
  779:                                                          $prob,
  780:                                                          $student,
  781:                                                          $partid,
  782:                                                          $respid);
  783:                         my @response_data = 
  784:                             &compile_response_data(\@headers,$response,
  785:                                                    $prob,$partid,$respid,
  786:                                                    $resptype,
  787:                                                    \&excel_format_item);
  788:                         $worksheet->write_row($rows_output++,$cols_output,
  789:                                               \@response_data);
  790:                         $cols_output+=scalar(@response_data);
  791:                         if ($rows_output > $max_row) {
  792:                             $max_row = $rows_output;
  793:                         }
  794:                     }
  795:                 }
  796:             }
  797:         }
  798:         # Fill in the remaining rows with the students data
  799:         for (my $row = $student_row+1;$row<$max_row;$row++) {
  800:             my $cols = 0;
  801:             foreach my $field (@StudentColumns) {
  802:                 $worksheet->write($row,$cols++,
  803:                                   $student->{$field});
  804:             }
  805:         }
  806:         &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
  807:                                                  'last student');
  808:     }
  809:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
  810:     #
  811:     # Close the excel file
  812:     $workbook->close();
  813:     #
  814:     # Write a link to allow them to download it
  815:     $r->print('<p><a href="'.$filename.'">'.
  816:               &mt('Your Excel spreadsheet.').
  817:               '</a></p>'."\n");
  818:     $r->print('<script>'.
  819:               'window.document.Statistics.stats_status.value="'.
  820:               'Done compiling spreadsheet.  See link below to download.'.
  821:               '";</script>');
  822:     $r->rflush();
  823:     return;
  824: }
  825: 
  826: sub compile_response_data {
  827:     my ($headers,$response,$prob,$partid,$respid,$resptype,$format) = @_;
  828:     if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
  829:         return ();
  830:     }
  831:     if (ref($format) ne 'CODE') {
  832:         $format = sub { return $_[0]; };
  833:     }
  834:     #
  835:     my $submission = 
  836:         &HTML::Entities::decode
  837:         (&unescape($response->{'Submission'}));
  838:     if (!$prob->is_task()) {
  839: 	return () if (! defined($submission) || $submission eq '');
  840:     }
  841:     $submission =~ s/\\\"/\"/g;
  842:     $submission =~ s/\\\'/\'/g;
  843:     if ($resptype eq 'radiobutton') {
  844:         $submission =~ s/=([^=])$//;
  845:     }
  846:     $response->{'Submission'} = $submission;
  847:     #
  848:     my @values;
  849:     if ($resptype =~ /^(option|match|rank)$/) {
  850:         my %submission = 
  851:             map { 
  852:                 my ($foil,$value) = split('=',&unescape($_));
  853:                 ($foil,$value);
  854:             } split('&',$response->{'Submission'});
  855:         my %correct;
  856:         if (exists($response->{'Correct'})) {
  857:             %correct = 
  858:                 map { 
  859:                     my ($foil,$value)=split('=',&unescape($_));
  860:                     ($foil,$value);
  861:                 } split('&',$response->{'Correct'});
  862:         }
  863:         #
  864:         foreach my $original_header (@$headers) {
  865:             if ($original_header =~ /^_/) {
  866:                 # '_' denotes a foil column
  867:                 my ($header) = ($original_header =~ m/^_(.*)$/);
  868:                 my $option = '';
  869:                 if ( my ($foil) = ($header =~ /(.*) Correct$/)) {
  870:                     if (exists($correct{$foil})) {
  871:                         $option = $correct{$foil};
  872:                     }
  873:                 } elsif (exists($submission{$header})) {
  874:                     $option = $submission{$header};
  875:                 }
  876:                 push(@values,&{$format}($option,$header));
  877:             } else {
  878:                 # A normal column
  879:                 push(@values,&{$format}($response->{$original_header},
  880:                                         $original_header));
  881:             }
  882:         }
  883:     } else {
  884:         @values = map { &{$format}($response->{$_},$_); } @$headers;
  885:     }
  886:     return @values;
  887: }
  888: 
  889: sub excel_format_item {
  890:     my ($item,$type) = @_;
  891:     if ($type eq 'Time') {
  892:         $item = &Apache::lonstathelpers::calc_serial($item);
  893:     } else {
  894:         if ($item =~ m/^=/) {
  895:             $item = ' '.$item;
  896:         }
  897:         $item =~ s/\\r//g;
  898:         $item =~ s/\\n/\n/g;
  899:         $item =~ s/(\s*$|^\s*)//g;
  900:         $item =~ s/\\\'/\'/g;
  901:     }
  902:     return $item;
  903: }
  904: 
  905: #########################################################
  906: #########################################################
  907: ##
  908: ##      CSV output of student answers
  909: ##
  910: #########################################################
  911: #########################################################
  912: sub prepare_csv_output {
  913:     my ($r,$problems,$students) = @_;
  914:     my $c = $r->connection();
  915:     #
  916:     $r->print('<h2>'.
  917:               &mt('Generating CSV report of student responses').'</h2>');
  918:     #
  919:     # Progress window
  920:     my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
  921:         ($r,'CSV File Compilation Status',
  922:          'CSV File Compilation Progress', 
  923:          scalar(@$students),'inline',undef,'Statistics','stats_status');
  924:     
  925:     $r->rflush();
  926:     #
  927:     # Open a file
  928:     my $outputfile;
  929:     my $filename = '/prtspool/'.
  930:         $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
  931:             time.'_'.rand(1000000000).'.csv';
  932:     unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {
  933:         $r->log_error("Couldn't open $filename for output $!");
  934:         $r->print(
  935:             '<p class="LC_error">'
  936:            .&mt('Problems occurred in writing the CSV file.')
  937:            .' '.&mt('This error has been logged.')
  938:            .' '.&mt('Please alert your LON-CAPA administrator.')
  939:            .'</p>'
  940:         );
  941:         $outputfile = undef;
  942:     }
  943:     #
  944:     # Compute the number of columns per response
  945:     my @extra_resp_headers = &get_extra_response_headers();
  946:     #
  947:     # Create the table header
  948:     my @student_columns = ('username','domain','id','section');
  949:     #
  950:     my %headers;
  951:     push(@{$headers{'student'}},@student_columns);
  952:     # Pad for the student data
  953:     foreach my $row ('problem','part','response') {
  954:         $headers{$row}=[map {''} @student_columns];
  955:     }
  956:     #
  957:     # we put the headers into the %headers hash
  958:     my %problem_analysis;
  959:     my %start_col;
  960:     my $max_column = scalar(@student_columns);
  961:     foreach my $prob (@$problems) {
  962:         my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
  963:         $problem_analysis{$prob->src}=\%analysis;
  964:         $headers{'problem'}->[$max_column] = $prob->compTitle;
  965:         foreach my $partid (@{$prob->parts}) {
  966:             $headers{'part'}->[$max_column] = $prob->part_display($partid);
  967:             my $responses = [$prob->responseIds($partid)];
  968:             my $resptypes = [$prob->responseType($partid)];
  969:             for (my $i=0;$i<scalar(@$responses);$i++) {
  970:                 my @headers = &get_headers($prob,$partid,$responses->[$i],
  971:                                            $resptypes->[$i],
  972:                                            $problem_analysis{$prob->src},
  973:                                            'csv','display',
  974:                                            @extra_resp_headers);
  975:                 $start_col{$prob->symb}->{$partid}->{$responses->[$i]}=
  976:                     $max_column;
  977:                 $headers{'response'}->[$max_column]=
  978:                     &mt('Response [_1]',$responses->[$i]);
  979:                 for (my $j=0;$j<=$#headers;$j++) {
  980:                     $headers{'student'}->[$max_column+$j]=$headers[$j];
  981:                 }
  982:                 $max_column += scalar(@headers);
  983:             }
  984:         }
  985:     }
  986:     foreach my $row ('problem','part','response','student') {
  987:         print $outputfile '"'.
  988:             join('","',
  989:                  map { 
  990:                      &Apache::loncommon::csv_translate($_); 
  991:                  } @{$headers{$row}}).'"'.$/;
  992:     }
  993:     #
  994:     # Main loop
  995:     foreach my $student (@$students) {
  996:         last if ($c->aborted());
  997:         my @rows;
  998:         foreach my $prob (@$problems) {
  999:             foreach my $partid (@{$prob->parts}) {
 1000:                 my @responses = $prob->responseIds($partid);
 1001:                 my @response_type = $prob->responseType($partid);
 1002:                 for (my $i=0;$i<=$#responses;$i++) {
 1003:                     my $respid   = $responses[$i];
 1004:                     my $resptype = $response_type[$i];
 1005:                     my @headers = &get_headers($prob,$partid,$respid,$resptype,
 1006:                                                $problem_analysis{$prob->src},
 1007:                                                'csv','normal',
 1008:                                                @extra_resp_headers);
 1009:                     my $results = 
 1010:                         &Apache::loncoursedata::get_response_data_by_student
 1011:                         ($student,$prob->symb(),$respid);
 1012:                     if (! defined($results)) {
 1013:                         $results = [];
 1014:                     }
 1015:                     for (my $j=0; $j<scalar(@$results);$j++) {
 1016:                         if ($env{'form.all_sub'} ne 'true') {
 1017:                             next if ($j != 0);
 1018:                         }
 1019:                         my $idx = scalar(@$results) - $j - 1;
 1020:                         my $response = &hashify_response($results->[$idx],
 1021:                                                          $prob,$student,
 1022:                                                          $partid,$respid);
 1023:                         my @data = &compile_response_data(\@headers,$response,
 1024:                                                           $prob,$partid,
 1025:                                                           $respid,$resptype,
 1026:                                                           \&csv_format_item);
 1027:                         my $resp_start_idx =
 1028:                             $start_col{$prob->symb}->{$partid}->{$respid};
 1029:                         for (my $k=0;$k<=$#data;$k++) {
 1030:                             $rows[$j]->[$resp_start_idx + $k] = $data[$k];
 1031:                         }
 1032:                     }
 1033:                 }
 1034:             }
 1035:         }
 1036:         foreach my $row (@rows) {
 1037:             print $outputfile '"'.join('","',
 1038:                                        map { $student->{$_}; }
 1039:                                        @student_columns).'"';
 1040:             for (my $i=scalar(@student_columns);$i<$max_column;$i++) {
 1041:                 my $value = &Apache::loncommon::csv_translate($row->[$i]);
 1042:                 $value ||='';
 1043:                 print $outputfile ',"'.$value.'"';
 1044:             }
 1045:             print $outputfile $/;
 1046:         }
 1047:         undef(@rows);
 1048:         &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
 1049:                                                  'last student');
 1050:     }
 1051:     close($outputfile);
 1052:     #
 1053:     # Close the progress window
 1054:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
 1055:     #
 1056:     # Tell the user where to get their CSV file
 1057:     $r->print('<br />'.
 1058:               '<a href="'.$filename.'">'.&mt('Your CSV file.').'</a>'."\n");
 1059:     $r->rflush();
 1060:     return;
 1061: }
 1062: 
 1063: sub csv_format_item {
 1064:     my ($item,$type) = @_;
 1065:     if ($type eq 'Time') {
 1066:         $item = localtime($item);
 1067:     }
 1068:     $item =&Apache::loncommon::csv_translate($item); 
 1069:     return $item;
 1070: }
 1071: 
 1072: #########################################################
 1073: #########################################################
 1074: ##
 1075: ##   Generic Interface Routines
 1076: ##
 1077: #########################################################
 1078: #########################################################
 1079: sub CreateInterface {
 1080:     ##
 1081:     ## Output Selection
 1082:     my $output_selector = $/.'<select name="output">'.$/;
 1083:     foreach ('HTML','Excel','CSV') {
 1084:         $output_selector .= '    <option value="'.lc($_).'"';
 1085:         if ($env{'form.output'} eq lc($_)) {
 1086:             $output_selector .= ' selected ';
 1087:         }
 1088:         $output_selector .='>'.&mt($_).'</option>'.$/;
 1089:     } 
 1090:     $output_selector .= '</select>'.$/;
 1091:     ##
 1092:     ## Environment variable initialization
 1093:     my $Str = '';
 1094:     $Str .= &Apache::lonhtmlcommon::breadcrumbs('Student Submission Reports');
 1095:     $Str .= '<p>';
 1096:     $Str .= &Apache::loncommon::start_data_table();
 1097:     $Str .= &Apache::loncommon::start_data_table_header_row();
 1098:     $Str .= '<th>'.&mt('Sections').'</th>';
 1099:     $Str .= '<th>'.&mt('Groups').'</th>';
 1100:     $Str .= '<th>'.&mt('Access Status').'</th>';
 1101:     $Str .= '<th>'.&mt('Options').'</th>';
 1102:     $Str .= '<th>'.&mt('Output Format').'</th>';
 1103:     $Str .= &Apache::loncommon::end_data_table_header_row();
 1104:     #
 1105:     $Str .= &Apache::loncommon::start_data_table_row();
 1106:     $Str .= '<td align="center">'."\n";
 1107:     $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
 1108:     $Str .= '</td>';
 1109:     #
 1110:     $Str .= '<td align="center">'."\n";
 1111:     $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
 1112:     $Str .= '</td>';
 1113:     #
 1114:     $Str .= '<td align="center">';
 1115:     $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
 1116:     $Str .= '</td>';
 1117:     #
 1118:     # Render problem checkbox
 1119:     my $prob_checkbox = '<input type="checkbox" name="renderprob" ';
 1120:     if (exists($env{'form.renderprob'}) && $env{'form.renderprob'} eq 'true') {
 1121:         $prob_checkbox .= 'checked="checked" ';
 1122:     }
 1123:     $prob_checkbox .= 'value="true" />';
 1124:     #
 1125:     # Compute correct answers checkbox
 1126:     my $ans_checkbox = '<input type="checkbox" name="correctans" ';
 1127:     if (exists($env{'form.correctans'}) && $env{'form.correctans'} eq 'true') {
 1128:         $ans_checkbox .= 'checked="checked" ';
 1129:     }
 1130:     $ans_checkbox .= 'value="true" />';
 1131:     #
 1132:     # Show all submissions checkbox
 1133:     my $all_sub_checkbox = '<input type="checkbox" name="all_sub" ';
 1134:     if (exists($env{'form.all_sub'}) && 
 1135:         $env{'form.all_sub'} eq 'true') {
 1136:         $all_sub_checkbox .= 'checked="checked" ';
 1137:     }
 1138:     $all_sub_checkbox.= 'value="true" />';
 1139:     #
 1140:     # problem status checkbox
 1141:     my $prob_status_checkbox = '<input type="checkbox" name="prob_status" ';
 1142:     if (exists($env{'form.prob_status'}) && 
 1143:         $env{'form.prob_status'} eq 'true') {
 1144:         $prob_status_checkbox .= 'checked="checked" ';
 1145:     }
 1146:     $prob_status_checkbox .= 'value="true" />';
 1147:     #
 1148:     $Str .=
 1149:         '<td valign="top">'
 1150:        .'<label>'
 1151:        .$prob_checkbox.&mt('Show problem')
 1152:        .'</label><br />'
 1153:        .'<label>'
 1154:        .' '.$ans_checkbox.&mt('Show correct answers')
 1155:        .'</label><br />'
 1156:        .'<label>'
 1157:        .$all_sub_checkbox.&mt('Show all submissions')
 1158:        .'</label><br />'
 1159:        .'<label>'
 1160:        .$prob_status_checkbox.&mt('Show problem grading')
 1161:        .'</label>'
 1162:        .'</td>';
 1163:     #
 1164:     $Str .= '<td align="center" valign="top">'.$output_selector.'</td>';
 1165:     #
 1166:     $Str .= &Apache::loncommon::end_data_table_row();
 1167:     $Str .= &Apache::loncommon::end_data_table();
 1168:     #
 1169:     $Str .= '<p><span class="LC_nobreak">'
 1170:            .&mt('Status: [_1]',
 1171:                     '<input type="text" name="stats_status"'
 1172:                    .' size="60" value="" readonly="readonly" />')
 1173:            .'</span></p>';
 1174:     $Str .= '</p>';
 1175:     ##
 1176:     return $Str;
 1177: }
 1178: 
 1179: 1;
 1180: 
 1181: __END__

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