File:  [LON-CAPA] / loncom / interface / statistics / lonstudentassessment.pm
Revision 1.17: download - view: text, annotated - select for diffs
Thu Oct 24 20:58:06 2002 UTC (21 years, 8 months ago) by minaeibi
Branches: MAIN
CVS tags: HEAD
started to fix a bug

    1: # The LearningOnline Network with CAPA
    2: # (Publication Handler
    3: #
    4: # $Id: lonstudentassessment.pm,v 1.17 2002/10/24 20:58:06 minaeibi Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: # LON-CAPA is free software; you can redistribute it and/or modify
   10: # it under the terms of the GNU General Public License as published by
   11: # the Free Software Foundation; either version 2 of the License, or
   12: # (at your option) any later version.
   13: #
   14: # LON-CAPA is distributed in the hope that it will be useful,
   15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17: # GNU General Public License for more details.
   18: #
   19: # You should have received a copy of the GNU General Public License
   20: # along with LON-CAPA; if not, write to the Free Software
   21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22: #
   23: # /home/httpd/html/adm/gpl.txt
   24: #
   25: # http://www.lon-capa.org/
   26: #
   27: # (Navigate problems for statistical reports
   28: # YEAR=2001
   29: # 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
   30: # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
   31: # YEAR=2002
   32: # 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
   33: # 5/12,5/14,5/15,5/19,5/26,7/16  Behrouz Minaei
   34: #
   35: ###
   36: 
   37: package Apache::lonstudentassessment; 
   38: 
   39: use strict;
   40: use Apache::lonhtmlcommon;
   41: use Apache::loncoursedata;
   42: use GDBM_File;
   43: 
   44: #my $jr;
   45: 
   46: sub BuildStudentAssessmentPage {
   47:     my ($cacheDB,$students,$courseID,$formName,$headings,$spacing,
   48:         $studentInformation,$r,$c)=@_;
   49: #    $jr = $r;
   50:     my %cache;
   51:     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
   52:         $r->print('<html><body>Unable to tie database.</body></html>');
   53:         return;
   54:     }
   55: 
   56:     # Remove students who don't have the proper section.
   57:     my @sectionsSelected = split(':',$cache{'sectionsSelected'});
   58:     for(my $studentIndex=((scalar @$students)-1); $studentIndex>=0;
   59:         $studentIndex--) {
   60:         my $value = $cache{$students->[$studentIndex].':section'};
   61:         my $found = 0;
   62:         foreach (@sectionsSelected) {
   63:             if($_ eq 'none') {
   64:                 if($value eq '' || !defined($value) || $value eq ' ') {
   65:                     $found = 1;
   66:                     last;
   67:                 }
   68:             } else {
   69:                 if($value eq $_) {
   70:                     $found = 1;
   71:                     last;
   72:                 }
   73:             }
   74:         }
   75:         if($found == 0) {
   76:             splice(@$students, $studentIndex, 1);
   77:         }
   78:     }
   79:     my ($infoHeadings, $infoKeys, $sequenceHeadings, $sequenceKeys,
   80:         $doNotShow) = 
   81:         &ShouldShowColumns(\%cache, $headings, $studentInformation);
   82: 
   83:     my $selectedName = &FindSelectedStudent(\%cache, 
   84:                                             $cache{'StudentAssessmentStudent'},
   85:                                             $students);
   86:     $r->print(&CreateInterface(\%cache, $selectedName, $students, $formName,
   87:                                $doNotShow));
   88:     $r->rflush();
   89: 
   90:     my $Str = '';
   91:     if($selectedName eq 'No Student Selected') {
   92: 	$Str .= '<h3><font color=blue>WARNING: ';
   93:         $Str .= 'Please select a student</font></h3>';
   94:         $r->print($Str);
   95:         return;
   96:     }
   97: 
   98:     $r->print(&CreateTableHeadings(\%cache, $spacing, $infoKeys, $infoHeadings,
   99:                                    $sequenceKeys, $sequenceHeadings));
  100:     untie(%cache);
  101:     if($c->aborted()) {  return $Str; }
  102: 
  103:     my $selected=0;
  104:     $r->print('<pre>'."\n");
  105:     foreach (@$students) {
  106:         if($c->aborted()) { return $Str; }
  107:         next if ($_ ne $selectedName &&
  108:                  $selectedName ne 'All Students');
  109:         $selected = 1;
  110: 
  111:         my @who = ($_);
  112:         next if(&Apache::loncoursedata::DownloadStudentCourseData(\@who, 'true',
  113:                                                              $cacheDB, 'true',
  114:                                                              'false', $courseID,
  115:                                                              $r, $c) ne 'OK');
  116:         next if($c->aborted());
  117: 
  118:         if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
  119:             my @before=();
  120:             my @after=();
  121:             my @updateColumn=();
  122:             my $foundUpdate = 0;
  123:             foreach(@$infoKeys) {
  124:                 if(/updateTime/) {
  125:                     $foundUpdate=1;
  126:                     push(@updateColumn, $_);
  127:                     next;
  128:                 }
  129:                 if($foundUpdate) {
  130:                     push(@after, $_);
  131:                 } else {
  132:                     push(@before, $_);
  133:                 }
  134:             }
  135:             my $displayString = 'DISPLAYDATA'.$spacing;
  136:             $r->print(&Apache::lonhtmlcommon::FormatStudentInformation(
  137:                                                          \%cache, $_,
  138:                                                          \@before,
  139:                                                          $displayString,
  140:                                                          'preformatted'));
  141: 
  142:             if($foundUpdate) {
  143:                 $displayString = '';
  144:                 $displayString .= '<a href="/adm/statistics?reportSelected=';
  145:                 $displayString .= &Apache::lonnet::escape('Student Assessment');
  146:                 $displayString .= '&download='.$_.'">';
  147:                 $displayString .= 'DISPLAYDATA</a>'.$spacing;
  148:                 $r->print(&Apache::lonhtmlcommon::FormatStudentInformation(
  149:                                                                    \%cache, $_,
  150:                                                                    \@updateColumn,
  151:                                                                    $displayString,
  152:                                                                    'preformatted'));
  153:             }
  154: 
  155:             $displayString = 'DISPLAYDATA'.$spacing;
  156:             $r->print(&Apache::lonhtmlcommon::FormatStudentInformation(
  157:                                                          \%cache, $_,
  158:                                                          \@after,
  159:                                                          $displayString,
  160:                                                          'preformatted'));
  161:             $r->print(&StudentReport(\%cache, $_, $spacing, $sequenceKeys));
  162:             $r->print("\n");
  163:             $r->rflush();
  164:             untie(%cache);
  165:         }
  166:     }
  167: 
  168: 
  169: #    $r->print("AverageTtal");
  170:     $r->print(&StudentAverageTotal(\%cache, $spacing, $sequenceKeys));
  171:     $r->print("\n");
  172:     $r->rflush();
  173:     untie(%cache);
  174: 
  175: 
  176:     $r->print('</pre>'."\n");
  177:     if($selected == 0) {
  178: 	$Str .= '<h3><font color=blue>WARNING: ';
  179:         $Str .= 'Please select a student</font></h3>';
  180:         $r->print($Str);
  181:     }
  182: 
  183:     return;
  184: }
  185: 
  186: #---- Student Assessment Web Page --------------------------------------------
  187: 
  188: sub CreateInterface {
  189:     my($cache,$selectedName,$students,$formName,$doNotShow)=@_;
  190: 
  191:     my $Str = '';
  192:     $Str .= &CreateLegend();
  193:     $Str .= '<table><tr><td>'."\n";
  194:     $Str .= '<input type="submit" name="PreviousStudent" ';
  195:     $Str .= 'value="Previous Student" />'."\n";
  196:     $Str .= '&nbsp&nbsp&nbsp'."\n";
  197:     $Str .= &Apache::lonhtmlcommon::StudentOptions($cache, $students,
  198:                                                    $selectedName, 
  199:                                                    'StudentAssessment', 
  200:                                                    $formName);
  201:     $Str .= "\n".'&nbsp&nbsp&nbsp'."\n";
  202:     $Str .= '<input type="submit" name="NextStudent" ';
  203:     $Str .= 'value="Next Student" />'."\n";
  204:     $Str .= '</td></tr></table>'."\n";
  205:     $Str .= '<table cellspacing="5"><tr>'."\n";
  206:     $Str .= '<td align="center"><b>Select Sections</b>'."\n";
  207:     $Str .= '</td>'."\n";
  208:     $Str .= '<td align="center"><b>Select column to view:</b></td>'."\n";
  209:     $Str .= '<td></td></tr>'."\n";
  210: 
  211:     $Str .= '<tr><td align="center">'."\n";
  212:     my @sections = split(':',$cache->{'sectionList'});
  213:     my @selectedSections = split(':',$cache->{'sectionsSelected'});
  214:     $Str .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
  215:                                                           \@selectedSections,
  216:                                                           'Statistics');
  217:     $Str .= '</td><td align="center">';
  218:     $Str .= &CreateColumnSelectionBox($doNotShow);
  219:     $Str .= '</td><td>'."\n";
  220:     $Str .= '<input type="submit" name="DefaultColumns" ';
  221:     $Str .= 'value="Default Column Display" />'."\n";
  222:     $Str .= '</td></tr></table>'."\n";
  223: 
  224:     return $Str;
  225: }
  226: 
  227: sub CreateTableHeadings {
  228:     my($cache,$spacing,$infoKeys,$infoHeadings,$sequenceKeys,
  229:        $sequenceHeadings)=@_;
  230: 
  231:     my $Str = '';
  232:     $Str .= '<table border="0" cellpadding="0" cellspacing="0">'."\n";
  233: 
  234:     $Str .= '<tr>'."\n";
  235:     $Str .= &CreateColumnSelectors($infoHeadings, $sequenceHeadings,
  236:                                    $sequenceKeys);
  237:     $Str .= '<td></td></tr>'."\n";
  238: 
  239:     $Str .= '<tr>'."\n";
  240:     my $displayString = '<td align="left"><pre><a href="/adm/statistics?';
  241:     $displayString .= 'sort=LINKDATA">DISPLAYDATA</a>FORMATTING';
  242:     $displayString .= $spacing.'</pre></td>'."\n";
  243:     $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
  244:                                                    $infoKeys,
  245:                                                    $infoHeadings,
  246:                                                    $displayString,
  247:                                                    'preformatted');
  248: 
  249:     $displayString  = '<td align="left"><pre>DISPLAYDATAFORMATTING'.$spacing;
  250:     $displayString .= '</pre></td>'."\n";
  251:     $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
  252:                                                    $sequenceKeys,
  253:                                                    $sequenceHeadings,
  254:                                                    $displayString,
  255:                                                    'preformatted');
  256: 
  257:     $Str .= '<td><pre>Total Solved/Total Problems</pre></td>';
  258:     $Str .= '</tr></table>'."\n";
  259: 
  260:     return $Str;
  261: }
  262: 
  263: =pod
  264: 
  265: =item &FormatStudentData()
  266: 
  267: First, FormatStudentInformation is called and prefixes the course information.
  268: This function produces a formatted string of the student's course information.
  269: Each column of data represents all the problems for a given sequence.  For
  270: valid grade data, a link is created for that problem to a submission record
  271: for that problem.
  272: 
  273: =over 4
  274: 
  275: Input: $name, $studentInformation, $ChartDB
  276: 
  277: $name: The name and domain of the current student in name:domain format
  278: 
  279: $studentInformation: A pointer to an array holding the names used to 
  280: remove data from the hash.  They represent 
  281: the name of the data to be removed.
  282: 
  283: $ChartDB: The name of the cached data database which will be tied to that 
  284: database.
  285: 
  286: Output: $Str
  287: 
  288: $Str: Formatted string that is an entire row of the chart.  It is a 
  289: concatenation of student information and student course information.
  290: 
  291: =back
  292: 
  293: =cut
  294: 
  295: sub StudentReport {
  296:     my ($cache,$name,$spacing,$showSequences)=@_;
  297:     my ($username,$domain)=split(':',$name);
  298: 
  299:     my $Str = '';
  300:     if(defined($cache->{$name.':error'})) {
  301:         return $Str;
  302:     }
  303:     if($cache->{$name.':error'} =~ /course/) {
  304:         $Str .= '<b><font color="blue">No course data for student </font>';
  305:         $Str .= '<font color="red">'.$username.'.</font></b><br>';
  306:         return $Str;
  307:     }
  308: 
  309:     my $hasVersion = 'false';
  310:     my $hasFinalData = 'false';
  311:     foreach my $sequence (@$showSequences) {
  312:         my $hasData = 'false';
  313:         my $characterCount=0;
  314:         foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
  315:             my $problem = $cache->{$problemID.':problem'};
  316:             # All grades (except for versionless parts) are displayed as links
  317:             # to their submission record.  Loop through all the parts for the
  318:             # current problem in the correct order and prepare the output links
  319:             foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
  320:                                         ':parts'})) {
  321:                 if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
  322:                    $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
  323:                    $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
  324:                     $Str .= ' ';
  325:                     $characterCount++;
  326:                     next;
  327:                 }
  328:                 $hasVersion = 'true';
  329:                 $hasData = 'true';
  330:                 $Str .= '<a href="/adm/grades?symb=';
  331:                 $Str .= &Apache::lonnet::escape($problem);
  332:                 $Str .= '&student='.$username.'&domain='.$domain;
  333:                 $Str .= '&command=submission">'; 
  334:                 my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
  335:                 my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
  336:                 if($code eq '*' && $tries < 10 && $tries ne '') {
  337:                     $code = $tries;
  338:                 }
  339:                 $Str .= $code;
  340:                 $Str .= '</a>';
  341:                 $characterCount++;
  342:             }
  343:         }
  344: 
  345:         # Output the number of correct answers for the current sequence.
  346:         # This part takes up 6 character slots, but is formated right
  347:         # justified.
  348:         my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
  349:         $spacesNeeded -= 3;
  350:         $Str .= (' 'x$spacesNeeded);
  351: 
  352: #        my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
  353: #							    ':problemsCorrect'});
  354: 
  355: 	my $outputProblemsCorrect = sprintf("%2d/%2d", $cache->{$name.':'.$sequence.
  356:                                             ':problemsCorrect'},
  357:                                             $characterCount);
  358:         if($hasData eq 'true') {
  359:             $Str .= '<font color="#007700">'.$outputProblemsCorrect.'</font>';
  360:             $hasFinalData = 'true';
  361:         } else {
  362:             $Str .= '<font color="#007700">     </font>';
  363:         }
  364:         $Str .= $spacing;
  365:     }
  366: 
  367:     # Output the total correct problems over the total number of problems.
  368:     # I don't like this type of formatting, but it is a solution.  Need
  369:     # a way to dynamically determine the space requirements.
  370:     my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
  371:     my $outputTotalProblems  = sprintf("%4d", $cache->{$name.':totalProblems'});
  372:     if($hasFinalData eq 'true') {
  373:         $Str .= '<font color="#000088">'.$outputProblemsSolved.
  374: 	    ' / '.$outputTotalProblems.'</font>';
  375:     } else {
  376:         $Str .= '<font color="#000088">           </font>';
  377:     }
  378: 
  379:     if($hasVersion eq 'false') {
  380:         $Str = '<b><font color="blue">No course data.</font></b>';
  381:     }
  382: 
  383:     return $Str;
  384: }
  385: 
  386: 
  387: sub StudentAverageTotal {
  388:     
  389:     return "";
  390: 
  391:     my ($cache,$name,$spacing,$showSequences)=@_;
  392:     my $username = $name;
  393:     my $Str = '';
  394:     my $hasVersion = 'false';
  395:     my $hasFinalData = 'false';
  396:     foreach my $sequence (@$showSequences) {
  397:         my $hasData = 'false';
  398:         my $characterCount=0;
  399:         foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
  400:             my $problem = $cache->{$problemID.':problem'};
  401:             # All grades (except for versionless parts) are displayed as links
  402:             # to their submission record.  Loop through all the parts for the
  403:             # current problem in the correct order and prepare the output links
  404:             foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
  405:                                         ':parts'})) {
  406:                 if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
  407:                    $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
  408:                    $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
  409:                     $Str .= ' ';
  410:                     $characterCount++;
  411:                     next;
  412:                 }
  413:                 $hasVersion = 'true';
  414:                 $hasData = 'true';
  415:                 $Str .= '<a href="/adm/grades?symb=';
  416:                 $Str .= &Apache::lonnet::escape($problem);
  417:                 $Str .= '&student= Average &domain= Total';
  418:                 $Str .= '&command=submission">';
  419:                 my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
  420:                 my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
  421:                 if($code eq '*' && $tries < 10 && $tries ne '') {
  422:                     $code = $tries;
  423:                 }
  424:                 $Str .= $code;
  425:                 $Str .= '</a>';
  426:                 $characterCount++;
  427:             }
  428:         }
  429: 
  430:         # Output the number of correct answers for the current sequence.
  431:         # This part takes up 6 character slots, but is formated right
  432:         # justified.
  433:         my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
  434:         $spacesNeeded -= 3;
  435:         $Str .= (' 'x$spacesNeeded);
  436: 
  437: #        my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
  438: #							    ':problemsCorrect'});
  439: 
  440: 	my $outputProblemsCorrect = sprintf("%2d/%2d", $cache->{$name.':'.$sequence.
  441:                                             ':problemsCorrect'},
  442:                                             $characterCount);
  443:         if($hasData eq 'true') {
  444:             $Str .= '<font color="#007700">'.$outputProblemsCorrect.'</font>';
  445:             $hasFinalData = 'true';
  446:         } else {
  447:             $Str .= '<font color="#007700">     </font>';
  448:         }
  449:         $Str .= $spacing;
  450:     }
  451: 
  452:     # Output the total correct problems over the total number of problems.
  453:     # I don't like this type of formatting, but it is a solution.  Need
  454:     # a way to dynamically determine the space requirements.
  455:     my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
  456:     my $outputTotalProblems  = sprintf("%4d", $cache->{$name.':totalProblems'});
  457:     if($hasFinalData eq 'true') {
  458:         $Str .= '<font color="#000088">'.$outputProblemsSolved.
  459: 	    ' / '.$outputTotalProblems.'</font>';
  460:     } else {
  461:         $Str .= '<font color="#000088">           </font>';
  462:     }
  463: 
  464:     if($hasVersion eq 'false') {
  465:         $Str = '<b><font color="blue">No course data.</font></b>';
  466:     }
  467: 
  468:     return $Str;
  469: }
  470: 
  471: 
  472: 
  473: =pod
  474: 
  475: =item &CreateLegend()
  476: 
  477: This function returns a formatted string containing the legend for the
  478: chart.  The legend describes the symbols used to represent grades for
  479: problems.
  480: 
  481: =cut
  482: 
  483: sub CreateLegend {
  484:     my $Str = "<p><pre>".
  485:               "   1  correct by student in 1 try\n".
  486:               "   7  correct by student in 7 tries\n".
  487:               "   *  correct by student in more than 9 tries\n".
  488: 	      "   +  correct by override\n".
  489:               "   -  incorrect by override\n".
  490: 	      "   .  incorrect attempted\n".
  491: 	      "   #  ungraded attempted\n".
  492:               "      not attempted (blank field)\n".
  493: 	      "   x  excused".
  494:               "</pre><p>";
  495:     return $Str;
  496: }
  497: 
  498: =pod
  499: 
  500: =item &CreateColumnSelectionBox()
  501: 
  502: If there are columns not being displayed then this selection box is created
  503: with a list of those columns.  When selections are made and the page
  504: refreshed, the columns will be removed from this box and the column is
  505: put back in the chart.  If there is no columns to select, no row is added
  506: to the interface table.
  507: 
  508: =over 4
  509: Input: $CacheData, $headings
  510: 
  511: 
  512: $CacheData: A pointer to a hash tied to the cached data
  513: 
  514: $headings:  An array of the names of the columns for the student information.
  515: They are used for displaying which columns are missing.
  516: 
  517: Output: $notThere
  518: 
  519: $notThere: The string contains one row of a table.  The first column has the
  520: name of the selection box.  The second contains the selection box
  521: which has a size of four.
  522: 
  523: =back
  524: 
  525: =cut
  526: 
  527: sub CreateColumnSelectionBox {
  528:     my ($doNotShow)=@_;
  529: 
  530:     my $notThere = '';
  531:     $notThere .= '<select name="ReselectColumns" size="4" ';
  532:     $notThere .= 'multiple="true">'."\n";
  533: 
  534:     for(my $index=0; $index<$doNotShow->{'count'}; $index++) {
  535:         my $name = $doNotShow->{$index.':name'};
  536:         $notThere .= '<option value="';
  537:         $notThere .= $doNotShow->{$index.':id'}.'">';
  538:         $notThere .= $name.'</option>'."\n";
  539:     }
  540: 
  541:     $notThere .= '</select>';
  542: 
  543:     return $notThere;
  544: }
  545: 
  546: =pod
  547: 
  548: =item &CreateColumnSelectors()
  549: 
  550: This function generates the checkboxes above the column headings.  The
  551: column will be removed if the checkbox is unchecked.
  552: 
  553: =over 4
  554: 
  555: Input: $CacheData, $headings
  556: 
  557: $CacheData: A pointer to a hash tied to the cached data
  558: 
  559: $headings:  An array of the names of the columns for the student 
  560: information.  They are used to know what are the student information columns
  561: 
  562: Output: $present
  563: 
  564: $present: The string contains the first row of a table.  Each column contains
  565: a checkbox which is left justified.  Currently left justification is used
  566: for consistency of location over the column in which it presides.
  567: 
  568: =back
  569: 
  570: =cut
  571: 
  572: sub CreateColumnSelectors {
  573:     my ($infoHeadings, $sequenceHeadings, $sequenceKeys)=@_;
  574: 
  575:     my $present = '';
  576:     for(my $index=0; $index<(scalar @$infoHeadings); $index++) {
  577:         $present .= '<td align="left">';
  578:         $present .= '<input type="checkbox" checked="on" ';
  579:         $present .= 'name="HeadingColumn'.$infoHeadings->[$index].'" />';
  580:         $present .= '</td>'."\n";
  581:     }
  582: 
  583:     for(my $index=0; $index<(scalar @$sequenceHeadings); $index++) {
  584:         $present .= '<td align="left">';
  585:         $present .= '<input type="checkbox" checked="on" ';
  586:         $present .= 'name="SequenceColumn'.$sequenceKeys->[$index].'" />';
  587:         $present .= '</td>'."\n";
  588:     }
  589: 
  590:     return $present;
  591: }
  592: 
  593: #---- END Student Assessment Web Page ----------------------------------------
  594: 
  595: #---- Student Assessment Worker Functions ------------------------------------
  596: 
  597: sub FindSelectedStudent {
  598:     my($cache, $selectedName, $students)=@_;
  599: 
  600:     if($selectedName eq 'All Students' ||
  601:        $selectedName eq 'No Student Selected') {
  602:         return $selectedName;
  603:     }
  604: 
  605:     for(my $index=0; $index<(scalar @$students); $index++) {
  606:         my $fullname = $cache->{$students->[$index].':fullname'};
  607:         if($fullname eq $selectedName) {
  608:             if($cache->{'StudentAssessmentMove'} eq 'next') {
  609:                 if($index == ((scalar @$students) - 1)) {
  610:                     $selectedName = $students->[0];
  611:                     return $selectedName;
  612:                 } else {
  613:                     $selectedName = $students->[$index+1];
  614:                     return $selectedName;
  615:                 }
  616:             } elsif($cache->{'StudentAssessmentMove'} eq 'previous') {
  617:                 if($index == 0) {
  618:                     $selectedName = $students->[-1];
  619:                     return $selectedName;
  620:                 } else {
  621:                     $selectedName = $students->[$index-1];
  622:                     return $selectedName;
  623:                 }
  624:             } else {
  625:                 $selectedName = $students->[$index];
  626:                 return $selectedName;
  627:             }
  628:             last;
  629:         }
  630:     }
  631: 
  632:     return 'No Student Selected';
  633: }
  634: 
  635: =pod
  636: 
  637: =item &ShouldShowColumn()
  638: 
  639: Determine if a specified column should be shown on the chart.
  640: 
  641: =over 4
  642: 
  643: Input: $cache, $test
  644: 
  645: $cache: A pointer to the hash tied to the cached data
  646: 
  647: $test: The form name of the column (heading.$headingIndex) or 
  648: (sequence.$sequenceIndex)
  649: 
  650: Output: 0 (false), 1 (true)
  651: 
  652: =back
  653: 
  654: =cut
  655: 
  656: sub ShouldShowColumns {
  657:     my ($cache,$headings,$cacheKey)=@_;
  658: 
  659:     my @infoKeys=();
  660:     my @infoHeadings=();
  661: 
  662:     my @sequenceKeys=();
  663:     my @sequenceHeadings=();
  664: 
  665:     my %doNotShow;
  666: 
  667:     my $index;
  668:     my $count = 0;
  669:     my $check = '';
  670:     for($index=0; $index < scalar @$headings; $index++) {
  671:         $check = 'HeadingColumn'.$headings->[$index];
  672:         if($cache->{'HeadingsFound'} =~ /$check/) {
  673:             push(@infoHeadings, $headings->[$index]);
  674:             push(@infoKeys, $cacheKey->[$index]);
  675:         } else {
  676:             $doNotShow{$count.':name'} = $headings->[$index];
  677:             $doNotShow{$count.':id'} = 'HeadingColumn'.$headings->[$index];
  678:             $count++;
  679:         }
  680:     }
  681: 
  682:     foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) {
  683:         $check = 'SequenceColumn'.$sequence;
  684:         if($cache->{'SequencesFound'} eq 'All Sequences' || 
  685:            $cache->{'SequencesFound'} =~ /$check/) {
  686:             push(@sequenceHeadings, $cache->{$sequence.':title'});
  687:             push(@sequenceKeys, $sequence);
  688:         } else {
  689:             $doNotShow{$count.':name'} = $cache->{$sequence.':title'};
  690:             $doNotShow{$count.':id'} = 'SequenceColumn'.$sequence;
  691:             $count++;
  692:         }
  693:     }
  694: 
  695:     $doNotShow{'count'} = $count;
  696: 
  697:     return (\@infoHeadings, \@infoKeys, \@sequenceHeadings, 
  698:             \@sequenceKeys, \%doNotShow);
  699: }
  700: 
  701: #---- END Student Assessment Worker Functions --------------------------------
  702: 
  703: 1;
  704: __END__

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