File:  [LON-CAPA] / loncom / interface / statistics / lonstudentassessment.pm
Revision 1.24: download - view: text, annotated - select for diffs
Fri Jan 3 23:54:05 2003 UTC (21 years, 6 months ago) by minaeibi
Branches: MAIN
CVS tags: HEAD
Tried to fix bug #994 for coloring and numbering the chart rows.
It needs more work.

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

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