Diff for /loncom/metadata_database/searchcat.pl between versions 1.56 and 1.57

version 1.56, 2004/04/09 22:04:53 version 1.57, 2004/04/12 21:11:45
Line 144  if ($wwwid!=$<) { Line 144  if ($wwwid!=$<) {
 # Let people know we are running  # Let people know we are running
 open(LOG,'>'.$perlvar{'lonDaemons'}.'/logs/searchcat.log');  open(LOG,'>'.$perlvar{'lonDaemons'}.'/logs/searchcat.log');
 &log(0,'==== Searchcat Run '.localtime()."====");  &log(0,'==== Searchcat Run '.localtime()."====");
   
   
 if ($debug) {  if ($debug) {
     &log(0,'simulating') if ($simulate);      &log(0,'simulating') if ($simulate);
     &log(0,'only processing user '.$oneuser) if ($oneuser);      &log(0,'only processing user '.$oneuser) if ($oneuser);
Line 305  sub log_metadata { Line 307  sub log_metadata {
     $_=$file;      $_=$file;
 }  }
   
   
 ##  ##
 ## process_meta_file  ## process_meta_file
 ##   Called by File::Find.   ##   Called by File::Find. 
Line 358  sub process_meta_file { Line 359  sub process_meta_file {
                                                                  \%Data);                                                                   \%Data);
         if ($err) {          if ($err) {
             &log(0,"MySQL Error Insert: ".$err);              &log(0,"MySQL Error Insert: ".$err);
             die $err;  
         }          }
         if ($count < 1) {          if ($count < 1) {
             &log(0,"Unable to insert record into MySQL database for $url");              &log(0,"Unable to insert record into MySQL database for $url");
             die "Unable to insert record into MySQl database for $url";  
         }          }
     }      }
     #      #
Line 491  sub process_dynamic_metadata { Line 490  sub process_dynamic_metadata {
         return 0;          return 0;
     }      }
     #      #
     # Process every stored element      %DynamicData = &LONCAPA::lonmetadata::process_reseval_data(\%evaldata);
     while (my ($storedkey,$value) = each(%evaldata)) {  
         my ($source,$file,$type) = split('___',$storedkey);  
         $source = &unescape($source);  
         $file = &unescape($file);  
         $value = &unescape($value);  
          "    got ".$file."\n        ".$type." ".$source."\n";  
         if ($type =~ /^(avetries|count|difficulty|stdno|timestamp)$/) {  
             #  
             # Statistics: $source is course id  
             $DynamicData{$file}->{'statistics'}->{$source}->{$type}=$value;  
         } elsif ($type =~ /^(clear|comments|depth|technical|helpful)$/){  
             #  
             # Evaluation $source is username, check if they evaluated it  
             # more than once.  If so, pad the entry with a space.  
             while(exists($DynamicData{$file}->{'evaluation'}->{$type}->{$source})) {  
                 $source .= ' ';  
             }  
             $DynamicData{$file}->{'evaluation'}->{$type}->{$source}=$value;  
         } elsif ($type =~ /^(course|comefrom|goto|usage)$/) {  
             #  
             # Context $source is course id or resource  
             push(@{$DynamicData{$file}->{$type}},&unescape($source));  
         } else {  
             &log(0,"   ".$user."@".$dom.":Process metadata: Unable to decode ".$type);  
         }  
     }  
     untie(%evaldata);      untie(%evaldata);
     #      #
     # Read in the access count data      # Read in the access count data
Line 551  sub get_dynamic_metadata { Line 524  sub get_dynamic_metadata {
         &log(7,'    No dynamic data for '.$url) if ($debug);          &log(7,'    No dynamic data for '.$url) if ($debug);
         return ();          return ();
     }      }
     my %data;      my %data = &LONCAPA::lonmetadata::process_dynamic_metadata($url,
     my $resdata = $DynamicData{$url};                                                                 \%DynamicData);
     #  
     # Get the statistical data  
     foreach my $type (qw/avetries difficulty stdno/) {  
         my $count;  
         my $sum;  
         my @Values;  
         foreach my $coursedata (values(%{$resdata->{'statistics'}})) {  
             if (ref($coursedata) eq 'HASH' && exists($coursedata->{$type})) {  
                 $count++;  
                 $sum += $coursedata->{$type};  
                 push(@Values,$coursedata->{$type});  
             }  
         }  
         if ($count) {  
             $data{$type} = $sum/$count;  
             $data{$type.'_list'} = join(',',@Values);  
         }  
     }  
     # find the count      # find the count
     $data{'count'} = $Counts{$url};      $data{'count'} = $Counts{$url};
     #      #
     # Get the context data  
     foreach my $type (qw/course goto comefrom/) {  
         if (defined($resdata->{$type}) &&   
             ref($resdata->{$type}) eq 'ARRAY') {  
             $data{$type} = scalar(@{$resdata->{$type}});  
             $data{$type.'_list'} = join(',',@{$resdata->{$type}});  
         }  
     }  
     if (defined($resdata->{'usage'}) &&   
         ref($resdata->{'usage'}) eq 'ARRAY') {  
         $data{'sequsage'} = scalar(@{$resdata->{'usage'}});  
         $data{'sequsage_list'} = join(',',@{$resdata->{'usage'}});  
     }  
     #  
     # Get the evaluation data  
     foreach my $type (qw/clear technical correct helpful depth/) {  
         my $count;  
         my $sum;  
         foreach my $evaluator (keys(%{$resdata->{'evaluation'}->{$type}})){  
             $sum += $resdata->{'evaluation'}->{$type}->{$evaluator};  
             $count++;  
         }  
         if ($count > 0) {  
             $data{$type}=$sum/$count;  
         }  
     }  
     #  
     # put together comments  
     my $comments = '<div class="LCevalcomments">';  
     foreach my $evaluator (keys(%{$resdata->{'evaluation'}->{'comments'}})){  
         $comments .= $evaluator.':'.  
             $resdata->{'evaluation'}->{'comments'}->{$evaluator}.'<hr />';  
     }  
     $comments .= '</div>';  
     #  
     # Log the dynamic metadata      # Log the dynamic metadata
     if ($debug) {      if ($debug) {
         while (my($k,$v)=each(%data)) {          while (my($k,$v)=each(%data)) {
             &log(8,"    ".$k." => ".$v);              &log(8,"    ".$k." => ".$v);
         }          }
     }      }
     #  
     return %data;      return %data;
 }  }
   

Removed from v.1.56  
changed lines
  Added in v.1.57


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