--- loncom/interface/loncoursedata.pm 2004/02/18 19:15:48 1.119 +++ loncom/interface/loncoursedata.pm 2004/03/07 21:42:19 1.122 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.119 2004/02/18 19:15:48 matthew Exp $ +# $Id: loncoursedata.pm,v 1.122 2004/03/07 21:42:19 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -182,7 +182,7 @@ sub get_sequence_assessment_data { next; } next if (! ref($curRes)); - next if (! $curRes->is_problem());# && !$curRes->randomout); + next if (! $curRes->is_problem() && $curRes->src() !~ /\.survey$/); # Okay, from here on out we only deal with assessments $title = $curRes->title(); $title =~ s/\:/\&\#058;/g; @@ -1867,7 +1867,7 @@ 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 +Inputs: $students, $symb, $part, $courseid, $starttime, $endtime =over 4 @@ -1880,6 +1880,9 @@ Each hash must contain at least the 'use =item $courseid is the course id, of course! +=item $starttime and $endtime are unix times which to use to limit +the statistical data. + =back Outputs: See the code for up to date information. A hash reference is @@ -1915,7 +1918,7 @@ able to answer it correctly. ################################################ ################################################ sub get_problem_statistics { - my ($Sections,$status,$symb,$part,$courseid) = @_; + my ($Sections,$status,$symb,$part,$courseid,$starttime,$endtime) = @_; return if (! defined($symb) || ! defined($part)); $courseid = $ENV{'request.course.id'} if (! defined($courseid)); # @@ -1945,6 +1948,20 @@ sub get_problem_statistics { if (defined($status) && lc($status) ne 'any') { $request .= " AND b.status='".$status."'"; } + # + &Apache::lonnet::logthis('starttime = '.$starttime); + my $time_requirements = undef; + if (defined($starttime)) { + $time_requirements .= 'a.timestamp>='.$starttime; + if (defined($endtime)) { + $time_requirements .= ' AND a.timestamp<='.$endtime; + } + } elsif (defined($endtime)) { + $time_requirements .= 'a.timestamp<='.$endtime; + } + if (defined($time_requirements)) { + $request .= ' AND '.$time_requirements; + } $dbh->do($request); # &Apache::lonnet::logthis('request = '.$/.$request); $request = 'SELECT COUNT(*),SUM(tries),MAX(tries),AVG(tries),STD(tries) '. @@ -2154,7 +2171,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) { @@ -2232,7 +2249,7 @@ sub get_response_time_data { ################################################ ################################################ sub get_student_scores { - my ($Sections,$Symbs,$enrollment,$courseid) = @_; + my ($Sections,$Symbs,$enrollment,$courseid,$starttime,$endtime) = @_; $courseid = $ENV{'request.course.id'} if (! defined($courseid)); &setup_table_names($courseid); my $dbh = &Apache::lonmysql::get_dbh(); @@ -2243,8 +2260,8 @@ sub get_student_scores { if (defined($Symbs) && @$Symbs) { $symb_requirements = '('. join(' OR ', map{ "(a.symb_id='".&get_symb_id($_->{'symb'}). - "' AND a.part_id='".&get_part_id($_->{'part'}). - "')" + "' AND a.part_id='".&get_part_id($_->{'part'}). + "')" } @$Symbs).')'; } # @@ -2259,6 +2276,16 @@ sub get_student_scores { if (defined($enrollment) && $enrollment ne 'Any') { $enrollment_requirements = "b.status='".$enrollment."'"; } + # + my $time_requirements = undef; + if (defined($starttime)) { + $time_requirements .= "a.timestamp>='".$starttime."'"; + if (defined($endtime)) { + $time_requirements .= " AND a.timestamp<='".$endtime."'"; + } + } elsif (defined($endtime)) { + $time_requirements .= "a.timestamp<='".$endtime."'"; + } ## ## my $request = 'CREATE TEMPORARY TABLE IF NOT EXISTS '.$tmptable. @@ -2281,7 +2308,10 @@ sub get_student_scores { if (defined($enrollment_requirements)) { $request .= $enrollment_requirements.' AND '; } - $request =~ s/ AND $//; + if (defined($time_requirements)) { + $request .= $time_requirements.' AND '; + } + $request =~ s/ AND $//; # Strip of the trailing ' AND '. $request .= ' GROUP BY a.student_id'; # &Apache::lonnet::logthis("request = \n".$request); my $sth = $dbh->prepare($request);