--- loncom/interface/loncoursedata.pm 2004/03/08 16:12:35 1.123 +++ loncom/interface/loncoursedata.pm 2004/03/22 17:25:26 1.126 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.123 2004/03/08 16:12:35 matthew Exp $ +# $Id: loncoursedata.pm,v 1.126 2004/03/22 17:25:26 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1867,12 +1867,14 @@ populated and all local caching variable properly. This means you need to call &ensure_current_data for the students you are concerned with prior to calling this routine. -Inputs: $students, $symb, $part, $courseid, $starttime, $endtime +Inputs: $Sections, $status, $symb, $part, $courseid, $starttime, $endtime =over 4 -=item $students is an array of hash references. -Each hash must contain at least the 'username' and 'domain' of a student. +=item $Sections Array ref containing section names for students. +'all' is allowed to be the first (and only) item in the array. + +=item $status String describing the status of students =item $symb is the symb for the problem. @@ -2085,7 +2087,7 @@ sub RD_tries { return 5; } sub RD_sname { return 6; } sub get_response_data { - my ($students,$symb,$response,$courseid) = @_; + my ($Sections,$enrollment,$symb,$response,$courseid) = @_; return undef if (! defined($symb) || ! defined($response)); $courseid = $ENV{'request.course.id'} if (! defined($courseid)); @@ -2096,6 +2098,18 @@ sub get_response_data { # my $dbh = &Apache::lonmysql::get_dbh(); return undef if (! defined($dbh)); + # + my $student_requirements; + if ( (defined($Sections) && $Sections->[0] ne 'all')) { + $student_requirements = '('. + join(' OR ', map { "d.section='".$_."'" } @$Sections + ).')'; + } + # + my $enrollment_requirements=undef; + if (defined($enrollment) && $enrollment ne 'Any') { + $enrollment_requirements = "d.status='".$enrollment."'"; + } my $request = 'SELECT '. 'a.student_id, a.awarddetail, a.response_specific_value, '. 'a.submission, b.timestamp, c.tries, d.student '. @@ -2110,13 +2124,15 @@ sub get_response_data { 'ON a.student_id=d.student_id '. 'WHERE '. 'a.symb_id='.$symb_id.' AND a.response_id='.$response_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); @@ -2175,7 +2191,7 @@ sub get_response_data_by_student { '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); +# &Apache::lonnet::logthis("request =\n".$request); my $sth = $dbh->prepare($request); $sth->execute(); if ($dbh->err) {