--- loncom/interface/loncoursedata.pm 2003/09/26 18:31:31 1.89 +++ loncom/interface/loncoursedata.pm 2003/10/01 20:50:13 1.97 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.89 2003/09/26 18:31:31 matthew Exp $ +# $Id: loncoursedata.pm,v 1.97 2003/10/01 20:50:13 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -197,6 +197,10 @@ sub get_sequence_assessment_data { my @Ids = $curRes->responseIds($part); $partdata{$part}->{'ResponseTypes'}= \@Responses; $partdata{$part}->{'ResponseIds'} = \@Ids; + # Count how many responses of each type there are in this part + foreach (@Responses) { + $partdata{$part}->{$_}++; + } } my $assessment = { title => $title, src => $src, @@ -456,7 +460,7 @@ The response table holds data (documente associated with a particular response id which is stored when a student attempts a problem. The following are the columns of the table, in order: 'symb_id','part_id','response_id','student_id','transaction','tries', -'awarddetail', 'awarded','response_specific' (data particular to the response +'awarddetail', 'response_specific' (data particular to the response type), 'response_specific_value', and 'submission (the text of the students submission). The primary key is based on the first five columns listed above. @@ -712,8 +716,6 @@ sub init_dbs { restrictions => 'NOT NULL' }, { name => 'awarddetail', type => 'TINYTEXT' }, - { name => 'awarded', - type => 'TINYTEXT' }, # { name => 'message', # type => 'CHAR' }, { name => 'response_specific', @@ -1157,7 +1159,15 @@ sub update_full_student_data { next; } elsif ($parameter eq 'version') { next; - } elsif ($parameter =~ /^resource\.(.*)\.(tries|award|awarded|previous|solved|awarddetail|submission)\s*$/){ + } elsif ($parameter =~ /^resource\.(.*)\.(tries| + award| + awarded| + previous| + solved| + awarddetail| + submission| + submissiongrading| + molecule)\s*$/x){ # we do not have enough information to store an # entire row, so we save it up until later. my ($part_and_resp_id,$field) = ($1,$2); @@ -1169,11 +1179,17 @@ sub update_full_student_data { } else { $part_id = &get_part_id($part_and_resp_id); } + # Deal with part specific data if ($field =~ /^(tries|award|awarded|previous)$/) { $partdata->{$symb_id}->{$part_id}->{$transaction}->{$field}=$value; } + # deal with response specific data if (defined($resp_id) && - $field =~ /^(tries|awarddetail|awarded|submission)$/) { + $field =~ /^(tries| + awarddetail| + submission| + submissiongrading| + molecule)$/x) { if ($field eq 'submission') { # We have to be careful with user supplied input. # most of the time we are okay because it is escaped. @@ -1185,7 +1201,13 @@ sub update_full_student_data { $value =~ s/\\$/\\\\/; } } - $respdata->{$symb_id}->{$part_id}->{$resp_id}->{$transaction}->{$field}=$value; + if ($field eq 'submissiongrading' || + $field eq 'molecule') { + $respdata->{$symb_id}->{$part_id}->{$resp_id}->{$transaction}->{'response_specific'}=$field; + $respdata->{$symb_id}->{$part_id}->{$resp_id}->{$transaction}->{'response_specific_value'}=$value; + } else { + $respdata->{$symb_id}->{$part_id}->{$resp_id}->{$transaction}->{$field}=$value; + } } } } @@ -1231,8 +1253,8 @@ sub update_full_student_data { $transaction, $data->{'tries'}, $data->{'awarddetail'}, - $data->{'awarded'}, - '','', + $data->{'response_specific'}, + $data->{'response_specific_value'}, $data->{'submission'})."'),"; $store_rows++; } @@ -1331,8 +1353,10 @@ sub update_student_data { my @Results = &store_student_data($sname,$sdom,$courseid,\%student_data); # # Set the students update time - &Apache::lonmysql::replace_row($studentdata_table, + if ($Results[0] eq 'okay') { + &Apache::lonmysql::replace_row($studentdata_table, [$student_id,$time_of_retrieval,undef,undef,undef]); + } # return @Results; } @@ -1411,6 +1435,13 @@ sub store_student_data { chop $store_performance_command; chop $store_performance_command; 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); + $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()); @@ -1420,13 +1451,6 @@ sub store_student_data { $returnstatus = 'error: unable to insert parameters into database'; return ($returnstatus,$student_data); } - $dbh->do($store_performance_command); - if ($dbh->err()) { - &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr()); - &Apache::lonnet::logthis('command = '.$store_performance_command); - $returnstatus = 'error: unable to insert performance into database'; - return ($returnstatus,$student_data); - } $elapsed += Time::HiRes::time - $start; return ($returnstatus,$student_data); } @@ -1656,6 +1680,33 @@ sub get_student_data_from_performance_ca $studentdata->{$symb}->{$base.'.awarddetail'} = $awarddetail; $studentdata->{$symb}->{'timestamp'} = $time if (defined($time) && $time ne ''); } + ## Get misc parameters + $request = 'SELECT c.symb,a.parameter,a.value '. + "FROM $student_table AS b ". + "LEFT JOIN $parameters_table AS a ON b.student_id=a.student_id ". + "LEFT JOIN $symb_table AS c ON c.symb_id = a.symb_id ". + "WHERE student='$student'"; + if (defined($symb) && $symb ne '') { + $request .= " AND c.symb=".$dbh->quote($symb); + } + $sth = $dbh->prepare($request); + $sth->execute(); + if ($sth->err()) { + &Apache::lonnet::logthis("Unable to execute MySQL request:"); + &Apache::lonnet::logthis("\n".$request."\n"); + &Apache::lonnet::logthis("error is:".$sth->errstr()); + if (defined($symb) && $symb ne '') { + $studentdata = $studentdata->{$symb}; + } + return $studentdata; + } + # + foreach my $row (@{$sth->fetchall_arrayref}) { + $rows_retrieved++; + my ($symb,$parameter,$value) = (@$row); + $studentdata->{$symb}->{$parameter} = $value; + } + # if (defined($symb) && $symb ne '') { $studentdata = $studentdata->{$symb}; } @@ -1842,7 +1893,7 @@ sub get_problem_statistics { $stats_table); my ($Solved) = &execute_SQL_request($dbh,'SELECT COUNT(tries) FROM '. $stats_table. - " WHERE solved='correct_by_student'"); + " WHERE solved='correct_by_student' OR solved='correct_by_scantron'"); my ($solved) = &execute_SQL_request($dbh,'SELECT COUNT(tries) FROM '. $stats_table. " WHERE solved='correct_by_override'");