--- loncom/interface/loncoursedata.pm 2004/11/02 20:48:02 1.141 +++ loncom/interface/loncoursedata.pm 2005/02/28 20:00:23 1.142 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.141 2004/11/02 20:48:02 albertel Exp $ +# $Id: loncoursedata.pm,v 1.142 2005/02/28 20:00:23 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2582,32 +2582,46 @@ sub RT_tries { return 2; } sub RT_timestamp { return 3; } sub get_response_time_data { - my ($students,$symb,$part,$courseid) = @_; + my ($sections,$enrollment,$symb,$part,$courseid) = @_; return undef if (! defined($symb) || ! defined($part)); $courseid = $ENV{'request.course.id'} if (! defined($courseid)); # &setup_table_names($courseid); my $symb_id = &get_symb_id($symb); + if (! defined($symb_id)) { + &Apache::lonnet::logthis('Unable to find symb for '.$symb.' in '.$courseid); + return undef; + } my $part_id = &get_part_id($part); + if (! defined($part_id)) { + &Apache::lonnet::logthis('Unable to find id for '.$part.' in '.$courseid); + return undef; + } # my $dbh = &Apache::lonmysql::get_dbh(); return undef if (! defined($dbh)); + my ($student_requirements,$enrollment_requirements) = + &limit_by_section_and_status($sections,$enrollment,'d'); my $request = 'SELECT '. 'a.student_id, a.awarded, a.tries, b.timestamp '. 'FROM '.$fulldump_part_table.' AS a '. - 'NATURAL 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_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 '.$student_table.' as d '. + 'ON a.student_id=d.student_id '. 'WHERE '. 'a.symb_id='.$symb_id.' AND a.part_id='.$part_id; - if (defined($students)) { - $request .= ' AND ('. - join(' OR ', map {'a.student_id='. - &get_student_id($_->{'username'}, - $_->{'domain'}) - } @$students - ).')'; + if (defined($student_requirements) || defined($enrollment_requirements)) { + $request .= ' AND '; + if (defined($student_requirements)) { + $request .= $student_requirements.' AND '; + } + if (defined($enrollment_requirements)) { + $request .= $enrollment_requirements.' AND '; + } + $request =~ s/( AND )$//; } $request .= ' ORDER BY b.timestamp'; # &Apache::lonnet::logthis("request =\n".$request);