--- loncom/interface/loncoursedata.pm 2003/10/17 21:36:10 1.104 +++ loncom/interface/loncoursedata.pm 2003/10/20 20:42:39 1.105 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.104 2003/10/17 21:36:10 matthew Exp $ +# $Id: loncoursedata.pm,v 1.105 2003/10/20 20:42:39 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1987,8 +1987,36 @@ sub execute_SQL_request { return (); } -#sub get_timestamp_data { -# my ($students,$symb, +sub get_student_data { + my ($students,$courseid) = @_; + $courseid = $ENV{'request.course.id'} if (! defined($courseid)); + &setup_table_names($courseid); + my $dbh = &Apache::lonmysql::get_dbh(); + return undef if (! defined($dbh)); + my $request = 'SELECT '. + 'student_id, student '. + 'FROM '.$student_table; + if (defined($students)) { + $request .= ' WHERE ('. + join(' OR ', map {'student_id='. + &get_student_id($_->{'username'}, + $_->{'domain'}) + } @$students + ).')'; + } + $request.= ' ORDER BY student_id'; + 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) { + return $dataset; + } +} + sub get_optionresponse_data { my ($students,$symb,$response,$courseid) = @_; return undef if (! defined($symb) || @@ -2002,8 +2030,8 @@ sub get_optionresponse_data { my $dbh = &Apache::lonmysql::get_dbh(); return undef if (! defined($dbh)); my $request = 'SELECT '. - 'a.awarddetail, a.response_specific_value, a.submission, '. - 'b.timestamp, c.tries '. + 'a.student_id, a.awarddetail, a.response_specific_value, '. + 'a.submission, b.timestamp, c.tries '. '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 '. @@ -2025,6 +2053,10 @@ sub get_optionresponse_data { # &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) { return $dataset;