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

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

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