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

1.1       stredwic    1: # The LearningOnline Network with CAPA
                      2: # (Publication Handler
                      3: #
1.21    ! minaeibi    4: # $Id: lonstudentassessment.pm,v 1.20 2002/12/11 18:41:00 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: 
1.21    ! minaeibi   37: package Apache::lonstudentassessment;
1.1       stredwic   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,
1.21    ! minaeibi   80:         $doNotShow) =
1.4       stredwic   81:         &ShouldShowColumns(\%cache, $headings, $studentInformation);
1.3       stredwic   82: 
1.21    ! minaeibi   83:     my $selectedName = &FindSelectedStudent(\%cache,
1.2       stredwic   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.17      minaeibi  107:         next if ($_ ne $selectedName &&
1.1       stredwic  108:                  $selectedName ne 'All Students');
                    109:         $selected = 1;
1.2       stredwic  110: 
1.8       stredwic  111:         my @who = ($_);
1.17      minaeibi  112:         next if(&Apache::loncoursedata::DownloadStudentCourseData(\@who, 'true',
                    113:                                                              $cacheDB, 'true',
1.8       stredwic  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: 
1.21    ! minaeibi  168:     if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
        !           169:         $r->print(&StudentAverageTotal(\%cache, $students, $sequenceKeys));
        !           170:         untie(%cache);
        !           171:     }
1.2       stredwic  172:     $r->print('</pre>'."\n");
1.1       stredwic  173:     if($selected == 0) {
1.4       stredwic  174: 	$Str .= '<h3><font color=blue>WARNING: ';
                    175:         $Str .= 'Please select a student</font></h3>';
                    176:         $r->print($Str);
1.1       stredwic  177:     }
                    178: 
1.2       stredwic  179:     return;
                    180: }
                    181: 
1.21    ! minaeibi  182: 
        !           183: 
        !           184: 
1.2       stredwic  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";
1.17      minaeibi  196:     $Str .= &Apache::lonhtmlcommon::StudentOptions($cache, $students,
1.21    ! minaeibi  197:                                                    $selectedName,
        !           198:                                                    'StudentAssessment',
1.2       stredwic  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";
1.18      matthew   221:     $Str .= '</td><td>'."\n";
                    222:     $Str .= '<input type="submit" name="displaymode" ';
                    223:     if (! exists($ENV{'form.displaymode'}) ||
                    224:         lc($ENV{'form.displaymode'}) eq 'display with links') {
                    225:         $Str .= 'value="Display without links" />';
                    226:         # Set the current value, in case it is undefined
1.21    ! minaeibi  227:         $ENV{'form.displaymode'} = 'Display with links';
1.18      matthew   228:     } else {
                    229:         $Str .= 'value="Display with links" />';
                    230:     }
                    231:     $Str .= "\n";
1.4       stredwic  232:     $Str .= '</td></tr></table>'."\n";
1.2       stredwic  233: 
1.4       stredwic  234:     return $Str;
1.1       stredwic  235: }
                    236: 
1.2       stredwic  237: sub CreateTableHeadings {
                    238:     my($cache,$spacing,$infoKeys,$infoHeadings,$sequenceKeys,
                    239:        $sequenceHeadings)=@_;
                    240: 
                    241:     my $Str = '';
1.4       stredwic  242:     $Str .= '<table border="0" cellpadding="0" cellspacing="0">'."\n";
                    243: 
                    244:     $Str .= '<tr>'."\n";
                    245:     $Str .= &CreateColumnSelectors($infoHeadings, $sequenceHeadings,
                    246:                                    $sequenceKeys);
                    247:     $Str .= '<td></td></tr>'."\n";
1.2       stredwic  248: 
1.4       stredwic  249:     $Str .= '<tr>'."\n";
1.2       stredwic  250:     my $displayString = '<td align="left"><pre><a href="/adm/statistics?';
                    251:     $displayString .= 'sort=LINKDATA">DISPLAYDATA</a>FORMATTING';
                    252:     $displayString .= $spacing.'</pre></td>'."\n";
1.17      minaeibi  253:     $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
1.2       stredwic  254:                                                    $infoKeys,
                    255:                                                    $infoHeadings,
                    256:                                                    $displayString,
                    257:                                                    'preformatted');
                    258: 
1.8       stredwic  259:     $displayString  = '<td align="left"><pre>DISPLAYDATAFORMATTING'.$spacing;
1.2       stredwic  260:     $displayString .= '</pre></td>'."\n";
                    261:     $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
                    262:                                                    $sequenceKeys,
                    263:                                                    $sequenceHeadings,
                    264:                                                    $displayString,
                    265:                                                    'preformatted');
                    266: 
                    267:     $Str .= '<td><pre>Total Solved/Total Problems</pre></td>';
                    268:     $Str .= '</tr></table>'."\n";
                    269: 
                    270:     return $Str;
                    271: }
                    272: 
                    273: =pod
                    274: 
                    275: =item &FormatStudentData()
                    276: 
                    277: First, FormatStudentInformation is called and prefixes the course information.
1.18      matthew   278: This function produces a formatted string of the student\'s course information.
1.2       stredwic  279: Each column of data represents all the problems for a given sequence.  For
                    280: valid grade data, a link is created for that problem to a submission record
                    281: for that problem.
                    282: 
                    283: =over 4
                    284: 
                    285: Input: $name, $studentInformation, $ChartDB
                    286: 
                    287: $name: The name and domain of the current student in name:domain format
                    288: 
                    289: $studentInformation: A pointer to an array holding the names used to 
                    290: remove data from the hash.  They represent 
                    291: the name of the data to be removed.
                    292: 
                    293: $ChartDB: The name of the cached data database which will be tied to that 
                    294: database.
                    295: 
                    296: Output: $Str
                    297: 
1.21    ! minaeibi  298: $Str: Formatted string that is an entire row of the chart.  It is a
1.2       stredwic  299: concatenation of student information and student course information.
                    300: 
                    301: =back
                    302: 
                    303: =cut
1.1       stredwic  304: 
                    305: sub StudentReport {
1.2       stredwic  306:     my ($cache,$name,$spacing,$showSequences)=@_;
                    307:     my ($username,$domain)=split(':',$name);
1.1       stredwic  308: 
                    309:     my $Str = '';
1.8       stredwic  310:     if(defined($cache->{$name.':error'})) {
1.10      stredwic  311:         return $Str;
1.8       stredwic  312:     }
1.1       stredwic  313:     if($cache->{$name.':error'} =~ /course/) {
                    314:         $Str .= '<b><font color="blue">No course data for student </font>';
                    315:         $Str .= '<font color="red">'.$username.'.</font></b><br>';
                    316:         return $Str;
                    317:     }
                    318: 
1.10      stredwic  319:     my $hasVersion = 'false';
                    320:     my $hasFinalData = 'false';
1.2       stredwic  321:     foreach my $sequence (@$showSequences) {
1.10      stredwic  322:         my $hasData = 'false';
1.2       stredwic  323:         my $characterCount=0;
1.1       stredwic  324:         foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
                    325:             my $problem = $cache->{$problemID.':problem'};
1.2       stredwic  326:             # All grades (except for versionless parts) are displayed as links
                    327:             # to their submission record.  Loop through all the parts for the
                    328:             # current problem in the correct order and prepare the output links
                    329:             foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
                    330:                                         ':parts'})) {
1.9       stredwic  331:                 if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
1.10      stredwic  332:                    $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
                    333:                    $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
1.8       stredwic  334:                     $Str .= ' ';
1.10      stredwic  335:                     $characterCount++;
1.8       stredwic  336:                     next;
1.2       stredwic  337:                 }
1.10      stredwic  338:                 $hasVersion = 'true';
                    339:                 $hasData = 'true';
1.18      matthew   340:                 if (lc($ENV{'form.displaymode'}) ne 'display without links') {
                    341:                     $Str .= '<a href="/adm/grades?symb=';
                    342:                     $Str .= &Apache::lonnet::escape($problem);
                    343:                     $Str .= '&student='.$username.'&domain='.$domain;
1.21    ! minaeibi  344:                     $Str .= '&command=submission">';
1.18      matthew   345:                 }
1.8       stredwic  346:                 my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
                    347:                 my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
                    348:                 if($code eq '*' && $tries < 10 && $tries ne '') {
                    349:                     $code = $tries;
1.2       stredwic  350:                 }
1.8       stredwic  351:                 $Str .= $code;
1.18      matthew   352:                 if (lc($ENV{'form.displaymode'}) ne 'display without links') {
                    353:                     $Str .= '</a>';
                    354:                 }
1.10      stredwic  355:                 $characterCount++;
1.2       stredwic  356:             }
                    357:         }
                    358: 
                    359:         # Output the number of correct answers for the current sequence.
1.17      minaeibi  360:         # This part takes up 6 character slots, but is formated right
                    361:         # justified.
                    362:         my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
                    363:         $spacesNeeded -= 3;
                    364:         $Str .= (' 'x$spacesNeeded);
                    365: 
                    366: #        my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
                    367: #							    ':problemsCorrect'});
                    368: 
                    369: 	my $outputProblemsCorrect = sprintf("%2d/%2d", $cache->{$name.':'.$sequence.
                    370:                                             ':problemsCorrect'},
                    371:                                             $characterCount);
                    372:         if($hasData eq 'true') {
                    373:             $Str .= '<font color="#007700">'.$outputProblemsCorrect.'</font>';
                    374:             $hasFinalData = 'true';
                    375:         } else {
                    376:             $Str .= '<font color="#007700">     </font>';
                    377:         }
                    378:         $Str .= $spacing;
                    379:     }
                    380: 
                    381:     # Output the total correct problems over the total number of problems.
                    382:     # I don't like this type of formatting, but it is a solution.  Need
                    383:     # a way to dynamically determine the space requirements.
                    384:     my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
                    385:     my $outputTotalProblems  = sprintf("%4d", $cache->{$name.':totalProblems'});
                    386:     if($hasFinalData eq 'true') {
                    387:         $Str .= '<font color="#000088">'.$outputProblemsSolved.
                    388: 	    ' / '.$outputTotalProblems.'</font>';
                    389:     } else {
                    390:         $Str .= '<font color="#000088">           </font>';
                    391:     }
                    392: 
                    393:     if($hasVersion eq 'false') {
                    394:         $Str = '<b><font color="blue">No course data.</font></b>';
                    395:     }
                    396: 
                    397:     return $Str;
                    398: }
                    399: 
                    400: 
                    401: sub StudentAverageTotal {
1.21    ! minaeibi  402:     my ($cache, $students, $sequenceKeys)=@_;
        !           403:     my $Str = "\nAverageTotal\n";
        !           404:     my %Correct = ();
        !           405:     my $ProblemsSolved = 0;
        !           406:     my $TotalProblems = 0;
        !           407:     my $StudentCount = 0;
        !           408: 
        !           409:     foreach my $name (@$students) {
        !           410:         $StudentCount++;
        !           411:         foreach my $sequence (@$sequenceKeys) {
        !           412:             $Correct{$cache->{$sequence.':title'}} +=
        !           413: 	        $cache->{$name.':'.$sequence.':problemsCorrect'};
1.17      minaeibi  414:         }
1.21    ! minaeibi  415: 	$ProblemsSolved += $cache->{$name.':problemsSolved'};
        !           416:         $TotalProblems += $cache->{$name.':totalProblems'};
1.1       stredwic  417:     }
1.21    ! minaeibi  418:     $ProblemsSolved /= $StudentCount;
        !           419:     $TotalProblems /= $StudentCount;
        !           420:     $Str .= "AvgSlvd:$ProblemsSolved  AvgTotal: $TotalProblems\n";
        !           421:     
        !           422:     foreach (%Correct) {
        !           423:         $Str .= "$_  : $Correct{$_}\n";
1.10      stredwic  424:     }
1.1       stredwic  425: 
                    426:     return $Str;
                    427: }
                    428: 
1.17      minaeibi  429: 
                    430: 
1.2       stredwic  431: =pod
                    432: 
                    433: =item &CreateLegend()
                    434: 
                    435: This function returns a formatted string containing the legend for the
                    436: chart.  The legend describes the symbols used to represent grades for
                    437: problems.
                    438: 
                    439: =cut
                    440: 
                    441: sub CreateLegend {
                    442:     my $Str = "<p><pre>".
1.13      minaeibi  443:               "   1  correct by student in 1 try\n".
                    444:               "   7  correct by student in 7 tries\n".
1.12      minaeibi  445:               "   *  correct by student in more than 9 tries\n".
1.20      minaeibi  446: 	      "   +  correct by hand grading or override\n".
1.12      minaeibi  447:               "   -  incorrect by override\n".
                    448: 	      "   .  incorrect attempted\n".
                    449: 	      "   #  ungraded attempted\n".
1.13      minaeibi  450:               "      not attempted (blank field)\n".
1.12      minaeibi  451: 	      "   x  excused".
1.17      minaeibi  452:               "</pre><p>";
1.2       stredwic  453:     return $Str;
                    454: }
                    455: 
                    456: =pod
                    457: 
                    458: =item &CreateColumnSelectionBox()
                    459: 
                    460: If there are columns not being displayed then this selection box is created
1.17      minaeibi  461: with a list of those columns.  When selections are made and the page
1.2       stredwic  462: refreshed, the columns will be removed from this box and the column is
                    463: put back in the chart.  If there is no columns to select, no row is added
                    464: to the interface table.
                    465: 
                    466: =over 4
                    467: Input: $CacheData, $headings
                    468: 
                    469: 
                    470: $CacheData: A pointer to a hash tied to the cached data
                    471: 
1.17      minaeibi  472: $headings:  An array of the names of the columns for the student information.
1.2       stredwic  473: They are used for displaying which columns are missing.
                    474: 
                    475: Output: $notThere
                    476: 
1.17      minaeibi  477: $notThere: The string contains one row of a table.  The first column has the
                    478: name of the selection box.  The second contains the selection box
1.2       stredwic  479: which has a size of four.
                    480: 
                    481: =back
                    482: 
                    483: =cut
                    484: 
                    485: sub CreateColumnSelectionBox {
1.4       stredwic  486:     my ($doNotShow)=@_;
1.2       stredwic  487: 
1.4       stredwic  488:     my $notThere = '';
                    489:     $notThere .= '<select name="ReselectColumns" size="4" ';
                    490:     $notThere .= 'multiple="true">'."\n";
                    491: 
                    492:     for(my $index=0; $index<$doNotShow->{'count'}; $index++) {
                    493:         my $name = $doNotShow->{$index.':name'};
                    494:         $notThere .= '<option value="';
                    495:         $notThere .= $doNotShow->{$index.':id'}.'">';
1.2       stredwic  496:         $notThere .= $name.'</option>'."\n";
                    497:     }
                    498: 
1.4       stredwic  499:     $notThere .= '</select>';
1.2       stredwic  500: 
1.4       stredwic  501:     return $notThere;
1.2       stredwic  502: }
                    503: 
                    504: =pod
                    505: 
                    506: =item &CreateColumnSelectors()
                    507: 
1.17      minaeibi  508: This function generates the checkboxes above the column headings.  The
1.2       stredwic  509: column will be removed if the checkbox is unchecked.
                    510: 
                    511: =over 4
                    512: 
                    513: Input: $CacheData, $headings
                    514: 
                    515: $CacheData: A pointer to a hash tied to the cached data
                    516: 
                    517: $headings:  An array of the names of the columns for the student 
                    518: information.  They are used to know what are the student information columns
                    519: 
                    520: Output: $present
                    521: 
                    522: $present: The string contains the first row of a table.  Each column contains
                    523: a checkbox which is left justified.  Currently left justification is used
                    524: for consistency of location over the column in which it presides.
                    525: 
                    526: =back
                    527: 
                    528: =cut
                    529: 
                    530: sub CreateColumnSelectors {
1.4       stredwic  531:     my ($infoHeadings, $sequenceHeadings, $sequenceKeys)=@_;
1.2       stredwic  532: 
1.4       stredwic  533:     my $present = '';
                    534:     for(my $index=0; $index<(scalar @$infoHeadings); $index++) {
1.2       stredwic  535:         $present .= '<td align="left">';
                    536:         $present .= '<input type="checkbox" checked="on" ';
1.4       stredwic  537:         $present .= 'name="HeadingColumn'.$infoHeadings->[$index].'" />';
                    538:         $present .= '</td>'."\n";
1.2       stredwic  539:     }
                    540: 
1.4       stredwic  541:     for(my $index=0; $index<(scalar @$sequenceHeadings); $index++) {
1.2       stredwic  542:         $present .= '<td align="left">';
                    543:         $present .= '<input type="checkbox" checked="on" ';
1.4       stredwic  544:         $present .= 'name="SequenceColumn'.$sequenceKeys->[$index].'" />';
                    545:         $present .= '</td>'."\n";
1.2       stredwic  546:     }
                    547: 
1.4       stredwic  548:     return $present;
1.2       stredwic  549: }
                    550: 
1.1       stredwic  551: #---- END Student Assessment Web Page ----------------------------------------
1.2       stredwic  552: 
                    553: #---- Student Assessment Worker Functions ------------------------------------
                    554: 
                    555: sub FindSelectedStudent {
                    556:     my($cache, $selectedName, $students)=@_;
1.3       stredwic  557: 
1.17      minaeibi  558:     if($selectedName eq 'All Students' ||
1.3       stredwic  559:        $selectedName eq 'No Student Selected') {
                    560:         return $selectedName;
                    561:     }
                    562: 
                    563:     for(my $index=0; $index<(scalar @$students); $index++) {
1.2       stredwic  564:         my $fullname = $cache->{$students->[$index].':fullname'};
                    565:         if($fullname eq $selectedName) {
                    566:             if($cache->{'StudentAssessmentMove'} eq 'next') {
                    567:                 if($index == ((scalar @$students) - 1)) {
                    568:                     $selectedName = $students->[0];
1.3       stredwic  569:                     return $selectedName;
1.2       stredwic  570:                 } else {
                    571:                     $selectedName = $students->[$index+1];
1.3       stredwic  572:                     return $selectedName;
1.2       stredwic  573:                 }
                    574:             } elsif($cache->{'StudentAssessmentMove'} eq 'previous') {
                    575:                 if($index == 0) {
                    576:                     $selectedName = $students->[-1];
1.3       stredwic  577:                     return $selectedName;
1.2       stredwic  578:                 } else {
                    579:                     $selectedName = $students->[$index-1];
1.3       stredwic  580:                     return $selectedName;
1.2       stredwic  581:                 }
                    582:             } else {
                    583:                 $selectedName = $students->[$index];
1.3       stredwic  584:                 return $selectedName;
1.2       stredwic  585:             }
                    586:             last;
                    587:         }
                    588:     }
                    589: 
1.3       stredwic  590:     return 'No Student Selected';
1.2       stredwic  591: }
                    592: 
                    593: =pod
                    594: 
                    595: =item &ShouldShowColumn()
                    596: 
                    597: Determine if a specified column should be shown on the chart.
                    598: 
                    599: =over 4
                    600: 
                    601: Input: $cache, $test
                    602: 
                    603: $cache: A pointer to the hash tied to the cached data
                    604: 
                    605: $test: The form name of the column (heading.$headingIndex) or 
                    606: (sequence.$sequenceIndex)
                    607: 
                    608: Output: 0 (false), 1 (true)
                    609: 
                    610: =back
                    611: 
                    612: =cut
                    613: 
                    614: sub ShouldShowColumns {
                    615:     my ($cache,$headings,$cacheKey)=@_;
                    616: 
                    617:     my @infoKeys=();
                    618:     my @infoHeadings=();
                    619: 
                    620:     my @sequenceKeys=();
                    621:     my @sequenceHeadings=();
                    622: 
1.4       stredwic  623:     my %doNotShow;
                    624: 
1.2       stredwic  625:     my $index;
1.4       stredwic  626:     my $count = 0;
                    627:     my $check = '';
1.2       stredwic  628:     for($index=0; $index < scalar @$headings; $index++) {
1.4       stredwic  629:         $check = 'HeadingColumn'.$headings->[$index];
                    630:         if($cache->{'HeadingsFound'} =~ /$check/) {
                    631:             push(@infoHeadings, $headings->[$index]);
                    632:             push(@infoKeys, $cacheKey->[$index]);
                    633:         } else {
                    634:             $doNotShow{$count.':name'} = $headings->[$index];
                    635:             $doNotShow{$count.':id'} = 'HeadingColumn'.$headings->[$index];
                    636:             $count++;
                    637:         }
1.2       stredwic  638:     }
                    639: 
                    640:     foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) {
1.4       stredwic  641:         $check = 'SequenceColumn'.$sequence;
1.21    ! minaeibi  642:         if($cache->{'SequencesFound'} eq 'All Sequences' ||
1.4       stredwic  643:            $cache->{'SequencesFound'} =~ /$check/) {
                    644:             push(@sequenceHeadings, $cache->{$sequence.':title'});
                    645:             push(@sequenceKeys, $sequence);
                    646:         } else {
                    647:             $doNotShow{$count.':name'} = $cache->{$sequence.':title'};
                    648:             $doNotShow{$count.':id'} = 'SequenceColumn'.$sequence;
                    649:             $count++;
                    650:         }
1.2       stredwic  651:     }
                    652: 
1.4       stredwic  653:     $doNotShow{'count'} = $count;
1.2       stredwic  654: 
1.21    ! minaeibi  655:     return (\@infoHeadings, \@infoKeys, \@sequenceHeadings,
1.4       stredwic  656:             \@sequenceKeys, \%doNotShow);
1.2       stredwic  657: }
                    658: 
                    659: #---- END Student Assessment Worker Functions --------------------------------
                    660: 
1.1       stredwic  661: 1;
                    662: __END__

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