version 1.25, 2007/12/07 22:31:08
|
version 1.37, 2012/03/15 21:54:58
|
Line 93 FULLTEXT idx_language (language),
|
Line 93 FULLTEXT idx_language (language),
|
FULLTEXT idx_owner (owner), |
FULLTEXT idx_owner (owner), |
FULLTEXT idx_copyright (copyright)) |
FULLTEXT idx_copyright (copyright)) |
|
|
TYPE=MYISAM; |
ENGINE=MYISAM; |
|
|
=cut |
=cut |
|
|
Line 356 sub create_metadata_storage {
|
Line 356 sub create_metadata_storage {
|
$col_des.="(".$coldata->{'size'}.")"; |
$col_des.="(".$coldata->{'size'}.")"; |
} |
} |
} |
} |
|
if (($tablename =~ /allusers/) && ($column eq 'username')) { |
|
$col_des .= ' CHARACTER SET latin1 COLLATE latin1_general_cs'; |
|
} |
# Modifiers |
# Modifiers |
if (exists($coldata->{'restrictions'})){ |
if (exists($coldata->{'restrictions'})){ |
$col_des.=" ".$coldata->{'restrictions'}; |
$col_des.=" ".$coldata->{'restrictions'}; |
Line 381 sub create_metadata_storage {
|
Line 384 sub create_metadata_storage {
|
$text .= 'idx_'.$colname.' ('.$colname.')'; |
$text .= 'idx_'.$colname.' ('.$colname.')'; |
push (@Columns,$text); |
push (@Columns,$text); |
} |
} |
$request .= "(".join(", ",@Columns).") TYPE=MyISAM"; |
$request .= "(".join(", ",@Columns).") ENGINE=MyISAM"; |
return $request; |
return $request; |
} |
} |
|
|
Line 460 sub store_metadata {
|
Line 463 sub store_metadata {
|
$mdata->{$fname} eq '') { |
$mdata->{$fname} eq '') { |
push(@MData,'NULL'); |
push(@MData,'NULL'); |
} else { |
} else { |
push(@MData,$mdata->{$fname}); |
push(@MData, $field->{type} eq 'DATETIME' ? |
|
sqltime($mdata->{$fname}) : $mdata->{$fname}); |
} |
} |
} else { |
} else { |
push(@MData,undef); |
push(@MData,undef); |
Line 756 sub process_reseval_data {
|
Line 760 sub process_reseval_data {
|
# |
# |
# Process every stored element |
# Process every stored element |
while (my ($storedkey,$value) = each(%{$evaldata})) { |
while (my ($storedkey,$value) = each(%{$evaldata})) { |
my ($source,$file,$type) = split('___',$storedkey); |
my (@keycomponents) = split('___',$storedkey); |
$source = &unescape($source); |
my $type=pop(@keycomponents); |
|
my $file=&unescape(pop(@keycomponents)); |
|
my $source = &unescape(join('___',@keycomponents)); |
$file = &unescape($file); |
$file = &unescape($file); |
$value = &unescape($value); |
$value = &unescape($value); |
" got ".$file."\n ".$type." ".$source."\n"; |
|
if ($type =~ /^(avetries|count|difficulty|stdno|timestamp)$/) { |
if ($type =~ /^(avetries|count|difficulty|stdno|timestamp)$/) { |
# |
# |
# Statistics: $source is course id |
# Statistics: $source is course id |
Line 915 sub process_dynamic_metadata {
|
Line 920 sub process_dynamic_metadata {
|
$data{$type.'_list'} = join(',',@{$resdata->{$type}}); |
$data{$type.'_list'} = join(',',@{$resdata->{$type}}); |
} |
} |
} |
} |
|
# |
|
# NOTE: usage is named sequsage elsewhere in LON-CAPA |
|
# The translation happens here |
|
# |
if (defined($resdata->{'usage'}) && |
if (defined($resdata->{'usage'}) && |
ref($resdata->{'usage'}) eq 'ARRAY') { |
ref($resdata->{'usage'}) eq 'ARRAY') { |
$data{'sequsage'} = scalar(@{$resdata->{'usage'}}); |
$data{'sequsage'} = scalar(@{$resdata->{'usage'}}); |
Line 935 sub process_dynamic_metadata {
|
Line 944 sub process_dynamic_metadata {
|
} |
} |
# |
# |
# put together comments |
# put together comments |
my $comments = '<div class="LCevalcomments">'; |
my $comments = ''; |
foreach my $evaluator (keys(%{$resdata->{'evaluation'}->{'comments'}})){ |
foreach my $evaluator (keys(%{$resdata->{'evaluation'}->{'comments'}})){ |
$comments .= |
$comments .= |
'<p>'. |
'<p>'. |
'<b>'.$evaluator.'</b>:'. |
'<b>'.$evaluator.'</b>: '. |
$resdata->{'evaluation'}->{'comments'}->{$evaluator}. |
$resdata->{'evaluation'}->{'comments'}->{$evaluator}. |
'</p>'; |
'</p>'; |
} |
} |
$comments .= '</div>'; |
if ($comments) { |
$data{'comments'} = $comments; |
$comments = '<div class="LCevalcomments">' |
|
.$comments |
|
.'</div>'; |
|
$data{'comments'} = $comments; |
|
} |
# |
# |
if (exists($resdata->{'stats'})) { |
if (exists($resdata->{'stats'})) { |
$data{'stats'} = $resdata->{'stats'}; |
$data{'stats'} = $resdata->{'stats'}; |
Line 962 sub dynamic_metadata_storage {
|
Line 975 sub dynamic_metadata_storage {
|
my $courseid = $data->{'course'}; |
my $courseid = $data->{'course'}; |
my $sections = $data->{'sections'}; |
my $sections = $data->{'sections'}; |
my $numstu = $data->{'num_students'}; |
my $numstu = $data->{'num_students'}; |
my $urlres = $data->{'urlres'}; |
my $part = $data->{'part'}; |
my $key = $courseid.'&'.$sections.'&'.$numstu.'___'.$urlres.'___stats'; |
my $symb = $data->{'symb'}; |
|
my $key = $courseid.'&'.$sections.'&'.$numstu.'&'.$part.'___'.$symb.'___stats'; |
$Store{$key} = |
$Store{$key} = |
'course='.$courseid.'&'. |
'course='.$courseid.'&'. |
'sections='.$sections.'&'. |
'sections='.$sections.'&'. |
'timestamp='.time.'&'. |
'timestamp='.time.'&'. |
'stdno='.$data->{'num_students'}.'&'. |
'part='.$part.'&'. |
|
'stdno='.$numstu.'&'. |
'avetries='.$data->{'mean_tries'}.'&'. |
'avetries='.$data->{'mean_tries'}.'&'. |
'difficulty='.$data->{'deg_of_diff'}; |
'difficulty='.$data->{'deg_of_diff'}.'&'. |
if (exists($data->{'deg_of_disc'})) { |
'disc='.$data->{'deg_of_disc'}; |
$Store{$key} .= '&'.'disc='.$data->{'deg_of_disc'}; |
|
} |
|
return %Store; |
return %Store; |
} |
} |
|
|
Line 1076 sub process_portfolio_access_data {
|
Line 1089 sub process_portfolio_access_data {
|
($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/); |
($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/); |
next if (($scope ne 'public') && ($scope ne 'guest')); |
next if (($scope ne 'public') && ($scope ne 'guest')); |
$acc_data->{scope} = $scope; |
$acc_data->{scope} = $scope; |
|
my $sqltime_error; |
if ($end != 0) { |
if ($end != 0) { |
$acc_data->{end} = &sqltime($end); |
$acc_data->{end} = &sqltime($end,\$sqltime_error); |
|
} |
|
$acc_data->{start} = &sqltime($start,\$sqltime_error); |
|
if ($sqltime_error) { |
|
$loghash{$key}{'err'} = $sqltime_error; |
} |
} |
$acc_data->{start} = &sqltime($start); |
|
if (! $simulate) { |
if (! $simulate) { |
my ($count,$err) = |
my ($count,$err) = |
&store_metadata($dbh,$newnames->{'access'}, |
&store_metadata($dbh,$newnames->{'access'}, |
Line 1123 sub process_portfolio_metadata {
|
Line 1140 sub process_portfolio_metadata {
|
if (-e $fullpath) { |
if (-e $fullpath) { |
my ($ref,$crs,$addedfields) = &portfolio_metadata($fullpath,$dom,$uname, |
my ($ref,$crs,$addedfields) = &portfolio_metadata($fullpath,$dom,$uname, |
$group); |
$group); |
&getfiledates($ref,$fullpath); |
my $sqltime_error; |
|
&getfiledates($ref,$fullpath,\$sqltime_error); |
if ($is_course) { |
if ($is_course) { |
$ref->{'groupname'} = $group; |
$ref->{'groupname'} = $group; |
} |
} |
Line 1138 sub process_portfolio_metadata {
|
Line 1156 sub process_portfolio_metadata {
|
); |
); |
my %loghash; |
my %loghash; |
if (! $simulate) { |
if (! $simulate) { |
|
if ($sqltime_error) { |
|
$loghash{'metadata'."\0"}{'err'} = $sqltime_error; |
|
} |
my ($count,$err) = |
my ($count,$err) = |
&store_metadata($dbh,$newnames->{'portfolio'},'portfolio_metadata', |
&store_metadata($dbh,$newnames->{'portfolio'},'portfolio_metadata', |
\%Data); |
\%Data); |
Line 1229 sub getfile {
|
Line 1250 sub getfile {
|
} |
} |
|
|
## |
## |
## &getfiledates() |
## &getfiledates($ref,$target,$sqltime_error) |
## Converts creationdate and modifieddates to SQL format |
## Converts creationdate and modifieddates to SQL format |
## Applies stat() to file to retrieve dates if missing |
## Applies stat() to file to retrieve dates if missing |
sub getfiledates { |
sub getfiledates { |
my ($ref,$target) = @_; |
my ($ref,$target,$sqltime_error) = @_; |
if (! defined($ref->{'creationdate'}) || |
if (! defined($ref->{'creationdate'}) || |
$ref->{'creationdate'} =~ /^\s*$/) { |
$ref->{'creationdate'} =~ /^\s*$/) { |
$ref->{'creationdate'} = (stat($target))[9]; |
$ref->{'creationdate'} = (stat($target))[9]; |
Line 1242 sub getfiledates {
|
Line 1263 sub getfiledates {
|
$ref->{'lastrevisiondate'} =~ /^\s*$/) { |
$ref->{'lastrevisiondate'} =~ /^\s*$/) { |
$ref->{'lastrevisiondate'} = (stat($target))[9]; |
$ref->{'lastrevisiondate'} = (stat($target))[9]; |
} |
} |
$ref->{'creationdate'} = &sqltime($ref->{'creationdate'}); |
$ref->{'creationdate'} = &sqltime($ref->{'creationdate'},$sqltime_error); |
$ref->{'lastrevisiondate'} = &sqltime($ref->{'lastrevisiondate'}); |
$ref->{'lastrevisiondate'} = &sqltime($ref->{'lastrevisiondate'},$sqltime_error); |
} |
} |
|
|
## |
## |
## &sqltime($timestamp) |
## &sqltime($timestamp,$sqltime_error) |
## |
## |
## Convert perl $timestamp to MySQL time. MySQL expects YYYY-MM-DD HH:MM:SS |
## Convert perl $timestamp to MySQL time. MySQL expects YYYY-MM-DD HH:MM:SS |
## |
## |
sub sqltime { |
sub sqltime { |
my ($time) = @_; |
my ($time,$sqltime_error) = @_; |
my $mysqltime; |
my $mysqltime; |
if ($time =~ |
if ($time =~ |
/(\d+)-(\d+)-(\d+) # YYYY-MM-DD |
/(\d+)-(\d+)-(\d+) # YYYY-MM-DD |
Line 1275 sub sqltime {
|
Line 1296 sub sqltime {
|
} elsif (! defined($time) || $time == 0) { |
} elsif (! defined($time) || $time == 0) { |
$mysqltime = 0; |
$mysqltime = 0; |
} else { |
} else { |
&log(0," sqltime:Unable to decode time ".$time); |
if (ref($sqltime_error) eq 'SCALAR') { |
|
$$sqltime_error = "sqltime:Unable to decode time ".$time; |
|
} |
$mysqltime = 0; |
$mysqltime = 0; |
} |
} |
return $mysqltime; |
return $mysqltime; |