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

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

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