--- loncom/interface/loncoursedata.pm 2004/02/17 19:56:30 1.117 +++ loncom/interface/loncoursedata.pm 2004/02/18 17:33:35 1.118 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.117 2004/02/17 19:56:30 matthew Exp $ +# $Id: loncoursedata.pm,v 1.118 2004/02/18 17:33:35 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2115,6 +2115,59 @@ 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 get_response_data_by_student { + my ($student,$symb,$response,$courseid) = @_; + return undef if (! defined($symb) || + ! defined($response)); + $courseid = $ENV{'request.course.id'} if (! defined($courseid)); + # + &setup_table_names($courseid); + my $symb_id = &get_symb_id($symb); + my $response_id = &get_part_id($response); + # + my $student_id = &get_student_id($student->{'username'}, + $student->{'domain'}); + # + my $dbh = &Apache::lonmysql::get_dbh(); + return undef if (! defined($dbh)); + my $request = 'SELECT '. + 'c.tries, b.timestamp, a.submission, a.awarddetail '. + '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 '. + 'a.transaction = b.transaction '. + 'LEFT JOIN '.$fulldump_part_table.' AS c '. + 'ON a.symb_id=c.symb_id AND a.student_id=c.student_id AND '. + 'a.part_id=c.part_id AND a.transaction = c.transaction '. + 'LEFT JOIN '.$student_table.' AS d '. + 'ON a.student_id=d.student_id '. + 'WHERE '. + 'a.symb_id='.$symb_id.' AND a.response_id='.$response_id. + ' AND a.student_id='.$student_id.' ORDER BY b.timestamp'; + &Apache::lonnet::logthis("request =\n".$request); + my $sth = $dbh->prepare($request); + $sth->execute(); + if ($dbh->err) { + &Apache::lonnet::logthis('error = '.$dbh->errstr()); + return undef; + } + my $dataset = $sth->fetchall_arrayref(); + if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) { + # Clear the \'s from around the submission + for (my $i =0;$i[$i]->[2] =~ s/(\'$|^\')//g; + } + return $dataset; + } + return undef; # error occurred +} + sub RT_student_id { return 0; } sub RT_awarded { return 1; } sub RT_tries { return 2; }