--- loncom/interface/loncoursedata.pm 2005/04/07 06:56:23 1.146 +++ loncom/interface/loncoursedata.pm 2005/04/19 00:44:31 1.147 @@ -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 @@ sub store_student_data { # 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 @@ sub store_student_data { $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';