[LON-CAPA-cvs] cvs: loncom /interface loncoursedata.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Tue, 19 Apr 2005 00:44:31 -0000
matthew Mon Apr 18 20:44:31 2005 EDT
Modified files:
/loncom/interface loncoursedata.pm
Log:
&store_student_data: Bug 4025: store data in cache if awarded or solved is set.
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.146 loncom/interface/loncoursedata.pm:1.147
--- loncom/interface/loncoursedata.pm:1.146 Thu Apr 7 02:56:23 2005
+++ loncom/interface/loncoursedata.pm Mon Apr 18 20:44:31 2005
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncoursedata.pm,v 1.146 2005/04/07 06:56:23 albertel Exp $
+# $Id: loncoursedata.pm,v 1.147 2005/04/19 00:44:31 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1270,23 +1270,28 @@
# make sure the symb is set up properly
my $symb_id = &get_symb_id($current_symb);
#
- # Load data into the tables
+ # Parameters
while (my ($parameter,$value) = each(%$param_hash)) {
- my $newstring;
if ($parameter !~ /(timestamp|resource\.(.*)\.(solved|tries|awarded|award|awarddetail|previous))/) {
- $newstring = "('".join("','",
- $symb_id,$student_id,
- $parameter)."',".
- $dbh->quote($value)."),\n";
+ my $sql_parameter = "('".join("','",
+ $symb_id,$student_id,
+ $parameter)."',".
+ $dbh->quote($value)."),\n";
$num_parameters ++;
- if ($newstring !~ /''/) {
- $store_parameters_command .= $newstring;
+ if ($sql_parameter !~ /''/) {
+ $store_parameters_command .= $sql_parameter;
$rows_stored++;
}
}
- next if ($parameter !~ /^resource\.(.*)\.solved$/);
- #
+ }
+ # Performance
+ my %stored;
+ while (my ($parameter,$value) = each(%$param_hash)) {
+ next if ($parameter !~ /^resource\.(.*)\.(solved|awarded)$/);
my $part = $1;
+ next if (exists($stored{$part}));
+ $stored{$part}++;
+ #
my $part_id = &get_part_id($part);
next if (!defined($part_id));
my $solved = $value;
@@ -1301,29 +1306,30 @@
$awarded = '' if (! defined($awarded));
$award = '' if (! defined($award));
$awarddetail = '' if (! defined($awarddetail));
- $newstring = "('".join("','",$symb_id,$student_id,$part_id,$part,
- $solved,$tries,$awarded,$award,
- $awarddetail,$timestamp)."'),\n";
- $store_performance_command .= $newstring;
+ my $sql_performance =
+ "('".join("','",$symb_id,$student_id,$part_id,$part,
+ $solved,$tries,$awarded,$award,
+ $awarddetail,$timestamp)."'),\n";
+ $store_performance_command .= $sql_performance;
$rows_stored++;
}
}
- chop $store_parameters_command;
- chop $store_parameters_command;
- chop $store_performance_command;
- chop $store_performance_command;
+ $store_parameters_command =~ s|,\n$||;
+ $store_performance_command =~ s|,\n$||;
my $start = Time::HiRes::time;
$dbh->do($store_performance_command);
if ($dbh->err()) {
- &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());
- &Apache::lonnet::logthis('command = '.$store_performance_command);
+ &Apache::lonnet::logthis('performance bigass insert error:'.
+ $dbh->errstr());
+ &Apache::lonnet::logthis('command = '.$/.$store_performance_command);
$returnstatus = 'error: unable to insert performance into database';
return ($returnstatus,$student_data);
}
$dbh->do($store_parameters_command) if ($num_parameters>0);
if ($dbh->err()) {
- &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());
- &Apache::lonnet::logthis('command = '.$store_parameters_command);
+ &Apache::lonnet::logthis('parameters bigass insert error:'.
+ $dbh->errstr());
+ &Apache::lonnet::logthis('command = '.$/.$store_parameters_command);
&Apache::lonnet::logthis('rows_stored = '.$rows_stored);
&Apache::lonnet::logthis('student_id = '.$student_id);
$returnstatus = 'error: unable to insert parameters into database';