--- loncom/interface/loncoursedata.pm 2006/03/04 06:11:08 1.156 +++ loncom/interface/loncoursedata.pm 2006/04/28 21:58:37 1.164 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.156 2006/03/04 06:11:08 albertel Exp $ +# $Id: loncoursedata.pm,v 1.164 2006/04/28 21:58:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,7 +49,6 @@ Set of functions that download and proce package Apache::loncoursedata; use strict; -use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::lonhtmlcommon; use Time::HiRes; @@ -205,9 +204,10 @@ 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', '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. +'awarddetail', 'response_specific', 'response_specific_value', +'response_specific_2', 'response_specific_value_2', and 'submission +(the text of the students submission). The primary key is based on the +first five columns listed above. =item $fulldump_part_table @@ -467,6 +467,10 @@ sub init_dbs { type => 'TINYTEXT' }, { name => 'response_specific_value', type => 'TINYTEXT' }, + { name => 'response_specific_2', + type => 'TINYTEXT' }, + { name => 'response_specific_value_2', + type => 'TINYTEXT' }, { name => 'submission', type => 'TEXT'}, ], @@ -898,6 +902,15 @@ sub clear_internal_caches { undef(%students_by_id); } + +################################################ +################################################ + +sub symb_is_for_task { + my ($symb) = @_; + return ($symb =~ /\.task$/); +} + ################################################ ################################################ @@ -949,7 +962,7 @@ sub update_full_student_data { # # Download students data my $time_of_retrieval = time; - my @tmp = &Apache::lonnet::dump($courseid,$sdom,$sname); + my @tmp = &Apache::lonnet::dumpstore($courseid,$sdom,$sname); if (@tmp && $tmp[0] =~ /^error/) { $returnstatus = 'error retrieving full student data'; return $returnstatus; @@ -1087,7 +1100,9 @@ sub update_full_student_data { $transaction, $data->{'awarddetail'}, $data->{'response_specific'}, - $data->{'response_specific_value'}). + $data->{'response_specific_value'}, + $data->{'response_specific_2'}, + $data->{'response_specific_value_2'}). "',".$submission."),"; $store_rows++; } @@ -1266,19 +1281,30 @@ sub store_student_data { my %stored; while (my ($parameter,$value) = each(%$param_hash)) { next if ($parameter !~ /^resource\.(.*)\.(solved|awarded)$/); - my $part = $1; + my $part = $1; + my $which = $2; next if ($part =~ /\./); next if (exists($stored{$part})); $stored{$part}++; # my $part_id = &get_part_id($part); next if (!defined($part_id)); - my $solved = $value; - my $tries = $param_hash->{'resource.'.$part.'.tries'}; - my $awarded = $param_hash->{'resource.'.$part.'.awarded'}; + + my ($solved,$awarded); + if ($which eq 'solved') { + $solved = $value; + $awarded = $param_hash->{'resource.'.$part.'.awarded'}; + } else { + $solved = $param_hash->{'resource.'.$part.'.solved'}; + $awarded = $value; + } my $award = $param_hash->{'resource.'.$part.'.award'}; my $awarddetail = $param_hash->{'resource.'.$part.'.awarddetail'}; my $timestamp = $param_hash->{'timestamp'}; + my $tries = $param_hash->{'resource.'.$part.'.tries'}; + if (&symb_is_for_task($current_symb)) { + $tries = $param_hash->{'resource.'.$part.'.version'}; + } # $solved = '' if (! defined($solved)); $tries = '' if (! defined($tries)); @@ -2323,13 +2349,14 @@ sub get_student_data { } } -sub RD_student_id { return 0; } -sub RD_awarddetail { return 1; } -sub RD_response_eval { return 2; } -sub RD_submission { return 3; } -sub RD_timestamp { return 4; } -sub RD_tries { return 5; } -sub RD_sname { return 6; } +sub RD_student_id { return 0; } +sub RD_awarddetail { return 1; } +sub RD_response_eval { return 2; } +sub RD_response_eval_2 { return 3; } +sub RD_submission { return 4; } +sub RD_timestamp { return 5; } +sub RD_tries { return 6; } +sub RD_sname { return 7; } sub get_response_data { my ($Sections,$enrollment,$symb,$response,$courseid) = @_; @@ -2356,7 +2383,8 @@ sub get_response_data { &limit_by_section_and_status($Sections,$enrollment,'d'); my $request = 'SELECT '. 'a.student_id, a.awarddetail, a.response_specific_value, '. - 'a.submission, b.timestamp, c.tries, d.student '. + 'a.response_specific_value_2, a.submission, b.timestamp, '. + 'c.tries, d.student '. 'FROM '.$fulldump_response_table.' AS a '. 'LEFT JOIN '.$fulldump_timestamp_table.' AS b '. 'ON a.symb_id=b.symb_id AND a.student_id=b.student_id AND '. @@ -2398,11 +2426,14 @@ sub get_response_data { } -sub RDs_awarddetail { return 3; } -sub RDs_submission { return 2; } -sub RDs_timestamp { return 1; } -sub RDs_tries { return 0; } -sub RDs_awarded { return 4; } +sub RDs_awarddetail { return 3; } +sub RDs_submission { return 2; } +sub RDs_timestamp { return 1; } +sub RDs_tries { return 0; } +sub RDs_awarded { return 4; } +sub RDs_response_eval { return 5; } +sub RDs_response_eval_2 { return 6; } +sub RDs_part_award { return 7; } sub get_response_data_by_student { my ($student,$symb,$response,$courseid) = @_; @@ -2420,7 +2451,8 @@ sub get_response_data_by_student { my $dbh = &Apache::lonmysql::get_dbh(); return undef if (! defined($dbh)); my $request = 'SELECT '. - 'c.tries, b.timestamp, a.submission, a.awarddetail, e.awarded '. + 'c.tries, b.timestamp, a.submission, a.awarddetail, c.awarded, '. + 'a.response_specific_value, a.response_specific_value_2, c.award '. 'FROM '.$fulldump_response_table.' AS a '. 'LEFT JOIN '.$fulldump_timestamp_table.' AS b '. 'ON a.symb_id=b.symb_id AND a.student_id=b.student_id AND '.