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

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

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