version 1.3, 2004/08/19 21:08:46
|
version 1.4, 2004/08/25 15:55:17
|
Line 99 if (! defined($domain) || $domain eq '')
|
Line 99 if (! defined($domain) || $domain eq '')
|
## Set up logging code |
## Set up logging code |
my $logthis = \¬hing; |
my $logthis = \¬hing; |
if ($log) { |
if ($log) { |
my $logfile = "/tmp/parse_activity_log.log.".time; |
my $logfile = $perlvar{'lonDaemons'}.'/tmp/parse_activity_log.log.'.time; |
print STDERR "$0: logging to $logfile".$/; |
print STDERR "$0: logging to $logfile".$/; |
if (! open(LOGFILE,">$logfile")) { |
if (! open(LOGFILE,">$logfile")) { |
die "Unable to open $logfile for writing. Run aborted."; |
die "Unable to open $logfile for writing. Run aborted."; |
Line 183 my $res_table_def =
|
Line 183 my $res_table_def =
|
'PRIMARY KEY' => ['res_id'], |
'PRIMARY KEY' => ['res_id'], |
}; |
}; |
|
|
my $action_table = $prefix.'actions'; |
#my $action_table = $prefix.'actions'; |
my $action_table_def = |
#my $action_table_def = |
{ id => $action_table, |
#{ id => $action_table, |
permanent => 'no', |
# permanent => 'no', |
columns => [{ name => 'action_id', |
# columns => [{ name => 'action_id', |
type => 'MEDIUMINT UNSIGNED', |
# type => 'MEDIUMINT UNSIGNED', |
restrictions => 'NOT NULL', |
# restrictions => 'NOT NULL', |
auto_inc => 'yes', }, |
# auto_inc => 'yes', }, |
{ name => 'action', |
# { name => 'action', |
type => 'VARCHAR(100)', |
# type => 'VARCHAR(100)', |
restrictions => 'NOT NULL'}, |
# restrictions => 'NOT NULL'}, |
], |
# ], |
'PRIMARY KEY' => ['action_id',], |
# 'PRIMARY KEY' => ['action_id',], |
}; |
#}; |
|
|
my $machine_table = $prefix.'machine_table'; |
my $machine_table = $prefix.'machine_table'; |
my $machine_table_def = |
my $machine_table_def = |
Line 227 my $activity_table_def =
|
Line 227 my $activity_table_def =
|
{ name => 'student_id', |
{ name => 'student_id', |
type => 'MEDIUMINT UNSIGNED', |
type => 'MEDIUMINT UNSIGNED', |
restrictions => 'NOT NULL',}, |
restrictions => 'NOT NULL',}, |
{ name => 'action_id', |
{ name => 'action', |
type => 'MEDIUMINT UNSIGNED', |
type => 'VARCHAR(10)', |
restrictions => 'NOT NULL',}, |
restrictions => 'NOT NULL',}, |
{ name => 'idx', # This is here in case a student |
{ name => 'idx', # This is here in case a student |
type => 'MEDIUMINT UNSIGNED', # has multiple submissions during |
type => 'MEDIUMINT UNSIGNED', # has multiple submissions during |
Line 240 my $activity_table_def =
|
Line 240 my $activity_table_def =
|
{ name => 'action_values', |
{ name => 'action_values', |
type => 'MEDIUMTEXT', }, |
type => 'MEDIUMTEXT', }, |
], |
], |
'PRIMARY KEY' => ['res_id','time','student_id','action_id','idx'], |
'PRIMARY KEY' => ['time','student_id','res_id','idx'], |
|
'KEY' => [{columns => ['student_id']}, |
|
{columns => ['time']},], |
}; |
}; |
my @Activity_Table = ($activity_table_def); |
my @Activity_Table = ($activity_table_def); |
my @ID_Tables = ($student_table_def,$res_table_def, |
|
$action_table_def,$machine_table_def); |
#my @ID_Tables = ($student_table_def,$res_table_def, |
|
# $action_table_def,$machine_table_def); |
|
|
|
my @ID_Tables = ($student_table_def,$res_table_def,$machine_table_def); |
|
|
|
|
## |
## |
## End of table definitions |
## End of table definitions |
Line 443 sub process_courselog {
|
Line 448 sub process_courselog {
|
$time_this->('split_and_error_check'); |
$time_this->('split_and_error_check'); |
my $student_id = &get_id($student_table,'student',$student); |
my $student_id = &get_id($student_table,'student',$student); |
my $res_id = &get_id($res_table,'resource',$res); |
my $res_id = &get_id($res_table,'resource',$res); |
my $action_id = &get_id($action_table,'action',$action); |
# my $action_id = &get_id($action_table,'action',$action); |
my $sql_time = &Apache::lonmysql::sqltime($time); |
my $sql_time = &Apache::lonmysql::sqltime($time); |
# |
# |
if (! defined($student_id) || $student_id eq '') { |
if (! defined($student_id) || $student_id eq '') { |
Line 452 sub process_courselog {
|
Line 457 sub process_courselog {
|
if (! defined($res_id) || $res_id eq '') { |
if (! defined($res_id) || $res_id eq '') { |
$warningflag.='res_id'; |
$warningflag.='res_id'; |
} |
} |
if (! defined($action_id) || $action_id eq '') { |
# if (! defined($action_id) || $action_id eq '') { |
$warningflag.='action_id'; |
# $warningflag.='action_id'; |
} |
# } |
if ($warningflag ne '') { |
if ($warningflag ne '') { |
print $error_fh 'full log entry:'.$log.$/; |
print $error_fh 'full log entry:'.$log.$/; |
print $error_fh 'error on chunk:'.$chunk.$/; |
print $error_fh 'error on chunk:'.$chunk.$/; |
Line 470 sub process_courselog {
|
Line 475 sub process_courselog {
|
my $row = [$res_id, |
my $row = [$res_id, |
qq{'$sql_time'}, |
qq{'$sql_time'}, |
$student_id, |
$student_id, |
$action_id, |
"'".$action."'", |
|
# $action_id, |
qq{''}, # idx |
qq{''}, # idx |
$machine_id, |
$machine_id, |
$values]; |
$values]; |
Line 619 sub get_filename {
|
Line 625 sub get_filename {
|
sub create_tables { |
sub create_tables { |
foreach my $table (@ID_Tables,@Activity_Table) { |
foreach my $table (@ID_Tables,@Activity_Table) { |
my $table_id = &Apache::lonmysql::create_table($table); |
my $table_id = &Apache::lonmysql::create_table($table); |
|
# print STDERR "Unable to create table ".$table->{'id'}.$/; |
|
# print STDERR join($/,&Apache::lonmysql::build_table_creation_request($table)).$/; |
if (! defined($table_id)) { |
if (! defined($table_id)) { |
warn "Unable to create table ".$table->{'id'}.$/; |
warn "Unable to create table ".$table->{'id'}.$/; |
warn &Apache::lonmysql::build_table_creation_request($table).$/; |
warn join($/,&Apache::lonmysql::build_table_creation_request($table)).$/; |
return 0; |
return 0; |
} |
} |
} |
} |