version 1.96, 2003/09/30 15:47:40
|
version 1.99, 2003/10/02 17:07:41
|
Line 1072 sub get_student {
|
Line 1072 sub get_student {
|
|
|
=pod |
=pod |
|
|
|
=item &clear_internal_caches() |
|
|
|
Causes the internal caches used in get_student_id, get_student, |
|
get_symb_id, get_symb, get_part_id, and get_part to be undef'd. |
|
|
|
Needs to be called before the first operation with the MySQL database |
|
for a given Apache request. |
|
|
|
=cut |
|
|
|
################################################ |
|
################################################ |
|
sub clear_internal_caches { |
|
$have_read_part_table = 0; |
|
undef(%ids_by_part); |
|
undef(%parts_by_id); |
|
$have_read_symb_table = 0; |
|
undef(%ids_by_symb); |
|
undef(%symbs_by_id); |
|
$have_read_student_table = 0; |
|
undef(%ids_by_student); |
|
undef(%students_by_id); |
|
} |
|
|
|
|
|
################################################ |
|
################################################ |
|
|
|
=pod |
|
|
=item &update_full_student_data($sname,$sdom,$courseid) |
=item &update_full_student_data($sname,$sdom,$courseid) |
|
|
Does a lonnet::dump on a student to populate the courses tables. |
Does a lonnet::dump on a student to populate the courses tables. |
Line 1149 sub update_full_student_data {
|
Line 1179 sub update_full_student_data {
|
# We can deal with 'timestamp' right away |
# We can deal with 'timestamp' right away |
my @timestamp_storage = ($symb_id,$student_id, |
my @timestamp_storage = ($symb_id,$student_id, |
$transaction,$value); |
$transaction,$value); |
my $store_command = 'INSERT INTO '.$fulldump_timestamp_table. |
my $store_command = 'INSERT IGNORE INTO '.$fulldump_timestamp_table. |
" VALUES ('".join("','",@timestamp_storage)."');"; |
" VALUES ('".join("','",@timestamp_storage)."');"; |
$dbh->do($store_command); |
$dbh->do($store_command); |
if ($dbh->err()) { |
if ($dbh->err()) { |
Line 1213 sub update_full_student_data {
|
Line 1243 sub update_full_student_data {
|
} |
} |
## |
## |
## Store the part data |
## Store the part data |
my $store_command = 'INSERT INTO '.$fulldump_part_table. |
my $store_command = 'INSERT IGNORE INTO '.$fulldump_part_table. |
' VALUES '."\n"; |
' VALUES '."\n"; |
my $store_rows = 0; |
my $store_rows = 0; |
while (my ($symb_id,$hash1) = each (%$partdata)) { |
while (my ($symb_id,$hash1) = each (%$partdata)) { |
Line 1241 sub update_full_student_data {
|
Line 1271 sub update_full_student_data {
|
} |
} |
## |
## |
## Store the response data |
## Store the response data |
$store_command = 'INSERT INTO '.$fulldump_response_table. |
$store_command = 'INSERT IGNORE INTO '.$fulldump_response_table. |
' VALUES '."\n"; |
' VALUES '."\n"; |
$store_rows = 0; |
$store_rows = 0; |
while (my ($symb_id,$hash1) = each (%$respdata)) { |
while (my ($symb_id,$hash1) = each (%$respdata)) { |
Line 1381 sub store_student_data {
|
Line 1411 sub store_student_data {
|
my $starttime = Time::HiRes::time; |
my $starttime = Time::HiRes::time; |
my $elapsed = 0; |
my $elapsed = 0; |
my $rows_stored; |
my $rows_stored; |
my $store_parameters_command = 'INSERT INTO '.$parameters_table. |
my $store_parameters_command = 'INSERT IGNORE INTO '.$parameters_table. |
' VALUES '."\n"; |
' VALUES '."\n"; |
my $num_parameters = 0; |
my $num_parameters = 0; |
my $store_performance_command = 'INSERT INTO '.$performance_table. |
my $store_performance_command = 'INSERT IGNORE INTO '.$performance_table. |
' VALUES '."\n"; |
' VALUES '."\n"; |
return ('error',undef) if (! defined($dbh)); |
return ('error',undef) if (! defined($dbh)); |
while (my ($current_symb,$param_hash) = each(%{$student_data})) { |
while (my ($current_symb,$param_hash) = each(%{$student_data})) { |
Line 1680 sub get_student_data_from_performance_ca
|
Line 1710 sub get_student_data_from_performance_ca
|
$studentdata->{$symb}->{$base.'.awarddetail'} = $awarddetail; |
$studentdata->{$symb}->{$base.'.awarddetail'} = $awarddetail; |
$studentdata->{$symb}->{'timestamp'} = $time if (defined($time) && $time ne ''); |
$studentdata->{$symb}->{'timestamp'} = $time if (defined($time) && $time ne ''); |
} |
} |
|
## Get misc parameters |
|
$request = 'SELECT c.symb,a.parameter,a.value '. |
|
"FROM $student_table AS b ". |
|
"LEFT JOIN $parameters_table AS a ON b.student_id=a.student_id ". |
|
"LEFT JOIN $symb_table AS c ON c.symb_id = a.symb_id ". |
|
"WHERE student='$student'"; |
|
if (defined($symb) && $symb ne '') { |
|
$request .= " AND c.symb=".$dbh->quote($symb); |
|
} |
|
$sth = $dbh->prepare($request); |
|
$sth->execute(); |
|
if ($sth->err()) { |
|
&Apache::lonnet::logthis("Unable to execute MySQL request:"); |
|
&Apache::lonnet::logthis("\n".$request."\n"); |
|
&Apache::lonnet::logthis("error is:".$sth->errstr()); |
|
if (defined($symb) && $symb ne '') { |
|
$studentdata = $studentdata->{$symb}; |
|
} |
|
return $studentdata; |
|
} |
|
# |
|
foreach my $row (@{$sth->fetchall_arrayref}) { |
|
$rows_retrieved++; |
|
my ($symb,$parameter,$value) = (@$row); |
|
$studentdata->{$symb}->{$parameter} = $value; |
|
} |
|
# |
if (defined($symb) && $symb ne '') { |
if (defined($symb) && $symb ne '') { |
$studentdata = $studentdata->{$symb}; |
$studentdata = $studentdata->{$symb}; |
} |
} |