--- loncom/interface/loncoursedata.pm 2004/02/18 17:33:35 1.118 +++ 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.118 2004/02/18 17:33:35 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) '. @@ -2120,6 +2137,7 @@ sub RDs_awarddetail { return 3; } sub RDs_submission { return 2; } sub RDs_timestamp { return 1; } sub RDs_tries { return 0; } +sub RDs_awarded { return 4; } sub get_response_data_by_student { my ($student,$symb,$response,$courseid) = @_; @@ -2137,7 +2155,7 @@ sub get_response_data_by_student { my $dbh = &Apache::lonmysql::get_dbh(); return undef if (! defined($dbh)); my $request = 'SELECT '. - 'c.tries, b.timestamp, a.submission, a.awarddetail '. + 'c.tries, b.timestamp, a.submission, a.awarddetail, e.awarded '. '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 '. @@ -2147,10 +2165,13 @@ sub get_response_data_by_student { 'a.part_id=c.part_id AND a.transaction = c.transaction '. 'LEFT JOIN '.$student_table.' AS d '. 'ON a.student_id=d.student_id '. + 'LEFT JOIN '.$performance_table.' AS e '. + 'ON a.symb_id=e.symb_id AND a.part_id=e.part_id AND '. + 'a.student_id=e.student_id AND c.tries=e.tries '. '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) { @@ -2228,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(); @@ -2239,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).')'; } # @@ -2255,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. @@ -2277,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);