version 1.99, 2003/10/02 17:07:41
|
version 1.106, 2003/10/24 13:34:45
|
Line 711 sub init_dbs {
|
Line 711 sub init_dbs {
|
{ name => 'transaction', |
{ name => 'transaction', |
type => 'MEDIUMINT UNSIGNED', |
type => 'MEDIUMINT UNSIGNED', |
restrictions => 'NOT NULL' }, |
restrictions => 'NOT NULL' }, |
{ name => 'tries', |
|
type => 'SMALLINT UNSIGNED', |
|
restrictions => 'NOT NULL' }, |
|
{ name => 'awarddetail', |
{ name => 'awarddetail', |
type => 'TINYTEXT' }, |
type => 'TINYTEXT' }, |
# { name => 'message', |
# { name => 'message', |
Line 1042 sub get_student_id {
|
Line 1039 sub get_student_id {
|
$have_read_student_table = 1; |
$have_read_student_table = 1; |
} |
} |
if (! exists($ids_by_student{$student})) { |
if (! exists($ids_by_student{$student})) { |
&Apache::lonmysql::store_row($student_table,[undef,$student,undef]); |
&Apache::lonmysql::store_row($student_table, |
|
[undef,$student,undef]); |
undef(%ids_by_student); |
undef(%ids_by_student); |
my @Result = &Apache::lonmysql::get_rows($student_table); |
my @Result = &Apache::lonmysql::get_rows($student_table); |
foreach (@Result) { |
foreach (@Result) { |
Line 1215 sub update_full_student_data {
|
Line 1213 sub update_full_student_data {
|
} |
} |
# deal with response specific data |
# deal with response specific data |
if (defined($resp_id) && |
if (defined($resp_id) && |
$field =~ /^(tries| |
$field =~ /^(awarddetail| |
awarddetail| |
|
submission| |
submission| |
submissiongrading| |
submissiongrading| |
molecule)$/x) { |
molecule)$/x) { |
Line 1226 sub update_full_student_data {
|
Line 1223 sub update_full_student_data {
|
# However, there is one wrinkle: submissions which end in |
# However, there is one wrinkle: submissions which end in |
# and odd number of '\' cause insert errors to occur. |
# and odd number of '\' cause insert errors to occur. |
# Best trap this somehow... |
# Best trap this somehow... |
|
$value =~ s/\'/\\\'/g; |
my ($offensive_string) = ($value =~ /(\\+)$/); |
my ($offensive_string) = ($value =~ /(\\+)$/); |
if (length($offensive_string) % 2) { |
if (length($offensive_string) % 2) { |
$value =~ s/\\$/\\\\/; |
$value =~ s/\\$/\\\\/; |
Line 1281 sub update_full_student_data {
|
Line 1279 sub update_full_student_data {
|
$store_command .= "('".join("','",$symb_id,$part_id, |
$store_command .= "('".join("','",$symb_id,$part_id, |
$resp_id,$student_id, |
$resp_id,$student_id, |
$transaction, |
$transaction, |
$data->{'tries'}, |
|
$data->{'awarddetail'}, |
$data->{'awarddetail'}, |
$data->{'response_specific'}, |
$data->{'response_specific'}, |
$data->{'response_specific_value'}, |
$data->{'response_specific_value'}, |
Line 1884 sub get_problem_statistics {
|
Line 1881 sub get_problem_statistics {
|
return if (! defined($symb) || ! defined($part)); |
return if (! defined($symb) || ! defined($part)); |
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |
# |
# |
|
&setup_table_names($courseid); |
my $symb_id = &get_symb_id($symb); |
my $symb_id = &get_symb_id($symb); |
my $part_id = &get_part_id($part); |
my $part_id = &get_part_id($part); |
my $stats_table = $courseid.'_problem_stats'; |
my $stats_table = $courseid.'_problem_stats'; |
Line 1990 sub execute_SQL_request {
|
Line 1988 sub execute_SQL_request {
|
return (); |
return (); |
} |
} |
|
|
|
sub get_student_data { |
|
my ($students,$courseid) = @_; |
|
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |
|
&setup_table_names($courseid); |
|
my $dbh = &Apache::lonmysql::get_dbh(); |
|
return undef if (! defined($dbh)); |
|
my $request = 'SELECT '. |
|
'student_id, student '. |
|
'FROM '.$student_table; |
|
if (defined($students)) { |
|
$request .= ' WHERE ('. |
|
join(' OR ', map {'student_id='. |
|
&get_student_id($_->{'username'}, |
|
$_->{'domain'}) |
|
} @$students |
|
).')'; |
|
} |
|
$request.= ' ORDER BY student_id'; |
|
my $sth = $dbh->prepare($request); |
|
$sth->execute(); |
|
if ($dbh->err) { |
|
&Apache::lonnet::logthis('error = '.$dbh->errstr()); |
|
return undef; |
|
} |
|
my $dataset = $sth->fetchall_arrayref(); |
|
if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) { |
|
return $dataset; |
|
} |
|
} |
|
|
|
sub get_optionresponse_data { |
|
my ($students,$symb,$response,$courseid) = @_; |
|
return undef if (! defined($symb) || |
|
! defined($response)); |
|
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |
|
# |
|
&setup_table_names($courseid); |
|
my $symb_id = &get_symb_id($symb); |
|
my $response_id = &get_part_id($response); |
|
# |
|
my $dbh = &Apache::lonmysql::get_dbh(); |
|
return undef if (! defined($dbh)); |
|
my $request = 'SELECT '. |
|
'a.student_id, a.awarddetail, a.response_specific_value, '. |
|
'a.submission, b.timestamp, c.tries '. |
|
'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 '. |
|
'a.transaction = b.transaction '. |
|
'LEFT JOIN '.$fulldump_part_table.' AS c '. |
|
'ON a.symb_id=c.symb_id AND a.student_id=c.student_id AND '. |
|
'a.part_id=c.part_id AND a.transaction = c.transaction '. |
|
'WHERE '. |
|
'a.symb_id='.$symb_id.' AND a.response_id='.$response_id; |
|
if (defined($students)) { |
|
$request .= ' AND ('. |
|
join(' OR ', map {'a.student_id='. |
|
&get_student_id($_->{'username'}, |
|
$_->{'domain'}) |
|
} @$students |
|
).')'; |
|
} |
|
$request .= ' ORDER BY b.timestamp'; |
|
# &Apache::lonnet::logthis("request =\n".$request); |
|
my $sth = $dbh->prepare($request); |
|
$sth->execute(); |
|
if ($dbh->err) { |
|
&Apache::lonnet::logthis('error = '.$dbh->errstr()); |
|
return undef; |
|
} |
|
my $dataset = $sth->fetchall_arrayref(); |
|
if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) { |
|
return $dataset; |
|
} |
|
} |
|
|
|
sub get_response_time_data { |
|
my ($students,$symb,$response,$courseid) = @_; |
|
return undef if (! defined($symb) || |
|
! defined($response)); |
|
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |
|
# |
|
&setup_table_names($courseid); |
|
my $symb_id = &get_symb_id($symb); |
|
my $response_id = &get_part_id($response); |
|
# |
|
my $dbh = &Apache::lonmysql::get_dbh(); |
|
return undef if (! defined($dbh)); |
|
my $request = 'SELECT '. |
|
'a.student_id, a.awarddetail, b.timestamp '. |
|
'FROM '.$fulldump_response_table.' AS a '. |
|
'NATURAL LEFT JOIN '.$fulldump_timestamp_table.' AS b '. |
|
# 'ON a.symb_id=b.symb_id AND a.student_id=b.student_id AND '. |
|
# 'a.transaction = b.transaction '. |
|
'WHERE '. |
|
'a.symb_id='.$symb_id.' AND a.response_id='.$response_id; |
|
if (defined($students)) { |
|
$request .= ' AND ('. |
|
join(' OR ', map {'a.student_id='. |
|
&get_student_id($_->{'username'}, |
|
$_->{'domain'}) |
|
} @$students |
|
).')'; |
|
} |
|
$request .= ' ORDER BY b.timestamp'; |
|
# &Apache::lonnet::logthis("request =\n".$request); |
|
my $sth = $dbh->prepare($request); |
|
$sth->execute(); |
|
if ($dbh->err) { |
|
&Apache::lonnet::logthis('error = '.$dbh->errstr()); |
|
return undef; |
|
} |
|
my $dataset = $sth->fetchall_arrayref(); |
|
if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) { |
|
return $dataset; |
|
} |
|
|
|
} |
|
|
################################################ |
################################################ |
################################################ |
################################################ |