--- loncom/metadata_database/LONCAPA/lonmetadata.pm 2011/05/31 14:45:53 1.33 +++ loncom/metadata_database/LONCAPA/lonmetadata.pm 2012/03/15 23:01:59 1.38 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonmetadata.pm,v 1.33 2011/05/31 14:45:53 raeburn Exp $ +# $Id: lonmetadata.pm,v 1.38 2012/03/15 23:01:59 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -463,7 +463,8 @@ sub store_metadata { $mdata->{$fname} eq '') { push(@MData,'NULL'); } else { - push(@MData,$mdata->{$fname}); + push(@MData, $field->{type} eq 'DATETIME' ? + sqltime($mdata->{$fname}) : $mdata->{$fname}); } } else { push(@MData,undef); @@ -759,11 +760,12 @@ sub process_reseval_data { # # Process every stored element while (my ($storedkey,$value) = each(%{$evaldata})) { - my ($source,$file,$type) = split('___',$storedkey); - $source = &unescape($source); + my (@keycomponents) = split('___',$storedkey); + my $type=pop(@keycomponents); + my $file=&unescape(pop(@keycomponents)); + my $source = &unescape(join('___',@keycomponents)); $file = &unescape($file); $value = &unescape($value); - " got ".$file."\n ".$type." ".$source."\n"; if ($type =~ /^(avetries|count|difficulty|stdno|timestamp)$/) { # # Statistics: $source is course id @@ -786,8 +788,8 @@ sub process_reseval_data { # $source is $cid\_$sec\_$stdno # $value is stat1=value&stat2=value&stat3=value,.... # - my ($cid,$sec,$stdno)=split('&',$source); - my $crssec = $cid.'&'.$sec; + my ($cid,$sec,$stdno,$part,$instance)=split('&',$source); + my $datakey = $cid.'&'.$sec.'&'.$part.'&'.$instance; my @Data = split('&',$value); my %Statistics; while (my ($key,$value) = split('=',pop(@Data))) { @@ -798,9 +800,9 @@ sub process_reseval_data { # # Only store the data if the number of students is greater # than the data already stored - if (! exists($DynamicData{$file}->{'stats'}->{$crssec}) || - $DynamicData{$file}->{'stats'}->{$crssec}->{'stdno'}<$stdno){ - $DynamicData{$file}->{'stats'}->{$crssec}=\%Statistics; + if (! exists($DynamicData{$file}->{'stats'}->{$datakey}) || + $DynamicData{$file}->{'stats'}->{$datakey}->{'stdno'}<$stdno){ + $DynamicData{$file}->{'stats'}->{$datakey}=\%Statistics; } } } @@ -918,6 +920,10 @@ sub process_dynamic_metadata { $data{$type.'_list'} = join(',',@{$resdata->{$type}}); } } +# +# NOTE: usage is named sequsage elsewhere in LON-CAPA +# The translation happens here +# if (defined($resdata->{'usage'}) && ref($resdata->{'usage'}) eq 'ARRAY') { $data{'sequsage'} = scalar(@{$resdata->{'usage'}}); @@ -969,18 +975,18 @@ sub dynamic_metadata_storage { my $courseid = $data->{'course'}; my $sections = $data->{'sections'}; my $numstu = $data->{'num_students'}; - my $urlres = $data->{'urlres'}; - my $key = $courseid.'&'.$sections.'&'.$numstu.'___'.$urlres.'___stats'; + my $part = $data->{'part'}; + my $symb = $data->{'symb'}; + my $key = $courseid.'&'.$sections.'&'.$numstu.'&'.$part.'&'.$symb.'___stats'; $Store{$key} = 'course='.$courseid.'&'. 'sections='.$sections.'&'. 'timestamp='.time.'&'. - 'stdno='.$data->{'num_students'}.'&'. + 'part='.$part.'&'. + 'stdno='.$numstu.'&'. 'avetries='.$data->{'mean_tries'}.'&'. - 'difficulty='.$data->{'deg_of_diff'}; - if (exists($data->{'deg_of_disc'})) { - $Store{$key} .= '&'.'disc='.$data->{'deg_of_disc'}; - } + 'difficulty='.$data->{'deg_of_diff'}.'&'. + 'disc='.$data->{'deg_of_disc'}; return %Store; }