version 1.203, 2018/03/11 12:44:22
|
version 1.209, 2023/11/04 00:06:00
|
Line 777 sub symb_is_for_task {
|
Line 777 sub symb_is_for_task {
|
return ($symb =~ /\.task$/); |
return ($symb =~ /\.task$/); |
} |
} |
|
|
|
my $requested_max_packet = 0; |
|
my $max_allowed_packet; |
|
|
sub update_full_student_data { |
sub update_full_student_data { |
my ($sname,$sdom,$courseid) = @_; |
my ($sname,$sdom,$courseid) = @_; |
Line 964 sub update_full_student_data {
|
Line 966 sub update_full_student_data {
|
} |
} |
## |
## |
## Store the response data |
## Store the response data |
$store_command = 'INSERT IGNORE INTO '.$fulldump_response_table. |
my $store_prefix = 'INSERT IGNORE INTO '.$fulldump_response_table. |
' VALUES '."\n"; |
' VALUES '."\n"; |
$store_rows = 0; |
$store_rows = 0; |
|
unless ($requested_max_packet) { |
|
(undef,$max_allowed_packet) = $dbh->selectrow_array( |
|
qq{show variables LIKE ? }, |
|
undef, |
|
"max_allowed_packet"); |
|
if ($max_allowed_packet !~ /^\d+$/) { |
|
$max_allowed_packet = ''; |
|
} |
|
$requested_max_packet = 1; |
|
} |
|
my @store_values = (); |
|
my $curr_values = ''; |
|
my $curr_length = 0; |
|
my ($max_values); |
|
if ($max_allowed_packet) { |
|
$max_values = $max_allowed_packet - length($store_prefix); |
|
} |
while (my ($symb_id,$hash1) = each (%$respdata)) { |
while (my ($symb_id,$hash1) = each (%$respdata)) { |
while (my ($part_id,$hash2) = each (%$hash1)) { |
while (my ($part_id,$hash2) = each (%$hash1)) { |
while (my ($resp_id,$hash3) = each (%$hash2)) { |
while (my ($resp_id,$hash3) = each (%$hash2)) { |
Line 978 sub update_full_student_data {
|
Line 997 sub update_full_student_data {
|
# and odd number of '\' cause insert errors to occur. |
# and odd number of '\' cause insert errors to occur. |
# Best trap this somehow... |
# Best trap this somehow... |
$submission = $dbh->quote($submission); |
$submission = $dbh->quote($submission); |
$store_command .= "('". |
my $sql_values = "('". |
join("','",$symb_id,$part_id, |
join("','",$symb_id,$part_id, |
$resp_id,$student_id, |
$resp_id,$student_id, |
$transaction, |
$transaction, |
Line 986 sub update_full_student_data {
|
Line 1005 sub update_full_student_data {
|
$data->{'response_specific'}, |
$data->{'response_specific'}, |
$data->{'response_specific_value'}, |
$data->{'response_specific_value'}, |
$data->{'response_specific_2'}, |
$data->{'response_specific_2'}, |
$data->{'response_specific_value_2'}). |
$data->{'response_specific_value_2'})."',"; |
"',".$submission."),"; |
if ($max_values) { |
|
my $length = length($sql_values) + length($submission."),"); |
|
if ($length > $max_values) { |
|
&Apache::lonnet::logthis("SQL responsedata insert for student: $sname would exceed max_allowed_packet size"); |
|
&Apache::lonnet::logthis("symb_id: $symb_id, part_id: $part_id, resp_id: $resp_id"); |
|
&Apache::lonnet::logthis("You may want to increase the max_allowed_packet size from the current: $max_allowed_packet"); |
|
$sql_values .= $dbh->quote('WARNING: Submission too large -- see grading interface for actual submission')."),"; |
|
$length = length($sql_values); |
|
&Apache::lonnet::logthis("Placeholder inserted instead of value of actual submission"); |
|
&Apache::lonnet::logthis("See grading interface for the actual submission"); |
|
} else { |
|
$sql_values .= $submission."),"; |
|
} |
|
if ($length + $curr_length > $max_values) { |
|
push(@store_values,$curr_values); |
|
$curr_values = $sql_values; |
|
$curr_length = $length; |
|
} else { |
|
$curr_values .= $sql_values; |
|
$curr_length += $length; |
|
} |
|
} else { |
|
$curr_values .= $sql_values.$submission."),"; |
|
} |
$store_rows++; |
$store_rows++; |
} |
} |
} |
} |
} |
} |
} |
} |
if ($store_rows) { |
if ($store_rows) { |
chop($store_command); |
if ($curr_values ne '') { |
$dbh->do($store_command); |
push(@store_values,$curr_values); |
if ($dbh->err) { |
} |
$returnstatus = 'error saving response data'; |
foreach my $item (@store_values) { |
&Apache::lonnet::logthis('insert error '.$dbh->errstr()); |
chop($item); |
&Apache::lonnet::logthis("While attempting\n".$store_command); |
if ($item ne '') { |
|
$dbh->do($store_prefix.$item); |
|
if ($dbh->err) { |
|
$returnstatus = 'error saving response data'; |
|
&Apache::lonnet::logthis('insert error '.$dbh->errstr()); |
|
&Apache::lonnet::logthis("While attempting\n".$store_prefix.$item); |
|
last; |
|
} |
|
} |
} |
} |
} |
} |
## |
## |
Line 1012 sub update_full_student_data {
|
Line 1062 sub update_full_student_data {
|
$returnstatus = 'error saving current data:'.$status; |
$returnstatus = 'error saving current data:'.$status; |
} elsif ($status ne 'okay') { |
} elsif ($status ne 'okay') { |
$returnstatus .= ' error saving current data:'.$status; |
$returnstatus .= ' error saving current data:'.$status; |
} |
} |
## |
## |
## Update the students time...... |
## Update the students time...... |
if ($returnstatus eq 'okay') { |
if ($returnstatus eq 'okay') { |
Line 1102 sub store_student_data {
|
Line 1152 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 IGNORE INTO '.$parameters_table. |
my $store_parameters_prefix = 'INSERT IGNORE INTO '.$parameters_table. |
' VALUES '."\n"; |
' VALUES '."\n"; |
my $num_parameters = 0; |
my $num_parameters = 0; |
my $store_performance_command = 'INSERT IGNORE INTO '.$performance_table. |
my $store_performance_prefix = 'INSERT IGNORE INTO '.$performance_table. |
' VALUES '."\n"; |
' VALUES '."\n"; |
return ('error',undef) if (! defined($dbh)); |
return ('error',undef) if (! defined($dbh)); |
|
unless ($requested_max_packet) { |
|
(undef,$max_allowed_packet) = $dbh->selectrow_array( |
|
qq{show variables LIKE ? }, |
|
undef, |
|
"max_allowed_packet"); |
|
if ($max_allowed_packet !~ /^\d+$/) { |
|
$max_allowed_packet = ''; |
|
} |
|
$requested_max_packet = 1; |
|
} |
|
my @store_parameters_values = (); |
|
my $curr_params_values = ''; |
|
my $curr_params_length = 0; |
|
my @store_performance_values = (); |
|
my $curr_perf_values = ''; |
|
my $curr_perf_length = 0; |
|
my ($max_param,$max_perf); |
|
if ($max_allowed_packet) { |
|
$max_param = $max_allowed_packet - length($store_parameters_prefix); |
|
$max_perf = $max_allowed_packet - length($store_performance_prefix); |
|
} |
while (my ($current_symb,$param_hash) = each(%{$student_data})) { |
while (my ($current_symb,$param_hash) = each(%{$student_data})) { |
# |
# |
# make sure the symb is set up properly |
# make sure the symb is set up properly |
Line 1120 sub store_student_data {
|
Line 1191 sub store_student_data {
|
$symb_id,$student_id, |
$symb_id,$student_id, |
$parameter)."',". |
$parameter)."',". |
$dbh->quote($value)."),\n"; |
$dbh->quote($value)."),\n"; |
$num_parameters ++; |
|
if ($sql_parameter !~ /''/) { |
if ($sql_parameter !~ /''/) { |
$store_parameters_command .= $sql_parameter; |
if ($max_param) { |
|
my $length = length($sql_parameter); |
|
if ($length > $max_param) { |
|
&Apache::lonnet::logthis("SQL parameter insert for student: $sname for parameter: $parameter would exceed max_allowed_packet size"); |
|
&Apache::lonnet::logthis("symb_id: $symb_id"); |
|
&Apache::lonnet::logthis("You may want to increase the max_allowed_packet size from the current: $max_allowed_packet"); |
|
if ($parameter =~ /\.submission$/) { |
|
$sql_parameter = "('".join("','", |
|
$symb_id,$student_id, |
|
$parameter)."',". |
|
$dbh->quote('WARNING: Submission too large -- see grading interface for actual submission')."),\n"; |
|
$length = length($sql_parameter); |
|
&Apache::lonnet::logthis("Placeholder inserted instead of value of actual submission"); |
|
&Apache::lonnet::logthis("See grading interface for the actual submission"); |
|
} else { |
|
&Apache::lonnet::logthis("Skipping this item"); |
|
next; |
|
} |
|
} |
|
if ($length + $curr_params_length > $max_param) { |
|
push(@store_parameters_values,$curr_params_values); |
|
$curr_params_values = $sql_parameter; |
|
$curr_params_length = $length; |
|
} else { |
|
$curr_params_values .= $sql_parameter; |
|
$curr_params_length += $length; |
|
} |
|
} else { |
|
$curr_params_values .= $sql_parameter; |
|
} |
#$rows_stored++; |
#$rows_stored++; |
|
$num_parameters ++; |
} |
} |
} |
} |
} |
} |
Line 1165 sub store_student_data {
|
Line 1265 sub store_student_data {
|
"('".join("','",$symb_id,$student_id,$part_id,$part, |
"('".join("','",$symb_id,$student_id,$part_id,$part, |
$solved,$tries,$awarded,$award, |
$solved,$tries,$awarded,$award, |
$awarddetail,$timestamp)."'),\n"; |
$awarddetail,$timestamp)."'),\n"; |
$store_performance_command .= $sql_performance; |
if ($max_perf) { |
|
my $length = length($sql_performance); |
|
if ($length > $max_perf) { |
|
&Apache::lonnet::logthis("SQL performance insert for student: $sname would exceed max_allowed_packet size"); |
|
&Apache::lonnet::logthis("symb_id: $symb_id"); |
|
&Apache::lonnet::logthis("Skipping this item. You may want to increase the max_allowed_packet size from the current: $max_allowed_packet"); |
|
next; |
|
} else { |
|
if ($length + $curr_perf_length > $max_perf) { |
|
push(@store_performance_values,$curr_perf_values); |
|
$curr_perf_values = $sql_performance; |
|
$curr_perf_length = $length; |
|
} else { |
|
$curr_perf_values .= $sql_performance; |
|
$curr_perf_length += $length; |
|
} |
|
} |
|
} else { |
|
$curr_perf_values .= $sql_performance; |
|
} |
$rows_stored++; |
$rows_stored++; |
} |
} |
} |
} |
|
if ($curr_params_values ne '') { |
|
push(@store_parameters_values,$curr_params_values); |
|
} |
|
if ($curr_perf_values ne '') { |
|
push(@store_performance_values,$curr_perf_values); |
|
} |
if (! $rows_stored) { return ($returnstatus, undef); } |
if (! $rows_stored) { return ($returnstatus, undef); } |
$store_parameters_command =~ s|,\n$||; |
|
$store_performance_command =~ s|,\n$||; |
|
my $start = Time::HiRes::time; |
my $start = Time::HiRes::time; |
$dbh->do($store_performance_command); |
foreach my $item (@store_performance_values) { |
if ($dbh->err()) { |
$item =~ s|,\n$||; |
&Apache::lonnet::logthis('performance bigass insert error:'. |
if ($item ne '') { |
$dbh->errstr()); |
$dbh->do($store_performance_prefix.$item); |
&Apache::lonnet::logthis('command = '.$/.$store_performance_command); |
if ($dbh->err()) { |
$returnstatus = 'error: unable to insert performance into database'; |
&Apache::lonnet::logthis('performance insert error:'. |
return ($returnstatus,$student_data); |
$dbh->errstr()); |
|
&Apache::lonnet::logthis('command = '.$/.$store_performance_prefix.$item); |
|
$returnstatus = 'error: unable to insert performance into database'; |
|
return ($returnstatus,$student_data); |
|
} |
|
} |
} |
} |
$dbh->do($store_parameters_command) if ($num_parameters>0); |
if ($num_parameters > 0) { |
if ($dbh->err()) { |
foreach my $item (@store_parameters_values) { |
&Apache::lonnet::logthis('parameters bigass insert error:'. |
$item =~ s|,\n$||; |
$dbh->errstr()); |
if ($item ne '') { |
&Apache::lonnet::logthis('command = '.$/.$store_parameters_command); |
$dbh->do($store_parameters_prefix.$item); |
&Apache::lonnet::logthis('rows_stored = '.$rows_stored); |
if ($dbh->err()) { |
&Apache::lonnet::logthis('student_id = '.$student_id); |
&Apache::lonnet::logthis('parameters insert error:'. |
$returnstatus = 'error: unable to insert parameters into database'; |
$dbh->errstr()); |
return ($returnstatus,$student_data); |
&Apache::lonnet::logthis('command = '.$/.$store_parameters_prefix.$item); |
|
&Apache::lonnet::logthis('rows_stored = '.$rows_stored); |
|
&Apache::lonnet::logthis('student_id = '.$student_id); |
|
$returnstatus = 'error: unable to insert parameters into database'; |
|
return ($returnstatus,$student_data); |
|
} |
|
} |
|
} |
} |
} |
$elapsed += Time::HiRes::time - $start; |
$elapsed += Time::HiRes::time - $start; |
return ($returnstatus,$student_data); |
return ($returnstatus,$student_data); |
Line 1677 sub get_problem_statistics {
|
Line 1812 sub get_problem_statistics {
|
# |
# |
$request = 'SELECT MAX(tries),MIN(tries) FROM '.$stats_table. |
$request = 'SELECT MAX(tries),MIN(tries) FROM '.$stats_table. |
' WHERE awarded>0'; |
' WHERE awarded>0'; |
if (defined($time_requirements)) { |
|
$request .= ' AND '.$time_requirements; |
|
} |
|
my ($max,$min) = &execute_SQL_request($dbh,$request); |
my ($max,$min) = &execute_SQL_request($dbh,$request); |
# |
# |
$request = 'SELECT SUM(awarded) FROM '.$stats_table; |
$request = 'SELECT SUM(awarded) FROM '.$stats_table; |
if (defined($time_requirements)) { |
|
$request .= ' AND '.$time_requirements; |
|
} |
|
my ($Solved) = &execute_SQL_request($dbh,$request); |
my ($Solved) = &execute_SQL_request($dbh,$request); |
# |
# |
$request = 'SELECT SUM(awarded) FROM '.$stats_table. |
$request = 'SELECT SUM(awarded) FROM '.$stats_table. |
" WHERE solved='correct_by_override'"; |
" WHERE solved='correct_by_override'"; |
if (defined($time_requirements)) { |
|
$request .= ' AND '.$time_requirements; |
|
} |
|
my ($solved) = &execute_SQL_request($dbh,$request); |
my ($solved) = &execute_SQL_request($dbh,$request); |
# |
# |
$Solved -= $solved; |
$Solved -= $solved; |
Line 2394 sub get_student_scores {
|
Line 2520 sub get_student_scores {
|
&Apache::lonnet::logthis('prepared then executed '.$/.$request); |
&Apache::lonnet::logthis('prepared then executed '.$/.$request); |
return undef; |
return undef; |
} |
} |
$request = 'SELECT score,COUNT(*) FROM '.$tmptable.' GROUP BY score'; |
$request = 'SELECT score,COUNT(*) FROM '.$tmptable.' GROUP BY score ORDER BY score'; |
# &Apache::lonnet::logthis("request = \n".$request); |
# &Apache::lonnet::logthis("request = \n".$request); |
$sth = $dbh->prepare($request); |
$sth = $dbh->prepare($request); |
$sth->execute(); |
$sth->execute(); |
Line 2493 sub CL_PHOTO { return 16; }
|
Line 2619 sub CL_PHOTO { return 16; }
|
sub CL_THUMBNAIL { return 17; } |
sub CL_THUMBNAIL { return 17; } |
sub CL_AUTHORQUOTA { return 18; } |
sub CL_AUTHORQUOTA { return 18; } |
sub CL_AUTHORUSAGE { return 19; } |
sub CL_AUTHORUSAGE { return 19; } |
|
sub CL_CAMANAGER {return 20; } |
|
|
sub get_classlist { |
sub get_classlist { |
my ($cdom,$cnum) = @_; |
my ($cdom,$cnum) = @_; |