--- loncom/interface/loncoursedata.pm 2005/07/14 02:28:25 1.149 +++ loncom/interface/loncoursedata.pm 2006/02/04 20:03:30 1.152 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.149 2005/07/14 02:28:25 albertel Exp $ +# $Id: loncoursedata.pm,v 1.152 2006/02/04 20:03:30 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -869,7 +869,9 @@ sub populate_student_table { my $dbh = &Apache::lonmysql::get_dbh(); my $request = 'INSERT IGNORE INTO '.$student_table. "(student,section,status) VALUES "; - my $classlist = &get_classlist($courseid); + my $cdom = $env{'course.'.$courseid.'.domain'}; + my $cnum = $env{'course.'.$courseid.'.num'}; + my $classlist = &get_classlist($cdom,$cnum); my $student_count=0; while (my ($student,$data) = each %$classlist) { my ($section,$status) = ($data->[&CL_SECTION()], @@ -1289,6 +1291,7 @@ sub store_student_data { while (my ($parameter,$value) = each(%$param_hash)) { next if ($parameter !~ /^resource\.(.*)\.(solved|awarded)$/); my $part = $1; + next if ($part =~ /\./); next if (exists($stored{$part})); $stored{$part}++; # @@ -1870,6 +1873,8 @@ sub execute_SQL_request { my ($dbh,$request)=@_; # &Apache::lonnet::logthis($request); my $sth = $dbh->prepare($request); + if (!$sth) + { die $dbh->errstr . " SQL: $request"; } $sth->execute(); my $row = $sth->fetchrow_arrayref(); if (ref($row) eq 'ARRAY' && scalar(@$row)>0) { @@ -2209,7 +2214,7 @@ sub score_stats { # &Apache::lonnet::logthis('request = '.$/.$request); $request = 'SELECT SUM(weight) FROM '.$weight_table. - ' WHERE ('.$symb_restriction.')'; + ' AS a WHERE ('.$symb_restriction.')'; my ($max_possible) = &execute_SQL_request($dbh,$request); # &Apache::lonnet::logthis('request = '.$/.$request); return($min,$max,$ave,$std,$count,$max_possible); @@ -2258,11 +2263,10 @@ sub count_stats { $request = 'CREATE TEMPORARY TABLE '.$stats_table.' '. 'SELECT a.student_id,'. - 'COUNT(a.award) AS count FROM '. + 'SUM(a.awarded) AS count FROM '. $performance_table.' AS a '. 'LEFT JOIN '.$student_table.' AS b ON a.student_id=b.student_id '. - 'WHERE ('.$symb_restriction.')'. - " AND a.award!='INCORRECT_ATTEMPTED'"; + 'WHERE ('.$symb_restriction.')'; if ($time_limits) { $request .= ' AND '.$time_limits; } @@ -2697,9 +2701,9 @@ Retrieve the classist of a given class o information is returned from the classlist.db file and, if needed, from the students environment. -Optional arguments are $cid, $cdom, and $cnum (course id, course domain, -and course number, respectively). Any omitted arguments will be taken -from the current environment ($env{'request.course.id'}, +Optional arguments are $cdom, and $cnum (course domain, +and course number, respectively). If either is ommitted the course +will be taken from the current environment ($env{'request.course.id'}, $env{'course.'.$cid.'.domain'}, and $env{'course.'.$cid.'.num'}). Returns a reference to a hash which contains: @@ -2727,10 +2731,13 @@ sub CL_TYPE { return 8; } sub CL_LOCKEDTYPE { return 9; } sub get_classlist { - my ($cid,$cdom,$cnum) = @_; - $cid = $cid || $env{'request.course.id'}; - $cdom = $cdom || $env{'course.'.$cid.'.domain'}; - $cnum = $cnum || $env{'course.'.$cid.'.num'}; + my ($cdom,$cnum) = @_; + my $cid = $cdom.'_'.$cnum; + if (!defined($cdom) || !defined($cnum)) { + $cid = $env{'request.course.id'}; + $cdom = $env{'course.'.$cid.'.domain'}; + $cnum = $env{'course.'.$cid.'.num'}; + } my $now = time; # my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);