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

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

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