version 1.59, 2003/03/20 19:58:37
|
version 1.60, 2003/03/21 16:04:10
|
Line 1828 sub init_dbs {
|
Line 1828 sub init_dbs {
|
type => 'TINYTEXT' }, |
type => 'TINYTEXT' }, |
{ name => 'timestamp', |
{ name => 'timestamp', |
type => 'INT UNSIGNED'}, |
type => 'INT UNSIGNED'}, |
|
{ name => 'weight', |
|
type => 'INT UNSIGNED'}, |
], |
], |
'PRIMARY KEY' => ['symb_id','student_id','part_id'], |
'PRIMARY KEY' => ['symb_id','student_id','part_id'], |
'KEY' => [{ columns=>['student_id'] }, |
'KEY' => [{ columns=>['student_id'] }, |
Line 2107 available the second time. CYA.
|
Line 2109 available the second time. CYA.
|
sub update_student_data { |
sub update_student_data { |
my ($sname,$sdom,$courseid) = @_; |
my ($sname,$sdom,$courseid) = @_; |
# |
# |
|
# Set up database names |
|
&setup_table_names($courseid); |
|
# |
my $student_id = &get_student_id($sname,$sdom); |
my $student_id = &get_student_id($sname,$sdom); |
my $student = $sname.':'.$sdom; |
my $student = $sname.':'.$sdom; |
# |
# |
my $returnstatus = 'okay'; |
my $returnstatus = 'okay'; |
# |
# |
# Set up database names |
|
&setup_table_names($courseid); |
|
# |
|
# Download students data |
# Download students data |
my $time_of_retrieval = time; |
my $time_of_retrieval = time; |
my @tmp = &Apache::lonnet::currentdump($courseid,$sdom,$sname); |
my @tmp = &Apache::lonnet::currentdump($courseid,$sdom,$sname); |
Line 2131 sub update_student_data {
|
Line 2133 sub update_student_data {
|
my %student_data = @tmp; |
my %student_data = @tmp; |
# |
# |
# Remove all of the students data from the table |
# Remove all of the students data from the table |
&Apache::lonmysql::remove_from_table($performance_table,'student_id', |
my $dbh = &Apache::lonmysql::get_dbh(); |
$student_id); |
$dbh->do('DELETE FROM '.$performance_table.' WHERE student_id='. |
|
$student_id); |
|
$dbh->do('DELETE FROM '.$parameters_table.' WHERE student_id='. |
|
$student_id); |
# |
# |
# Store away the data |
# Store away the data |
# |
# |
Line 2140 sub update_student_data {
|
Line 2145 sub update_student_data {
|
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 INTO '.$parameters_table. |
' VALUES '; |
' VALUES '."\n"; |
my $store_performance_command = 'INSERT INTO '.$performance_table. |
my $store_performance_command = 'INSERT INTO '.$performance_table. |
' VALUES '; |
' VALUES '."\n"; |
my $dbh = &Apache::lonmysql::get_dbh(); |
|
return 'error' if (! defined($dbh)); |
return 'error' if (! defined($dbh)); |
while (my ($current_symb,$param_hash) = each(%student_data)) { |
while (my ($current_symb,$param_hash) = each(%student_data)) { |
# |
# |
Line 2156 sub update_student_data {
|
Line 2160 sub update_student_data {
|
if ($parameter !~ /(timestamp|resource\.(.*)\.(solved|tries|awarded|award|awarddetail|previous))/) { |
if ($parameter !~ /(timestamp|resource\.(.*)\.(solved|tries|awarded|award|awarddetail|previous))/) { |
$newstring = "('".join("','", |
$newstring = "('".join("','", |
$symb_id,$student_id, |
$symb_id,$student_id, |
$parameter,$value)."'),"; |
$parameter,$value)."'),\n"; |
if ($newstring !~ /''/) { |
if ($newstring !~ /''/) { |
$store_parameters_command .= $newstring; |
$store_parameters_command .= $newstring; |
$rows_stored++; |
$rows_stored++; |
Line 2173 sub update_student_data {
|
Line 2177 sub update_student_data {
|
my $award = $param_hash->{'resource.'.$part.'.award'}; |
my $award = $param_hash->{'resource.'.$part.'.award'}; |
my $awarddetail = $param_hash->{'resource.'.$part.'.awarddetail'}; |
my $awarddetail = $param_hash->{'resource.'.$part.'.awarddetail'}; |
my $timestamp = $param_hash->{'timestamp'}; |
my $timestamp = $param_hash->{'timestamp'}; |
|
# use EXT to get the weight |
|
my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight', |
|
$current_symb,$sdom,$sname); |
|
# Give the weight back to the user |
|
$param_hash->{'resource.'.$part.'.weight'}=$weight; |
|
# |
$solved = '' if (! defined($awarded)); |
$solved = '' if (! defined($awarded)); |
$tries = '' if (! defined($tries)); |
$tries = '' if (! defined($tries)); |
$awarded = '' if (! defined($awarded)); |
$awarded = '' if (! defined($awarded)); |
Line 2180 sub update_student_data {
|
Line 2190 sub update_student_data {
|
$awarddetail = '' if (! defined($awarddetail)); |
$awarddetail = '' if (! defined($awarddetail)); |
$newstring = "('".join("','",$symb_id,$student_id,$part_id, |
$newstring = "('".join("','",$symb_id,$student_id,$part_id, |
$solved,$tries,$awarded,$award, |
$solved,$tries,$awarded,$award, |
$awarddetail,$timestamp)."'),"; |
$awarddetail,$timestamp,$weight)."'),\n"; |
$store_performance_command .= $newstring; |
$store_performance_command .= $newstring; |
$rows_stored++; |
$rows_stored++; |
} |
} |
} |
} |
chop $store_parameters_command; |
chop $store_parameters_command; |
|
chop $store_parameters_command; |
|
chop $store_performance_command; |
chop $store_performance_command; |
chop $store_performance_command; |
my $start = Time::HiRes::time; |
my $start = Time::HiRes::time; |
$dbh->do($store_parameters_command); |
$dbh->do($store_parameters_command); |
Line 2259 sub ensure_current_data {
|
Line 2271 sub ensure_current_data {
|
# |
# |
# Get the update time for the user |
# Get the update time for the user |
my $updatetime = 0; |
my $updatetime = 0; |
my $modifiedtime = 1; |
my $modifiedtime = &Apache::lonnet::GetFileTimestamp |
|
($sdom,$sname,$courseid.'.db', |
|
$Apache::lonnet::perlvar{'lonUsersDir'}); |
# |
# |
my $student = $sname.':'.$sdom; |
my $student = $sname.':'.$sdom; |
my @Result = &Apache::lonmysql::get_rows($updatetime_table, |
my @Result = &Apache::lonmysql::get_rows($updatetime_table, |
Line 2316 sub get_student_data_from_performance_ca
|
Line 2330 sub get_student_data_from_performance_ca
|
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
my $request = "SELECT ". |
my $request = "SELECT ". |
"d.symb,c.part,a.solved,a.tries,a.awarded,a.award,a.awarddetail,". |
"d.symb,c.part,a.solved,a.tries,a.awarded,a.award,a.awarddetail,". |
"a.timestamp "; |
"a.timestamp,a.weight "; |
if (defined($student)) { |
if (defined($student)) { |
$request .= "FROM $student_table AS b ". |
$request .= "FROM $student_table AS b ". |
"LEFT JOIN $performance_table AS a ON b.student_id=a.student_id ". |
"LEFT JOIN $performance_table AS a ON b.student_id=a.student_id ". |
Line 2345 sub get_student_data_from_performance_ca
|
Line 2359 sub get_student_data_from_performance_ca
|
} |
} |
foreach my $row (@{$sth->fetchall_arrayref}) { |
foreach my $row (@{$sth->fetchall_arrayref}) { |
$rows_retrieved++; |
$rows_retrieved++; |
my ($symb,$part,$solved,$tries,$awarded,$award,$awarddetail,$time) = |
my ($symb,$part,$solved,$tries,$awarded,$award,$awarddetail,$time,$weight) = |
(@$row); |
(@$row); |
my $base = 'resource.'.$part; |
my $base = 'resource.'.$part; |
$studentdata->{$symb}->{$base.'.solved'} = $solved; |
$studentdata->{$symb}->{$base.'.solved'} = $solved; |
Line 2354 sub get_student_data_from_performance_ca
|
Line 2368 sub get_student_data_from_performance_ca
|
$studentdata->{$symb}->{$base.'.award'} = $award; |
$studentdata->{$symb}->{$base.'.award'} = $award; |
$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 ''); |
|
$studentdata->{$symb}->{'resource.'.$part.'.weight'}=$weight; |
} |
} |
return $studentdata; |
return $studentdata; |
} |
} |
Line 2495 sub get_classlist {
|
Line 2510 sub get_classlist {
|
# |
# |
my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum); |
my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum); |
while (my ($student,$info) = each(%classlist)) { |
while (my ($student,$info) = each(%classlist)) { |
return undef if ($student =~ /^(con_lost|error|no_such_host)/i); |
if ($student =~ /^(con_lost|error|no_such_host)/i) { |
|
&Apache::lonnet::logthis('get_classlist error for '.$cid.':'.$student); |
|
return undef; |
|
} |
my ($sname,$sdom) = split(/:/,$student); |
my ($sname,$sdom) = split(/:/,$student); |
my @Values = split(/:/,$info); |
my @Values = split(/:/,$info); |
my ($end,$start,$id,$section,$fullname); |
my ($end,$start,$id,$section,$fullname); |