version 1.146, 2005/04/07 06:56:23
|
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 1214 sub update_student_data {
|
Line 1216 sub update_student_data {
|
# |
# |
# Set the students update time |
# Set the students update time |
if ($Results[0] eq 'okay') { |
if ($Results[0] eq 'okay') { |
&store_updatetime($student_id,$time_of_retrieval,$time_of_retrieval); |
&store_updatetime($student_id,$time_of_retrieval); |
} |
} |
# |
# |
return @Results; |
return @Results; |
Line 1270 sub store_student_data {
|
Line 1272 sub store_student_data {
|
# make sure the symb is set up properly |
# make sure the symb is set up properly |
my $symb_id = &get_symb_id($current_symb); |
my $symb_id = &get_symb_id($current_symb); |
# |
# |
# Load data into the tables |
# Parameters |
while (my ($parameter,$value) = each(%$param_hash)) { |
while (my ($parameter,$value) = each(%$param_hash)) { |
my $newstring; |
|
if ($parameter !~ /(timestamp|resource\.(.*)\.(solved|tries|awarded|award|awarddetail|previous))/) { |
if ($parameter !~ /(timestamp|resource\.(.*)\.(solved|tries|awarded|award|awarddetail|previous))/) { |
$newstring = "('".join("','", |
my $sql_parameter = "('".join("','", |
$symb_id,$student_id, |
$symb_id,$student_id, |
$parameter)."',". |
$parameter)."',". |
$dbh->quote($value)."),\n"; |
$dbh->quote($value)."),\n"; |
$num_parameters ++; |
$num_parameters ++; |
if ($newstring !~ /''/) { |
if ($sql_parameter !~ /''/) { |
$store_parameters_command .= $newstring; |
$store_parameters_command .= $sql_parameter; |
$rows_stored++; |
#$rows_stored++; |
} |
} |
} |
} |
next if ($parameter !~ /^resource\.(.*)\.solved$/); |
} |
# |
# Performance |
|
my %stored; |
|
while (my ($parameter,$value) = each(%$param_hash)) { |
|
next if ($parameter !~ /^resource\.(.*)\.(solved|awarded)$/); |
my $part = $1; |
my $part = $1; |
|
next if ($part =~ /\./); |
|
next if (exists($stored{$part})); |
|
$stored{$part}++; |
|
# |
my $part_id = &get_part_id($part); |
my $part_id = &get_part_id($part); |
next if (!defined($part_id)); |
next if (!defined($part_id)); |
my $solved = $value; |
my $solved = $value; |
Line 1301 sub store_student_data {
|
Line 1309 sub store_student_data {
|
$awarded = '' if (! defined($awarded)); |
$awarded = '' if (! defined($awarded)); |
$award = '' if (! defined($award)); |
$award = '' if (! defined($award)); |
$awarddetail = '' if (! defined($awarddetail)); |
$awarddetail = '' if (! defined($awarddetail)); |
$newstring = "('".join("','",$symb_id,$student_id,$part_id,$part, |
my $sql_performance = |
$solved,$tries,$awarded,$award, |
"('".join("','",$symb_id,$student_id,$part_id,$part, |
$awarddetail,$timestamp)."'),\n"; |
$solved,$tries,$awarded,$award, |
$store_performance_command .= $newstring; |
$awarddetail,$timestamp)."'),\n"; |
|
$store_performance_command .= $sql_performance; |
$rows_stored++; |
$rows_stored++; |
} |
} |
} |
} |
chop $store_parameters_command; |
if (! $rows_stored) { return ($returnstatus, undef); } |
chop $store_parameters_command; |
$store_parameters_command =~ s|,\n$||; |
chop $store_performance_command; |
$store_performance_command =~ s|,\n$||; |
chop $store_performance_command; |
|
my $start = Time::HiRes::time; |
my $start = Time::HiRes::time; |
$dbh->do($store_performance_command); |
$dbh->do($store_performance_command); |
if ($dbh->err()) { |
if ($dbh->err()) { |
&Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr()); |
&Apache::lonnet::logthis('performance bigass insert error:'. |
&Apache::lonnet::logthis('command = '.$store_performance_command); |
$dbh->errstr()); |
|
&Apache::lonnet::logthis('command = '.$/.$store_performance_command); |
$returnstatus = 'error: unable to insert performance into database'; |
$returnstatus = 'error: unable to insert performance into database'; |
return ($returnstatus,$student_data); |
return ($returnstatus,$student_data); |
} |
} |
$dbh->do($store_parameters_command) if ($num_parameters>0); |
$dbh->do($store_parameters_command) if ($num_parameters>0); |
if ($dbh->err()) { |
if ($dbh->err()) { |
&Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr()); |
&Apache::lonnet::logthis('parameters bigass insert error:'. |
&Apache::lonnet::logthis('command = '.$store_parameters_command); |
$dbh->errstr()); |
|
&Apache::lonnet::logthis('command = '.$/.$store_parameters_command); |
&Apache::lonnet::logthis('rows_stored = '.$rows_stored); |
&Apache::lonnet::logthis('rows_stored = '.$rows_stored); |
&Apache::lonnet::logthis('student_id = '.$student_id); |
&Apache::lonnet::logthis('student_id = '.$student_id); |
$returnstatus = 'error: unable to insert parameters into database'; |
$returnstatus = 'error: unable to insert parameters into database'; |
Line 1863 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 2202 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 2251 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 2690 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 2720 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); |