version 1.74, 2003/06/02 17:09:09
|
version 1.79, 2003/06/19 12:45:54
|
Line 109 sub get_sequence_assessment_data {
|
Line 109 sub get_sequence_assessment_data {
|
if (!defined($navmap)) { |
if (!defined($navmap)) { |
return 'Can not open Coursemap'; |
return 'Can not open Coursemap'; |
} |
} |
|
# We explicity grab the top level map because I am not sure we |
|
# are pulling it from the iterator. |
|
my $top_level_map = $navmap->getById('0.0'); |
|
# |
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
my $curRes = $iterator->next(); # Top level sequence |
my $curRes = $iterator->next(); # Top level sequence |
## |
## |
Line 118 sub get_sequence_assessment_data {
|
Line 122 sub get_sequence_assessment_data {
|
## resources. This means we have to start out with something to look |
## resources. This means we have to start out with something to look |
## at. |
## at. |
my $title = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; |
my $title = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; |
my $symb = 'top'; |
my $symb = $top_level_map->symb(); |
my $src = 'not applicable'; |
my $src = $top_level_map->src(); |
|
my $randompick = $top_level_map->randompick(); |
# |
# |
my @Sequences; |
my @Sequences; |
my @Assessments; |
my @Assessments; |
Line 130 sub get_sequence_assessment_data {
|
Line 135 sub get_sequence_assessment_data {
|
type => 'container', |
type => 'container', |
num_assess => 0, |
num_assess => 0, |
num_assess_parts => 0, |
num_assess_parts => 0, |
contents => [], }; |
contents => [], |
|
randompick => $randompick, |
|
}; |
push (@Sequences,$top); |
push (@Sequences,$top); |
push (@Nested_Sequences, $top); |
push (@Nested_Sequences, $top); |
# |
# |
# We need to keep track of which sequences contain homework problems |
# We need to keep track of which sequences contain homework problems |
# |
# |
|
my $previous_too; |
my $previous; |
my $previous; |
while (scalar(@Nested_Sequences)) { |
while (scalar(@Nested_Sequences)) { |
|
$previous_too = $previous; |
$previous = $curRes; |
$previous = $curRes; |
$curRes = $iterator->next(); |
$curRes = $iterator->next(); |
my $currentmap = $Nested_Sequences[-1]; # Last one on the stack |
my $currentmap = $Nested_Sequences[-1]; # Last one on the stack |
if ($curRes == $iterator->BEGIN_MAP()) { |
if ($curRes == $iterator->BEGIN_MAP()) { |
|
if (! ref($previous)) { |
|
$previous = $previous_too; |
|
} |
|
if (! ref($previous)) { |
|
next; |
|
} |
# get the map itself, instead of BEGIN_MAP |
# get the map itself, instead of BEGIN_MAP |
$title = $previous->title(); |
$title = $previous->title(); |
$symb = $previous->symb(); |
$symb = $previous->symb(); |
$src = $previous->src(); |
$src = $previous->src(); |
|
$randompick = $previous->randompick(); |
my $newmap = { title => $title, |
my $newmap = { title => $title, |
src => $src, |
src => $src, |
symb => $symb, |
symb => $symb, |
type => 'container', |
type => 'container', |
num_assess => 0, |
num_assess => 0, |
|
randompick => $randompick, |
contents => [], |
contents => [], |
}; |
}; |
push (@{$currentmap->{'contents'}},$newmap); # this is permanent |
push (@{$currentmap->{'contents'}},$newmap); # this is permanent |
Line 899 sub update_student_data {
|
Line 916 sub update_student_data {
|
$sname.':'.$sdom.' in course '.$courseid. |
$sname.':'.$sdom.' in course '.$courseid. |
':'.$tmp[0]); |
':'.$tmp[0]); |
$returnstatus = 'error getting data'; |
$returnstatus = 'error getting data'; |
return $returnstatus; |
return ($returnstatus,undef); |
} |
} |
if (scalar(@tmp) < 1) { |
if (scalar(@tmp) < 1) { |
return ('no data',undef); |
return ('no data',undef); |
Line 923 sub update_student_data {
|
Line 940 sub update_student_data {
|
my $num_parameters = 0; |
my $num_parameters = 0; |
my $store_performance_command = 'INSERT INTO '.$performance_table. |
my $store_performance_command = 'INSERT INTO '.$performance_table. |
' VALUES '."\n"; |
' VALUES '."\n"; |
return 'error' if (! defined($dbh)); |
return ('error',undef) if (! defined($dbh)); |
while (my ($current_symb,$param_hash) = each(%student_data)) { |
while (my ($current_symb,$param_hash) = each(%student_data)) { |
# |
# |
# make sure the symb is set up properly |
# make sure the symb is set up properly |
Line 977 sub update_student_data {
|
Line 994 sub update_student_data {
|
&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); |
$returnstatus = 'error: unable to insert parameters into database'; |
$returnstatus = 'error: unable to insert parameters into database'; |
return $returnstatus,\%student_data; |
return ($returnstatus,\%student_data); |
} |
} |
$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(' bigass insert error:'.$dbh->errstr()); |
&Apache::lonnet::logthis('command = '.$store_performance_command); |
&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); |
} |
} |
$elapsed += Time::HiRes::time - $start; |
$elapsed += Time::HiRes::time - $start; |
# |
# |
Line 1040 sub ensure_current_data {
|
Line 1057 sub ensure_current_data {
|
!$found_student || !$found_part || |
!$found_student || !$found_part || |
!$found_performance || !$found_parameters) { |
!$found_performance || !$found_parameters) { |
if (&init_dbs($courseid)) { |
if (&init_dbs($courseid)) { |
return 'error'; |
return ('error',undef); |
} |
} |
} |
} |
# |
# |
Line 1196 sub get_current_state {
|
Line 1213 sub get_current_state {
|
return () if (! defined($sname) || ! defined($sdom)); |
return () if (! defined($sname) || ! defined($sdom)); |
# |
# |
my ($status,$data) = &ensure_current_data($sname,$sdom,$courseid); |
my ($status,$data) = &ensure_current_data($sname,$sdom,$courseid); |
&Apache::lonnet::logthis |
# &Apache::lonnet::logthis |
('sname = '.$sname. |
# ('sname = '.$sname. |
' domain = '.$sdom. |
# ' domain = '.$sdom. |
' status = '.$status. |
# ' status = '.$status. |
' data is '.(defined($data)?'defined':'undefined')); |
# ' data is '.(defined($data)?'defined':'undefined')); |
# while (my ($symb,$hash) = each(%$data)) { |
# while (my ($symb,$hash) = each(%$data)) { |
# &Apache::lonnet::logthis($symb."\n----------------------------------"); |
# &Apache::lonnet::logthis($symb."\n----------------------------------"); |
# while (my ($key,$value) = each (%$hash)) { |
# while (my ($key,$value) = each (%$hash)) { |
Line 1208 sub get_current_state {
|
Line 1225 sub get_current_state {
|
# } |
# } |
# } |
# } |
# |
# |
if (defined($data)) { |
if (defined($data) && defined($symb) && ref($data->{$symb})) { |
if (defined($symb)) { |
return %{$data->{$symb}}; |
return %{$data->{$symb}}; |
} elsif (defined($data) && ! defined($symb) && ref($data)) { |
} else { |
return %$data; |
return %$data; |
} |
} |
if ($status eq 'no data') { |
} elsif ($status eq 'no data') { |
|
return (); |
return (); |
} else { |
} else { |
if ($status ne 'okay' && $status ne '') { |
if ($status ne 'okay' && $status ne '') { |