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

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

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