Diff for /loncom/interface/statistics/lonstudentassessment.pm between versions 1.3 and 1.6

version 1.3, 2002/07/26 16:22:09 version 1.6, 2002/08/01 20:49:06
Line 42  use Apache::lonhtmlcommon; Line 42  use Apache::lonhtmlcommon;
 use Apache::loncoursedata;  use Apache::loncoursedata;
 use GDBM_File;  use GDBM_File;
   
   #my $jr;
   
 sub BuildStudentAssessmentPage {  sub BuildStudentAssessmentPage {
     my ($cacheDB,$students,$courseID,$formName,$headings,$spacing,      my ($cacheDB,$students,$courseID,$formName,$headings,$spacing,
         $studentInformation,$r,$c)=@_;          $studentInformation,$r,$c)=@_;
   #    $jr = $r;
     my %cache;      my %cache;
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {      unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
         $r->print('<html><body>Unable to tie database.</body></html>');          $r->print('<html><body>Unable to tie database.</body></html>');
         return;          return;
     }      }
Line 75  sub BuildStudentAssessmentPage { Line 77  sub BuildStudentAssessmentPage {
             splice(@$students, $studentIndex, 1);              splice(@$students, $studentIndex, 1);
         }          }
     }      }
       my ($infoHeadings, $infoKeys, $sequenceHeadings, $sequenceKeys,
           $doNotShow) = 
           &ShouldShowColumns(\%cache, $headings, $studentInformation);
   
     my $selectedName = &FindSelectedStudent(\%cache,       my $selectedName = &FindSelectedStudent(\%cache, 
                                             $cache{'StudentAssessmentStudent'},                                              $cache{'StudentAssessmentStudent'},
                                             $students);                                              $students);
     $r->print(&CreateInterface(\%cache, $selectedName, $students, $formName));      $r->print(&CreateInterface(\%cache, $selectedName, $students, $formName,
                                  $doNotShow));
   
     my $Ptr = '';      my $Str = '';
     if($selectedName eq 'No Student Selected') {      if($selectedName eq 'No Student Selected') {
  $Ptr .= '<h3><font color=blue>WARNING: ';   $Str .= '<h3><font color=blue>WARNING: ';
         $Ptr .= 'Please select a student</font></h3>';          $Str .= 'Please select a student</font></h3>';
         $r->print($Ptr);          $r->print($Str);
         return;          return;
     }      }
   
     my ($infoHeadings, $infoKeys, $sequenceHeadings, $sequenceKeys) =   
         &ShouldShowColumns(\%cache, $headings, $studentInformation);  
   
     $r->print(&CreateTableHeadings(\%cache, $spacing, $infoKeys, $infoHeadings,      $r->print(&CreateTableHeadings(\%cache, $spacing, $infoKeys, $infoHeadings,
                                    $sequenceKeys, $sequenceHeadings));                                     $sequenceKeys, $sequenceHeadings));
     untie(%cache);      untie(%cache);
       if($c->aborted()) {  return $Str; }
   
     my $selected=0;      my $selected=0;
     $r->print('<pre>'."\n");      $r->print('<pre>'."\n");
     foreach (@$students) {      foreach (@$students) {
           if($c->aborted()) {  return $Str; }
         next if ($_ ne $selectedName &&           next if ($_ ne $selectedName && 
                  $selectedName ne 'All Students');                   $selectedName ne 'All Students');
         $selected = 1;          $selected = 1;
         my $courseData;           my $courseData; 
         if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {          my $downloadTime='';
             if($cache{$_.':lastDownloadTime'} eq 'Not downloaded') {          if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
                 untie(%cache);              $downloadTime = $cache{$_.':lastDownloadTime'};
                 $courseData =               untie(%cache);
                     &Apache::loncoursedata::DownloadCourseInformation($_,           }
                                                                     $courseID);          if($downloadTime eq 'Not downloaded') {
                 if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {              $courseData = 
                     &Apache::loncoursedata::ProcessStudentData(\%cache,                   &Apache::loncoursedata::DownloadCourseInformation($_, 
                                                              $courseData, $_);                                                                    $courseID);
                     untie(%cache);              unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
                 } else {                  next;
                     last if($c->aborted());  
                     next;  
                 }  
             } else {  
                 untie(%cache);  
             }              }
         } else {              &Apache::loncoursedata::ProcessStudentData(\%cache, 
             last if($c->aborted());                                                         $courseData, $_);
             next;              untie(%cache);
         }          }
   
         last if ($c->aborted());          next if($c->aborted());
   
         if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {          if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
             my $displayString = 'DISPLAYDATA'.$spacing;              my $displayString = 'DISPLAYDATA'.$spacing;
             $r->print(&Apache::lonhtmlcommon::FormatStudentInformation(              $r->print(&Apache::lonhtmlcommon::FormatStudentInformation(
                                                          \%cache, $_,                                                           \%cache, $_,
Line 141  sub BuildStudentAssessmentPage { Line 141  sub BuildStudentAssessmentPage {
     }      }
     $r->print('</pre>'."\n");      $r->print('</pre>'."\n");
     if($selected == 0) {      if($selected == 0) {
  $Ptr .= '<h3><font color=blue>WARNING: ';   $Str .= '<h3><font color=blue>WARNING: ';
         $Ptr .= 'Please select a student</font></h3>';          $Str .= 'Please select a student</font></h3>';
         $r->print($Ptr);          $r->print($Str);
     }      }
   
     return;      return;
Line 152  sub BuildStudentAssessmentPage { Line 152  sub BuildStudentAssessmentPage {
 #---- Student Assessment Web Page --------------------------------------------  #---- Student Assessment Web Page --------------------------------------------
   
 sub CreateInterface {  sub CreateInterface {
     my($cache,$selectedName,$students,$formName)=@_;      my($cache,$selectedName,$students,$formName,$doNotShow)=@_;
     my $Ptr = '';  
     $Ptr .= &CreateLegend();      my $Str = '';
     $Ptr .= '<table><tr><td>'."\n";      $Str .= &CreateLegend();
     $Ptr .= '<input type="submit" name="PreviousStudent" ';      $Str .= '<table><tr><td>'."\n";
     $Ptr .= 'value="Previous Student" />'."\n";      $Str .= '<input type="submit" name="PreviousStudent" ';
     $Ptr .= '&nbsp&nbsp&nbsp'."\n";      $Str .= 'value="Previous Student" />'."\n";
     $Ptr .= &Apache::lonhtmlcommon::StudentOptions($cache, $students,       $Str .= '&nbsp&nbsp&nbsp'."\n";
       $Str .= &Apache::lonhtmlcommon::StudentOptions($cache, $students, 
                                                    $selectedName,                                                      $selectedName, 
                                                    'StudentAssessment',                                                      'StudentAssessment', 
                                                    $formName);                                                     $formName);
     $Ptr .= "\n".'&nbsp&nbsp&nbsp'."\n";      $Str .= "\n".'&nbsp&nbsp&nbsp'."\n";
     $Ptr .= '<input type="submit" name="NextStudent" ';      $Str .= '<input type="submit" name="NextStudent" ';
     $Ptr .= 'value="Next Student" />'."\n";      $Str .= 'value="Next Student" />'."\n";
     $Ptr .= '</td></tr></table>'."\n";      $Str .= '</td></tr></table>'."\n";
     $Ptr .= '<table><tr><td align="center"><b>Select Sections</b>';      $Str .= '<table cellspacing="5"><tr>'."\n";
     $Ptr .= '</td></tr>'."\n";      $Str .= '<td align="center"><b>Select Sections</b>'."\n";
       $Str .= '</td>'."\n";
       $Str .= '<td align="center"><b>Select column to view:</b></td>'."\n";
       $Str .= '<td></td></tr>'."\n";
   
     $Ptr .= '<tr><td align="center">'."\n";      $Str .= '<tr><td align="center">'."\n";
     my @sections = split(':',$cache->{'sectionList'});      my @sections = split(':',$cache->{'sectionList'});
     my @selectedSections = split(':',$cache->{'sectionsSelected'});      my @selectedSections = split(':',$cache->{'sectionsSelected'});
     $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,      $Str .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
                                                           \@selectedSections,                                                            \@selectedSections,
                                                           'Statistics');                                                            'Statistics');
     $Ptr .= '</td></tr></table>'."\n";      $Str .= '</td><td align="center">';
       $Str .= &CreateColumnSelectionBox($doNotShow);
       $Str .= '</td><td>'."\n";
       $Str .= '<input type="submit" name="DefaultColumns" ';
       $Str .= 'value="Default Column Display" />'."\n";
       $Str .= '</td></tr></table>'."\n";
   
     return $Ptr;      return $Str;
 }  }
   
 sub CreateTableHeadings {  sub CreateTableHeadings {
Line 186  sub CreateTableHeadings { Line 195  sub CreateTableHeadings {
        $sequenceHeadings)=@_;         $sequenceHeadings)=@_;
   
     my $Str = '';      my $Str = '';
     $Str .= '<table border="0" cellpadding="0" cellspacing="0"><tr>'."\n";      $Str .= '<table border="0" cellpadding="0" cellspacing="0">'."\n";
   
       $Str .= '<tr>'."\n";
       $Str .= &CreateColumnSelectors($infoHeadings, $sequenceHeadings,
                                      $sequenceKeys);
       $Str .= '<td></td></tr>'."\n";
   
       $Str .= '<tr>'."\n";
     my $displayString = '<td align="left"><pre><a href="/adm/statistics?';      my $displayString = '<td align="left"><pre><a href="/adm/statistics?';
     $displayString .= 'sort=LINKDATA">DISPLAYDATA</a>FORMATTING';      $displayString .= 'sort=LINKDATA">DISPLAYDATA</a>FORMATTING';
     $displayString .= $spacing.'</pre></td>'."\n";      $displayString .= $spacing.'</pre></td>'."\n";
Line 433  which has a size of four. Line 448  which has a size of four.
 =cut  =cut
   
 sub CreateColumnSelectionBox {  sub CreateColumnSelectionBox {
     my ($CacheData,$headings)=@_;      my ($doNotShow)=@_;
   
     my $missing=0;      my $notThere = '';
     my $notThere='<tr><td align="right"><b>Select column to view:</b>';      $notThere .= '<select name="ReselectColumns" size="4" ';
     my $name;      $notThere .= 'multiple="true">'."\n";
     $notThere .= '<td align="left">';  
     $notThere .= '<select name="ChartReselect" size="4" multiple="true">'."\n";      for(my $index=0; $index<$doNotShow->{'count'}; $index++) {
           my $name = $doNotShow->{$index.':name'};
     for(my $index=0; $index<(scalar @$headings); $index++) {          $notThere .= '<option value="';
         if(&ShouldShowColumn($CacheData, 'ChartHeading'.$index)) {          $notThere .= $doNotShow->{$index.':id'}.'">';
             next;  
         }  
         $name = $headings->[$index];  
         $notThere .= '<option value="ChartHeading'.$index.'">';  
         $notThere .= $name.'</option>'."\n";          $notThere .= $name.'</option>'."\n";
         $missing++;  
     }      }
   
     foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) {      $notThere .= '</select>';
         if(&ShouldShowColumn($CacheData, 'ChartSequence'.$sequence)) {  
             next;  
         }  
         $name = $CacheData->{$sequence.':title'};  
         $notThere .= '<option value="ChartSequence'.$sequence.'">';  
         $notThere .= $name.'</option>'."\n";  
         $missing++;  
     }  
   
     if($missing) {      return $notThere;
         $notThere .= '</select>';  
     } else {  
         $notThere='<tr><td>';  
     }  
   
     return $notThere.'</td></tr>';  
 }  }
   
 =pod  =pod
Line 497  for consistency of location over the col Line 493  for consistency of location over the col
 =cut  =cut
   
 sub CreateColumnSelectors {  sub CreateColumnSelectors {
     my ($headings)=@_;      my ($infoHeadings, $sequenceHeadings, $sequenceKeys)=@_;
 =pod  
     my $found=0;  
     my ($name, $length, $position);  
   
     my $present = '<tr>';      my $present = '';
     for(my $index=0; $index<(scalar @$headings); $index++) {      for(my $index=0; $index<(scalar @$infoHeadings); $index++) {
         $present .= '<td align="left">';          $present .= '<td align="left">';
         $present .= '<input type="checkbox" checked="on" ';          $present .= '<input type="checkbox" checked="on" ';
         $present .= 'name="ChartHeading'.$index.'" />';          $present .= 'name="HeadingColumn'.$infoHeadings->[$index].'" />';
         $present .= '</td>';          $present .= '</td>'."\n";
         $found++;  
     }      }
   
     foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) {      for(my $index=0; $index<(scalar @$sequenceHeadings); $index++) {
         if(!&ShouldShowColumn($CacheData, 'ChartSequence'.$sequence)) {  
             next;  
         }  
         $present .= '<td align="left">';          $present .= '<td align="left">';
         $present .= '<input type="checkbox" checked="on" ';          $present .= '<input type="checkbox" checked="on" ';
         $present .= 'name="ChartSequence'.$sequence.'" />';          $present .= 'name="SequenceColumn'.$sequenceKeys->[$index].'" />';
         $present .= '</td>';          $present .= '</td>'."\n";
         $found++;  
     }      }
   
     if(!$found) {      return $present;
         $present = '';  
     }  
   
     return $present.'<td></td></tr></form>'."\n";;  
 =cut  
 }  }
   
 #---- END Student Assessment Web Page ----------------------------------------  #---- END Student Assessment Web Page ----------------------------------------
Line 602  sub ShouldShowColumns { Line 585  sub ShouldShowColumns {
     my @sequenceKeys=();      my @sequenceKeys=();
     my @sequenceHeadings=();      my @sequenceHeadings=();
   
       my %doNotShow;
   
     my $index;      my $index;
       my $count = 0;
       my $check = '';
     for($index=0; $index < scalar @$headings; $index++) {      for($index=0; $index < scalar @$headings; $index++) {
         push(@infoHeadings, $headings->[$index]);          $check = 'HeadingColumn'.$headings->[$index];
         push(@infoKeys, $cacheKey->[$index]);          if($cache->{'HeadingsFound'} =~ /$check/) {
               push(@infoHeadings, $headings->[$index]);
               push(@infoKeys, $cacheKey->[$index]);
           } else {
               $doNotShow{$count.':name'} = $headings->[$index];
               $doNotShow{$count.':id'} = 'HeadingColumn'.$headings->[$index];
               $count++;
           }
     }      }
   
     foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) {      foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) {
         push(@sequenceHeadings, $cache->{$sequence.':title'});          $check = 'SequenceColumn'.$sequence;
         push(@sequenceKeys, $sequence);          if($cache->{'SequencesFound'} eq 'All Sequences' || 
              $cache->{'SequencesFound'} =~ /$check/) {
               push(@sequenceHeadings, $cache->{$sequence.':title'});
               push(@sequenceKeys, $sequence);
           } else {
               $doNotShow{$count.':name'} = $cache->{$sequence.':title'};
               $doNotShow{$count.':id'} = 'SequenceColumn'.$sequence;
               $count++;
           }
     }      }
   
 #    my $headings=$cache->{'form.ChartHeadings'};      $doNotShow{'count'} = $count;
 #    my $sequences=$cache->{'form.ChartSequences'};  
 #    if($headings eq 'ALLHEADINGS' || $sequences eq 'ALLSEQUENCES' ||  
 #       $headings=~/$test/ || $sequences=~/$test/) {  
 #        return 1;  
 #    }  
   
     return (\@infoHeadings, \@infoKeys, \@sequenceHeadings,       return (\@infoHeadings, \@infoKeys, \@sequenceHeadings, 
             \@sequenceKeys);              \@sequenceKeys, \%doNotShow);
 }  }
   
 #---- END Student Assessment Worker Functions --------------------------------  #---- END Student Assessment Worker Functions --------------------------------

Removed from v.1.3  
changed lines
  Added in v.1.6


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