File:  [LON-CAPA] / loncom / interface / statistics / lonstudentassessment.pm
Revision 1.23: download - view: text, annotated - select for diffs
Tue Dec 24 21:00:21 2002 UTC (21 years, 6 months ago) by minaeibi
Branches: MAIN
CVS tags: HEAD
Fixed bug #880
lonstudentassessment.pm (chart) gives summary tables at the end of computing the course chart.
Let me know any feedback.

    1: # The LearningOnline Network with CAPA
    2: # (Publication Handler
    3: #
    4: # $Id: lonstudentassessment.pm,v 1.23 2002/12/24 21:00:21 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,12/24  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:     if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
  169:         $r->print(&StudentAverageTotal(\%cache, $students, $sequenceKeys));
  170:         untie(%cache);
  171:     }
  172:     $r->print('</pre>'."\n");
  173:     if($selected == 0) {
  174: 	$Str .= '<h3><font color=blue>WARNING: ';
  175:         $Str .= 'Please select a student</font></h3>';
  176:         $r->print($Str);
  177:     }
  178: 
  179:     return;
  180: }
  181: 
  182: 
  183: 
  184: 
  185: #---- Student Assessment Web Page --------------------------------------------
  186: 
  187: sub CreateInterface {
  188:     my($cache,$selectedName,$students,$formName,$doNotShow)=@_;
  189: 
  190:     my $Str = '';
  191:     $Str .= &CreateLegend();
  192:     $Str .= '<table><tr><td>'."\n";
  193:     $Str .= '<input type="submit" name="PreviousStudent" ';
  194:     $Str .= 'value="Previous Student" />'."\n";
  195:     $Str .= '&nbsp&nbsp&nbsp'."\n";
  196:     $Str .= &Apache::lonhtmlcommon::StudentOptions($cache, $students,
  197:                                                    $selectedName,
  198:                                                    'StudentAssessment',
  199:                                                    $formName);
  200:     $Str .= "\n".'&nbsp&nbsp&nbsp'."\n";
  201:     $Str .= '<input type="submit" name="NextStudent" ';
  202:     $Str .= 'value="Next Student" />'."\n";
  203:     $Str .= '</td></tr></table>'."\n";
  204:     $Str .= '<table cellspacing="5"><tr>'."\n";
  205:     $Str .= '<td align="center"><b>Select Sections</b>'."\n";
  206:     $Str .= '</td>'."\n";
  207:     $Str .= '<td align="center"><b>Select column to view:</b></td>'."\n";
  208:     $Str .= '<td></td></tr>'."\n";
  209: 
  210:     $Str .= '<tr><td align="center">'."\n";
  211:     my @sections = split(':',$cache->{'sectionList'});
  212:     my @selectedSections = split(':',$cache->{'sectionsSelected'});
  213:     $Str .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
  214:                                                           \@selectedSections,
  215:                                                           'Statistics');
  216:     $Str .= '</td><td align="center">';
  217:     $Str .= &CreateColumnSelectionBox($doNotShow);
  218:     $Str .= '</td><td>'."\n";
  219:     $Str .= '<input type="submit" name="DefaultColumns" ';
  220:     $Str .= 'value="Default Column Display" />'."\n";
  221:     $Str .= '</td><td>'."\n";
  222:     $Str .= '<input type="submit" name="displaymode" ';
  223:     if (! exists($ENV{'form.displaymode'}) ||
  224:         lc($ENV{'form.displaymode'}) eq 'display with links') {
  225:         $Str .= 'value="Display without links" />';
  226:         # Set the current value, in case it is undefined
  227:         $ENV{'form.displaymode'} = 'Display with links';
  228:     } else {
  229:         $Str .= 'value="Display with links" />';
  230:     }
  231:     $Str .= "\n";
  232:     $Str .= '</td></tr></table>'."\n";
  233: 
  234:     return $Str;
  235: }
  236: 
  237: sub CreateTableHeadings {
  238:     my($cache,$spacing,$infoKeys,$infoHeadings,$sequenceKeys,
  239:        $sequenceHeadings)=@_;
  240: 
  241:     my $Str = '';
  242:     $Str .= '<table border="0" cellpadding="0" cellspacing="0">'."\n";
  243: 
  244:     $Str .= '<tr>'."\n";
  245:     $Str .= &CreateColumnSelectors($infoHeadings, $sequenceHeadings,
  246:                                    $sequenceKeys);
  247:     $Str .= '<td></td></tr>'."\n";
  248: 
  249:     $Str .= '<tr>'."\n";
  250:     my $displayString = '<td align="left"><pre><a href="/adm/statistics?';
  251:     $displayString .= 'sort=LINKDATA">DISPLAYDATA</a>FORMATTING';
  252:     $displayString .= $spacing.'</pre></td>'."\n";
  253:     $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
  254:                                                    $infoKeys,
  255:                                                    $infoHeadings,
  256:                                                    $displayString,
  257:                                                    'preformatted');
  258: 
  259:     $displayString  = '<td align="left"><pre>DISPLAYDATAFORMATTING'.$spacing;
  260:     $displayString .= '</pre></td>'."\n";
  261:     $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
  262:                                                    $sequenceKeys,
  263:                                                    $sequenceHeadings,
  264:                                                    $displayString,
  265:                                                    'preformatted');
  266: 
  267:     $Str .= '<td><pre>Total Solved/Total Problems</pre></td>';
  268:     $Str .= '</tr></table>'."\n";
  269: 
  270:     return $Str;
  271: }
  272: 
  273: =pod
  274: 
  275: =item &FormatStudentData()
  276: 
  277: First, FormatStudentInformation is called and prefixes the course information.
  278: This function produces a formatted string of the student\'s course information.
  279: Each column of data represents all the problems for a given sequence.  For
  280: valid grade data, a link is created for that problem to a submission record
  281: for that problem.
  282: 
  283: =over 4
  284: 
  285: Input: $name, $studentInformation, $ChartDB
  286: 
  287: $name: The name and domain of the current student in name:domain format
  288: 
  289: $studentInformation: A pointer to an array holding the names used to 
  290: remove data from the hash.  They represent 
  291: the name of the data to be removed.
  292: 
  293: $ChartDB: The name of the cached data database which will be tied to that 
  294: database.
  295: 
  296: Output: $Str
  297: 
  298: $Str: Formatted string that is an entire row of the chart.  It is a
  299: concatenation of student information and student course information.
  300: 
  301: =back
  302: 
  303: =cut
  304: 
  305: sub StudentReport {
  306:     my ($cache,$name,$spacing,$showSequences)=@_;
  307:     my ($username,$domain)=split(':',$name);
  308: 
  309:     my $Str = '';
  310:     if(defined($cache->{$name.':error'})) {
  311:         return $Str;
  312:     }
  313:     if($cache->{$name.':error'} =~ /course/) {
  314:         $Str .= '<b><font color="blue">No course data for student </font>';
  315:         $Str .= '<font color="red">'.$username.'.</font></b><br>';
  316:         return $Str;
  317:     }
  318: 
  319:     my $hasVersion = 'false';
  320:     my $hasFinalData = 'false';
  321:     foreach my $sequence (@$showSequences) {
  322:         my $hasData = 'false';
  323:         my $characterCount=0;
  324:         foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
  325:             my $problem = $cache->{$problemID.':problem'};
  326:             # All grades (except for versionless parts) are displayed as links
  327:             # to their submission record.  Loop through all the parts for the
  328:             # current problem in the correct order and prepare the output links
  329:             foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
  330:                                         ':parts'})) {
  331:                 if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
  332:                    $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
  333:                    $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
  334:                     $Str .= ' ';
  335:                     $characterCount++;
  336:                     next;
  337:                 }
  338:                 $hasVersion = 'true';
  339:                 $hasData = 'true';
  340:                 if (lc($ENV{'form.displaymode'}) ne 'display without links') {
  341:                     $Str .= '<a href="/adm/grades?symb=';
  342:                     $Str .= &Apache::lonnet::escape($problem);
  343:                     $Str .= '&student='.$username.'&domain='.$domain;
  344:                     $Str .= '&command=submission">';
  345:                 }
  346:                 my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
  347:                 my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
  348:                 if($code eq '*' && $tries < 10 && $tries ne '') {
  349:                     $code = $tries;
  350:                 }
  351:                 $Str .= $code;
  352:                 if (lc($ENV{'form.displaymode'}) ne 'display without links') {
  353:                     $Str .= '</a>';
  354:                 }
  355:                 $characterCount++;
  356:             }
  357:         }
  358: 
  359:         # Output the number of correct answers for the current sequence.
  360:         # This part takes up 6 character slots, but is formated right
  361:         # justified.
  362:         my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
  363:         $spacesNeeded -= 3;
  364:         $Str .= (' 'x$spacesNeeded);
  365: 
  366: #        my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
  367: #							    ':problemsCorrect'});
  368: 
  369: 	my $outputProblemsCorrect = sprintf("%2d/%2d", $cache->{$name.':'.$sequence.
  370:                                             ':problemsCorrect'},
  371:                                             $characterCount);
  372:         if($hasData eq 'true') {
  373:             $Str .= '<font color="#007700">'.$outputProblemsCorrect.'</font>';
  374:             $hasFinalData = 'true';
  375:         } else {
  376:             $Str .= '<font color="#007700">     </font>';
  377:         }
  378:         $Str .= $spacing;
  379:     }
  380: 
  381:     # Output the total correct problems over the total number of problems.
  382:     # I don't like this type of formatting, but it is a solution.  Need
  383:     # a way to dynamically determine the space requirements.
  384:     my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
  385:     my $outputTotalProblems  = sprintf("%4d", $cache->{$name.':totalProblems'});
  386:     if($hasFinalData eq 'true') {
  387:         $Str .= '<font color="#000088">'.$outputProblemsSolved.
  388: 	    ' / '.$outputTotalProblems.'</font>';
  389:     } else {
  390:         $Str .= '<font color="#000088">           </font>';
  391:     }
  392: 
  393:     if($hasVersion eq 'false') {
  394:         $Str = '<b><font color="blue">No course data.</font></b>';
  395:     }
  396: 
  397:     return $Str;
  398: }
  399: 
  400: 
  401: sub StudentAverageTotal {
  402:     my ($cache, $students, $sequenceKeys)=@_;
  403:     my $Str = "\n<b>Summary Tables:</b>\n";
  404:     my %Correct = ();
  405:     my $ProblemsSolved = 0;
  406:     my $TotalProblems = 0;
  407:     my $StudentCount = 0;
  408: 
  409:     foreach my $name (@$students) {
  410:         $StudentCount++;
  411:         foreach my $sequence (@$sequenceKeys) {
  412:             $Correct{$sequence} +=
  413: 	       $cache->{$name.':'.$sequence.':problemsCorrect'};
  414:         }
  415: 	$ProblemsSolved += $cache->{$name.':problemsSolved'};
  416:         $TotalProblems += $cache->{$name.':totalProblems'};
  417:     }
  418:     $ProblemsSolved /= $StudentCount;
  419:     $TotalProblems /= $StudentCount;
  420:     
  421:     $Str .= '<table border=2 cellspacing="5">'."\n";
  422:     $Str .= '<tr><td><b>Students Count</b></td><td><b>'.
  423:             $StudentCount.'</b></td></tr>'."\n";
  424:     $Str .= '<tr><td><b>Total Problems</b></td><td><b>'.
  425:             $TotalProblems.'</b></td></tr>'."\n";
  426:     $Str .= '<tr><td><b>Average Correct</b></td><td><b>'.
  427:             $ProblemsSolved.'</b></td></tr>'."\n";
  428:     $Str .= '</table>'."\n";
  429: 
  430:     $Str .= '<table border=2 cellspacing="5">'."\n";
  431:     $Str .= '<tr><th>Title</th><th>Total Problems</th>'.
  432:             '<th>Average Correct</th></tr>'."\n";
  433:     foreach my $S(@$sequenceKeys) {
  434:         my $title=$cache->{$S.':title'};
  435: 	#$Str .= $cache->{$S.':problems'};
  436: 	#my @problems=split(':', $cache->{$S.':problems'}); 
  437: 	#my $pCount=scalar @problems;
  438: 	my $pCount=MaxSeqPr($cache,@$students[0],$S);
  439: 	my $crr=sprintf( "%.2f", $Correct{$S}/$StudentCount );
  440:         $Str .= '<tr><td>'.$title.
  441:                 '</td><td align=center>'.$pCount.
  442:                 '</td><td align=center>'.$crr.
  443:                 '</td></tr>'."\n";
  444:     }
  445: 
  446:     $Str .= '</table>'."\n";
  447: 
  448:     return $Str;
  449: }
  450: 
  451: 
  452: 
  453: sub MaxSeqPr {
  454:     my ($cache, $name, $sequence)=@_;
  455:     my $prCount=0;
  456:     foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
  457:         my $problem = $cache->{$problemID.':problem'};
  458:         foreach(split(/\:/,$cache->{$sequence.':'.$problemID.':parts'})) {
  459:             if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
  460:                $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
  461:                $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
  462:                  $prCount++;
  463:                  next;
  464:             }
  465:             $prCount++;
  466:         }
  467:     }
  468:     return $prCount;
  469: }
  470: 
  471: 
  472: 
  473: 
  474: 
  475: =pod
  476: 
  477: =item &CreateLegend()
  478: 
  479: This function returns a formatted string containing the legend for the
  480: chart.  The legend describes the symbols used to represent grades for
  481: problems.
  482: 
  483: =cut
  484: 
  485: sub CreateLegend {
  486:     my $Str = "<p><pre>".
  487:               "   1  correct by student in 1 try\n".
  488:               "   7  correct by student in 7 tries\n".
  489:               "   *  correct by student in more than 9 tries\n".
  490: 	      "   +  correct by hand grading or override\n".
  491:               "   -  incorrect by override\n".
  492: 	      "   .  incorrect attempted\n".
  493: 	      "   #  ungraded attempted\n".
  494:               "      not attempted (blank field)\n".
  495: 	      "   x  excused".
  496:               "</pre><p>";
  497:     return $Str;
  498: }
  499: 
  500: =pod
  501: 
  502: =item &CreateColumnSelectionBox()
  503: 
  504: If there are columns not being displayed then this selection box is created
  505: with a list of those columns.  When selections are made and the page
  506: refreshed, the columns will be removed from this box and the column is
  507: put back in the chart.  If there is no columns to select, no row is added
  508: to the interface table.
  509: 
  510: =over 4
  511: Input: $CacheData, $headings
  512: 
  513: 
  514: $CacheData: A pointer to a hash tied to the cached data
  515: 
  516: $headings:  An array of the names of the columns for the student information.
  517: They are used for displaying which columns are missing.
  518: 
  519: Output: $notThere
  520: 
  521: $notThere: The string contains one row of a table.  The first column has the
  522: name of the selection box.  The second contains the selection box
  523: which has a size of four.
  524: 
  525: =back
  526: 
  527: =cut
  528: 
  529: sub CreateColumnSelectionBox {
  530:     my ($doNotShow)=@_;
  531: 
  532:     my $notThere = '';
  533:     $notThere .= '<select name="ReselectColumns" size="4" ';
  534:     $notThere .= 'multiple="true">'."\n";
  535: 
  536:     for(my $index=0; $index<$doNotShow->{'count'}; $index++) {
  537:         my $name = $doNotShow->{$index.':name'};
  538:         $notThere .= '<option value="';
  539:         $notThere .= $doNotShow->{$index.':id'}.'">';
  540:         $notThere .= $name.'</option>'."\n";
  541:     }
  542: 
  543:     $notThere .= '</select>';
  544: 
  545:     return $notThere;
  546: }
  547: 
  548: =pod
  549: 
  550: =item &CreateColumnSelectors()
  551: 
  552: This function generates the checkboxes above the column headings.  The
  553: column will be removed if the checkbox is unchecked.
  554: 
  555: =over 4
  556: 
  557: Input: $CacheData, $headings
  558: 
  559: $CacheData: A pointer to a hash tied to the cached data
  560: 
  561: $headings:  An array of the names of the columns for the student 
  562: information.  They are used to know what are the student information columns
  563: 
  564: Output: $present
  565: 
  566: $present: The string contains the first row of a table.  Each column contains
  567: a checkbox which is left justified.  Currently left justification is used
  568: for consistency of location over the column in which it presides.
  569: 
  570: =back
  571: 
  572: =cut
  573: 
  574: sub CreateColumnSelectors {
  575:     my ($infoHeadings, $sequenceHeadings, $sequenceKeys)=@_;
  576: 
  577:     my $present = '';
  578:     for(my $index=0; $index<(scalar @$infoHeadings); $index++) {
  579:         $present .= '<td align="left">';
  580:         $present .= '<input type="checkbox" checked="on" ';
  581:         $present .= 'name="HeadingColumn'.$infoHeadings->[$index].'" />';
  582:         $present .= '</td>'."\n";
  583:     }
  584: 
  585:     for(my $index=0; $index<(scalar @$sequenceHeadings); $index++) {
  586:         $present .= '<td align="left">';
  587:         $present .= '<input type="checkbox" checked="on" ';
  588:         $present .= 'name="SequenceColumn'.$sequenceKeys->[$index].'" />';
  589:         $present .= '</td>'."\n";
  590:     }
  591: 
  592:     return $present;
  593: }
  594: 
  595: #---- END Student Assessment Web Page ----------------------------------------
  596: 
  597: #---- Student Assessment Worker Functions ------------------------------------
  598: 
  599: sub FindSelectedStudent {
  600:     my($cache, $selectedName, $students)=@_;
  601: 
  602:     if($selectedName eq 'All Students' ||
  603:        $selectedName eq 'No Student Selected') {
  604:         return $selectedName;
  605:     }
  606: 
  607:     for(my $index=0; $index<(scalar @$students); $index++) {
  608:         my $fullname = $cache->{$students->[$index].':fullname'};
  609:         if($fullname eq $selectedName) {
  610:             if($cache->{'StudentAssessmentMove'} eq 'next') {
  611:                 if($index == ((scalar @$students) - 1)) {
  612:                     $selectedName = $students->[0];
  613:                     return $selectedName;
  614:                 } else {
  615:                     $selectedName = $students->[$index+1];
  616:                     return $selectedName;
  617:                 }
  618:             } elsif($cache->{'StudentAssessmentMove'} eq 'previous') {
  619:                 if($index == 0) {
  620:                     $selectedName = $students->[-1];
  621:                     return $selectedName;
  622:                 } else {
  623:                     $selectedName = $students->[$index-1];
  624:                     return $selectedName;
  625:                 }
  626:             } else {
  627:                 $selectedName = $students->[$index];
  628:                 return $selectedName;
  629:             }
  630:             last;
  631:         }
  632:     }
  633: 
  634:     return 'No Student Selected';
  635: }
  636: 
  637: =pod
  638: 
  639: =item &ShouldShowColumn()
  640: 
  641: Determine if a specified column should be shown on the chart.
  642: 
  643: =over 4
  644: 
  645: Input: $cache, $test
  646: 
  647: $cache: A pointer to the hash tied to the cached data
  648: 
  649: $test: The form name of the column (heading.$headingIndex) or 
  650: (sequence.$sequenceIndex)
  651: 
  652: Output: 0 (false), 1 (true)
  653: 
  654: =back
  655: 
  656: =cut
  657: 
  658: sub ShouldShowColumns {
  659:     my ($cache,$headings,$cacheKey)=@_;
  660: 
  661:     my @infoKeys=();
  662:     my @infoHeadings=();
  663: 
  664:     my @sequenceKeys=();
  665:     my @sequenceHeadings=();
  666: 
  667:     my %doNotShow;
  668: 
  669:     my $index;
  670:     my $count = 0;
  671:     my $check = '';
  672:     for($index=0; $index < scalar @$headings; $index++) {
  673:         $check = 'HeadingColumn'.$headings->[$index];
  674:         if($cache->{'HeadingsFound'} =~ /$check/) {
  675:             push(@infoHeadings, $headings->[$index]);
  676:             push(@infoKeys, $cacheKey->[$index]);
  677:         } else {
  678:             $doNotShow{$count.':name'} = $headings->[$index];
  679:             $doNotShow{$count.':id'} = 'HeadingColumn'.$headings->[$index];
  680:             $count++;
  681:         }
  682:     }
  683: 
  684:     foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) {
  685:         $check = 'SequenceColumn'.$sequence;
  686:         if($cache->{'SequencesFound'} eq 'All Sequences' ||
  687:            $cache->{'SequencesFound'} =~ /$check/) {
  688:             push(@sequenceHeadings, $cache->{$sequence.':title'});
  689:             push(@sequenceKeys, $sequence);
  690:         } else {
  691:             $doNotShow{$count.':name'} = $cache->{$sequence.':title'};
  692:             $doNotShow{$count.':id'} = 'SequenceColumn'.$sequence;
  693:             $count++;
  694:         }
  695:     }
  696: 
  697:     $doNotShow{'count'} = $count;
  698: 
  699:     return (\@infoHeadings, \@infoKeys, \@sequenceHeadings,
  700:             \@sequenceKeys, \%doNotShow);
  701: }
  702: 
  703: #---- END Student Assessment Worker Functions --------------------------------
  704: 
  705: 1;
  706: __END__

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