--- loncom/interface/loncoursedata.pm 2004/02/02 21:45:12 1.114 +++ loncom/interface/loncoursedata.pm 2004/02/03 20:44:06 1.115 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.114 2004/02/02 21:45:12 matthew Exp $ +# $Id: loncoursedata.pm,v 1.115 2004/02/03 20:44:06 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1919,7 +1919,7 @@ able to answer it correctly. ################################################ ################################################ sub get_problem_statistics { - my ($students,$symb,$part,$courseid) = @_; + my ($Sections,$status,$symb,$part,$courseid) = @_; return if (! defined($symb) || ! defined($part)); $courseid = $ENV{'request.course.id'} if (! defined($courseid)); # @@ -1933,18 +1933,22 @@ sub get_problem_statistics { # $dbh->do('DROP TABLE '.$stats_table); # May return an error my $request = - 'CREATE TEMPORARY TABLE '.$stats_table. - ' SELECT student_id,solved,award,awarded,tries FROM '.$performance_table. - ' WHERE symb_id='.$symb_id.' AND part_id='.$part_id; - if (defined($students)) { + 'CREATE TEMPORARY TABLE '.$stats_table.' '. + 'SELECT a.student_id,a.solved,a.award,a.awarded,a.tries '. + 'FROM '.$performance_table.' AS a '; + if ((defined($Sections) && lc($Sections->[0]) ne 'all') || + (defined($status) && lc($status) ne 'any')) { + $request .= 'NATURAL LEFT JOIN '.$student_table.' AS b '; + } + $request .= ' WHERE a.symb_id='.$symb_id.' AND a.part_id='.$part_id; + if (defined($Sections) && lc($Sections->[0]) ne 'all') { $request .= ' AND ('. - join(' OR ', map {'student_id='. - &get_student_id($_->{'username'}, - $_->{'domain'}) - } @$students + join(' OR ', map { "b.section='".$_."'" } @$Sections ).')'; } -# &Apache::lonnet::logthis($request); + if (defined($status) && lc($status) ne 'any') { + $request .= " AND b.status='".$status."'"; + } $dbh->do($request); # &Apache::lonnet::logthis('request = '.$/.$request); $request = 'SELECT COUNT(*),SUM(tries),MAX(tries),AVG(tries),STD(tries) '.