version 1.86, 2003/09/09 18:46:28
|
version 1.87, 2003/09/24 15:14:41
|
Line 191 sub get_sequence_assessment_data {
|
Line 191 sub get_sequence_assessment_data {
|
$symb = $curRes->symb(); |
$symb = $curRes->symb(); |
$src = $curRes->src(); |
$src = $curRes->src(); |
my $parts = $curRes->parts(); |
my $parts = $curRes->parts(); |
|
my %partdata; |
|
foreach my $part (@$parts) { |
|
$partdata{$part}->{'ResponseTypes'}= $curRes->responseType($part); |
|
$partdata{$part}->{'ResponseIds'} = $curRes->responseIds($part); |
|
} |
my $assessment = { title => $title, |
my $assessment = { title => $title, |
src => $src, |
src => $src, |
symb => $symb, |
symb => $symb, |
type => 'assessment', |
type => 'assessment', |
parts => $parts, |
parts => $parts, |
num_parts => scalar(@$parts), |
num_parts => scalar(@$parts), |
|
partdata => \%partdata, |
}; |
}; |
push(@Assessments,$assessment); |
push(@Assessments,$assessment); |
push(@{$currentmap->{'contents'}},$assessment); |
push(@{$currentmap->{'contents'}},$assessment); |
Line 388 internally to the MySQL database and is
|
Line 394 internally to the MySQL database and is
|
(stored in the students environment). This table has its PRIMARY KEY on the |
(stored in the students environment). This table has its PRIMARY KEY on the |
'student' (100 characters). |
'student' (100 characters). |
|
|
=item $updatetime_table |
=item $studentdata_table |
|
|
The updatetime_table has two columns. The first is 'student' (100 characters, |
The studentdata_table has four columns. The first is 'student_id', the unique |
typically username:domain). The second is 'updatetime', which is an unsigned |
id of the student. The second is the time the students data was last updated. |
integer, NOT a MySQL date. This table has its PRIMARY KEY on 'student' (100 |
The third is the students section. The fourth is the students current |
characters). |
classification. This table has its PRIMARY KEY on 'student_id'. |
|
|
=item $performance_table |
=item $performance_table |
|
|
Line 451 my $current_course ='';
|
Line 457 my $current_course ='';
|
my $symb_table; |
my $symb_table; |
my $part_table; |
my $part_table; |
my $student_table; |
my $student_table; |
my $updatetime_table; |
my $studentdata_table; |
my $performance_table; |
my $performance_table; |
my $parameters_table; |
my $parameters_table; |
|
|
Line 479 sub init_dbs {
|
Line 485 sub init_dbs {
|
# |
# |
# Drop any of the existing tables |
# Drop any of the existing tables |
foreach my $table ($symb_table,$part_table,$student_table, |
foreach my $table ($symb_table,$part_table,$student_table, |
$updatetime_table,$performance_table, |
$studentdata_table,$performance_table, |
$parameters_table) { |
$parameters_table) { |
&Apache::lonmysql::drop_table($table); |
&Apache::lonmysql::drop_table($table); |
} |
} |
Line 533 sub init_dbs {
|
Line 539 sub init_dbs {
|
'KEY' => [{ columns => ['student_id']},], |
'KEY' => [{ columns => ['student_id']},], |
}; |
}; |
# |
# |
my $updatetime_table_def = { |
my $studentdata_table_def = { |
id => $updatetime_table, |
id => $studentdata_table, |
permanent => 'no', |
permanent => 'no', |
columns => [{ name => 'student', |
columns => [{ name => 'student_id', |
type => 'VARCHAR(100)', |
type => 'MEDIUMINT UNSIGNED', |
restrictions => 'NOT NULL UNIQUE',}, |
restrictions => 'NOT NULL UNIQUE',}, |
{ name => 'updatetime', |
{ name => 'updatetime', |
type => 'INT UNSIGNED', |
type => 'INT UNSIGNED', |
restrictions => 'NOT NULL' }, |
restrictions => 'NOT NULL' }, |
|
{ name => 'section', |
|
type => 'VARCHAR(100)'}, |
|
{ name => 'classification', |
|
type => 'VARCHAR(100)', }, |
], |
], |
'PRIMARY KEY' => ['student (100)'], |
'PRIMARY KEY' => ['student_id'], |
}; |
}; |
# |
# |
my $performance_table_def = { |
my $performance_table_def = { |
Line 620 sub init_dbs {
|
Line 630 sub init_dbs {
|
return 3; |
return 3; |
} |
} |
# |
# |
$tableid = &Apache::lonmysql::create_table($updatetime_table_def); |
$tableid = &Apache::lonmysql::create_table($studentdata_table_def); |
if (! defined($tableid)) { |
if (! defined($tableid)) { |
&Apache::lonnet::logthis("error creating updatetime_table: ". |
&Apache::lonnet::logthis("error creating studentdata_table: ". |
&Apache::lonmysql::get_error()); |
&Apache::lonmysql::get_error()); |
return 4; |
return 4; |
} |
} |
Line 662 sub delete_caches {
|
Line 672 sub delete_caches {
|
# |
# |
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
foreach my $table ($symb_table,$part_table,$student_table, |
foreach my $table ($symb_table,$part_table,$student_table, |
$updatetime_table,$performance_table, |
$studentdata_table,$performance_table, |
$parameters_table ){ |
$parameters_table ){ |
my $command = 'DROP TABLE '.$table.';'; |
my $command = 'DROP TABLE '.$table.';'; |
$dbh->do($command); |
$dbh->do($command); |
Line 1000 sub update_student_data {
|
Line 1010 sub update_student_data {
|
if ($dbh->err()) { |
if ($dbh->err()) { |
&Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr()); |
&Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr()); |
&Apache::lonnet::logthis('command = '.$store_parameters_command); |
&Apache::lonnet::logthis('command = '.$store_parameters_command); |
|
&Apache::lonnet::logthis('rows_stored = '.$rows_stored); |
|
&Apache::lonnet::logthis('student_id = '.$student_id); |
$returnstatus = 'error: unable to insert parameters into database'; |
$returnstatus = 'error: unable to insert parameters into database'; |
return ($returnstatus,\%student_data); |
return ($returnstatus,\%student_data); |
} |
} |
Line 1013 sub update_student_data {
|
Line 1025 sub update_student_data {
|
$elapsed += Time::HiRes::time - $start; |
$elapsed += Time::HiRes::time - $start; |
# |
# |
# Set the students update time |
# Set the students update time |
&Apache::lonmysql::replace_row($updatetime_table, |
&Apache::lonmysql::replace_row($studentdata_table, |
[$student,$time_of_retrieval]); |
[$student_id,$time_of_retrieval,undef,undef]); |
return ($returnstatus,\%student_data); |
return ($returnstatus,\%student_data); |
} |
} |
|
|
Line 1030 Input: $sname, $sdom, $courseid
|
Line 1042 Input: $sname, $sdom, $courseid
|
Output: $status, $data |
Output: $status, $data |
|
|
This routine ensures the data for a given student is up to date. It calls |
This routine ensures the data for a given student is up to date. It calls |
&init_dbs() if the tables do not exist. The $updatetime_table is queried |
&init_dbs() if the tables do not exist. The $studentdata_table is queried |
to determine the time of the last update. If the students data is out of |
to determine the time of the last update. If the students data is out of |
date, &update_student_data() is called. The return values from the call |
date, &update_student_data() is called. The return values from the call |
to &update_student_data() are returned. |
to &update_student_data() are returned. |
Line 1050 sub ensure_current_data {
|
Line 1062 sub ensure_current_data {
|
# |
# |
# if the tables do not exist, make them |
# if the tables do not exist, make them |
my @CurrentTable = &Apache::lonmysql::tables_in_db(); |
my @CurrentTable = &Apache::lonmysql::tables_in_db(); |
my ($found_symb,$found_student,$found_part,$found_update, |
my ($found_symb,$found_student,$found_part,$found_studentdata, |
$found_performance,$found_parameters); |
$found_performance,$found_parameters); |
foreach (@CurrentTable) { |
foreach (@CurrentTable) { |
$found_symb = 1 if ($_ eq $symb_table); |
$found_symb = 1 if ($_ eq $symb_table); |
$found_student = 1 if ($_ eq $student_table); |
$found_student = 1 if ($_ eq $student_table); |
$found_part = 1 if ($_ eq $part_table); |
$found_part = 1 if ($_ eq $part_table); |
$found_update = 1 if ($_ eq $updatetime_table); |
$found_studentdata = 1 if ($_ eq $studentdata_table); |
$found_performance = 1 if ($_ eq $performance_table); |
$found_performance = 1 if ($_ eq $performance_table); |
$found_parameters = 1 if ($_ eq $parameters_table); |
$found_parameters = 1 if ($_ eq $parameters_table); |
} |
} |
if (!$found_symb || !$found_update || |
if (!$found_symb || !$found_studentdata || |
!$found_student || !$found_part || |
!$found_student || !$found_part || |
!$found_performance || !$found_parameters) { |
!$found_performance || !$found_parameters) { |
if (&init_dbs($courseid)) { |
if (&init_dbs($courseid)) { |
Line 1074 sub ensure_current_data {
|
Line 1086 sub ensure_current_data {
|
($sdom,$sname,$courseid.'.db', |
($sdom,$sname,$courseid.'.db', |
$Apache::lonnet::perlvar{'lonUsersDir'}); |
$Apache::lonnet::perlvar{'lonUsersDir'}); |
# |
# |
my $student = $sname.':'.$sdom; |
my $student_id = &get_student_id($sname,$sdom); |
my @Result = &Apache::lonmysql::get_rows($updatetime_table, |
my @Result = &Apache::lonmysql::get_rows($studentdata_table, |
"student ='$student'"); |
"student_id ='$student_id'"); |
my $data = undef; |
my $data = undef; |
if (@Result) { |
if (@Result) { |
$updatetime = $Result[0]->[1]; |
$updatetime = $Result[0]->[1]; |
Line 1465 sub setup_table_names {
|
Line 1477 sub setup_table_names {
|
$symb_table = $base_id.'_'.'symb'; |
$symb_table = $base_id.'_'.'symb'; |
$part_table = $base_id.'_'.'part'; |
$part_table = $base_id.'_'.'part'; |
$student_table = $base_id.'_'.'student'; |
$student_table = $base_id.'_'.'student'; |
$updatetime_table = $base_id.'_'.'updatetime'; |
$studentdata_table = $base_id.'_'.'studentdata'; |
$performance_table = $base_id.'_'.'performance'; |
$performance_table = $base_id.'_'.'performance'; |
$parameters_table = $base_id.'_'.'parameters'; |
$parameters_table = $base_id.'_'.'parameters'; |
return; |
return; |