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