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

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

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