Diff for /loncom/interface/loncoursedata.pm between versions 1.201.2.6 and 1.205

version 1.201.2.6, 2021/09/16 16:20:36 version 1.205, 2021/03/02 19:51:02
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 966  sub update_full_student_data { Line 964  sub update_full_student_data {
     }      }
     ##      ##
     ## Store the response data      ## Store the response data
     my $store_prefix = 'INSERT IGNORE INTO '.$fulldump_response_table.      $store_command = '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 997  sub update_full_student_data { Line 978  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);
                     my $sql_values = "('".                      $store_command .= "('".
                         join("','",$symb_id,$part_id,                          join("','",$symb_id,$part_id,
                              $resp_id,$student_id,                               $resp_id,$student_id,
                              $transaction,                               $transaction,
Line 1005  sub update_full_student_data { Line 986  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'}).
                     if ($max_values) {                               "',".$submission."),";
                         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) {
         if ($curr_values ne '') {          chop($store_command);
             push(@store_values,$curr_values);          $dbh->do($store_command);
         }          if ($dbh->err) {
         foreach my $item (@store_values) {              $returnstatus = 'error saving response data';
             chop($item);              &Apache::lonnet::logthis('insert error '.$dbh->errstr());
             if ($item ne '') {              &Apache::lonnet::logthis("While attempting\n".$store_command);
                 $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 1062  sub update_full_student_data { Line 1012  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 1132  sub store_updatetime { Line 1082  sub store_updatetime {
     $dbh->do($request);      $dbh->do($request);
 }  }
   
   my $requested_max_packet = 0;
   my $max_allowed_packet;
   
 sub store_student_data {  sub store_student_data {
     my ($sname,$sdom,$courseid,$student_data) = @_;      my ($sname,$sdom,$courseid,$student_data) = @_;
     #      #
Line 1197  sub store_student_data { Line 1150  sub store_student_data {
                         if ($length > $max_param) {                          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("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("symb_id: $symb_id");
                             &Apache::lonnet::logthis("You may want to increase the max_allowed_packet size from the current: $max_allowed_packet");                              &Apache::lonnet::logthis("Skipping this item.  You may want to increase the max_allowed_packet size from the current: $max_allowed_packet");
                             if ($parameter =~ /\.submission$/) {                              next;
                                 $sql_parameter = "('".join("','",                          } else {
                                               $symb_id,$student_id,                              if ($length + $curr_params_length > $max_param) {
                                               $parameter)."',".                                  push(@store_parameters_values,$curr_params_values);
                                                   $dbh->quote('WARNING: Submission too large -- see grading interface for actual submission')."),\n";                                  $curr_params_values = $sql_parameter;
                                 $length = length($sql_parameter);                                  $curr_params_length = $length;
                                 &Apache::lonnet::logthis("Placeholder inserted instead of value of actual submission");  
                                 &Apache::lonnet::logthis("See grading interface for the actual submission");  
                             } else {                              } else {
                                 &Apache::lonnet::logthis("Skipping this item");                                  $curr_params_values .= $sql_parameter;
                                 next;                                  $curr_params_length += $length;
                             }                              }
                         }                          }
                         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 {                      } else {
                         $curr_params_values .= $sql_parameter;                          $curr_params_values .= $sql_parameter;
                     }                      }
Line 1901  sub populate_weight_table { Line 1844  sub populate_weight_table {
     my @resources;      my @resources;
     foreach my $seq (@sequences) {      foreach my $seq (@sequences) {
         push(@resources,$navmap->retrieveResources($seq,          push(@resources,$navmap->retrieveResources($seq,
                                                    sub {shift->is_problem();},                                                     sub {shift->is_gradable();},
                                                    0,0,0));                                                     0,0,0));
     }      }
     if (! scalar(@resources)) {      if (! scalar(@resources)) {
Line 2520  sub get_student_scores { Line 2463  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 ORDER BY score';      $request = 'SELECT score,COUNT(*) FROM '.$tmptable.' GROUP 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();

Removed from v.1.201.2.6  
changed lines
  Added in v.1.205


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>