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

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

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