--- loncom/interface/loncoursedata.pm 2003/06/02 17:18:33 1.75 +++ loncom/interface/loncoursedata.pm 2003/06/25 19:25:54 1.80 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursedata.pm,v 1.75 2003/06/02 17:18:33 matthew Exp $ +# $Id: loncoursedata.pm,v 1.80 2003/06/25 19:25:54 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -121,7 +121,7 @@ sub get_sequence_assessment_data { ## We are going to loop until we run out of sequences/pages to explore for ## resources. This means we have to start out with something to look ## at. - my $title = $top_level_map->title(); + my $title = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; my $symb = $top_level_map->symb(); my $src = $top_level_map->src(); my $randompick = $top_level_map->randompick(); @@ -143,12 +143,20 @@ sub get_sequence_assessment_data { # # We need to keep track of which sequences contain homework problems # + my $previous_too; my $previous; while (scalar(@Nested_Sequences)) { + $previous_too = $previous; $previous = $curRes; $curRes = $iterator->next(); my $currentmap = $Nested_Sequences[-1]; # Last one on the stack if ($curRes == $iterator->BEGIN_MAP()) { + if (! ref($previous)) { + $previous = $previous_too; + } + if (! ref($previous)) { + next; + } # get the map itself, instead of BEGIN_MAP $title = $previous->title(); $symb = $previous->symb(); @@ -908,7 +916,7 @@ sub update_student_data { $sname.':'.$sdom.' in course '.$courseid. ':'.$tmp[0]); $returnstatus = 'error getting data'; - return $returnstatus; + return ($returnstatus,undef); } if (scalar(@tmp) < 1) { return ('no data',undef); @@ -932,7 +940,7 @@ sub update_student_data { my $num_parameters = 0; my $store_performance_command = 'INSERT INTO '.$performance_table. ' VALUES '."\n"; - return 'error' if (! defined($dbh)); + return ('error',undef) if (! defined($dbh)); while (my ($current_symb,$param_hash) = each(%student_data)) { # # make sure the symb is set up properly @@ -986,14 +994,14 @@ sub update_student_data { &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr()); &Apache::lonnet::logthis('command = '.$store_parameters_command); $returnstatus = 'error: unable to insert parameters into database'; - return $returnstatus,\%student_data; + return ($returnstatus,\%student_data); } $dbh->do($store_performance_command); if ($dbh->err()) { &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr()); &Apache::lonnet::logthis('command = '.$store_performance_command); $returnstatus = 'error: unable to insert performance into database'; - return $returnstatus,\%student_data; + return ($returnstatus,\%student_data); } $elapsed += Time::HiRes::time - $start; # @@ -1049,7 +1057,7 @@ sub ensure_current_data { !$found_student || !$found_part || !$found_performance || !$found_parameters) { if (&init_dbs($courseid)) { - return 'error'; + return ('error',undef); } } # @@ -1205,11 +1213,11 @@ sub get_current_state { return () if (! defined($sname) || ! defined($sdom)); # my ($status,$data) = &ensure_current_data($sname,$sdom,$courseid); - &Apache::lonnet::logthis - ('sname = '.$sname. - ' domain = '.$sdom. - ' status = '.$status. - ' data is '.(defined($data)?'defined':'undefined')); +# &Apache::lonnet::logthis +# ('sname = '.$sname. +# ' domain = '.$sdom. +# ' status = '.$status. +# ' data is '.(defined($data)?'defined':'undefined')); # while (my ($symb,$hash) = each(%$data)) { # &Apache::lonnet::logthis($symb."\n----------------------------------"); # while (my ($key,$value) = each (%$hash)) { @@ -1217,13 +1225,12 @@ sub get_current_state { # } # } # - if (defined($data)) { - if (defined($symb)) { - return %{$data->{$symb}}; - } else { - return %$data; - } - } elsif ($status eq 'no data') { + if (defined($data) && defined($symb) && ref($data->{$symb})) { + return %{$data->{$symb}}; + } elsif (defined($data) && ! defined($symb) && ref($data)) { + return %$data; + } + if ($status eq 'no data') { return (); } else { if ($status ne 'okay' && $status ne '') { @@ -1364,6 +1371,25 @@ sub get_problem_statistics { } # $dbh->do('DROP TABLE '.$stats_table); # May return an error +# +# Store in metadata +# + if ($num) { + my %storestats=(); + + my $urlres=(split(/\_\_\_/,$symb))[2]; + + $storestats{$courseid.'___'.$urlres.'___timestamp'}=time; + $storestats{$courseid.'___'.$urlres.'___stdno'}=$num; + $storestats{$courseid.'___'.$urlres.'___avetries'}=$mean; + $storestats{$courseid.'___'.$urlres.'___difficulty'}=$DegOfDiff; + + $urlres=~/^(\w+)\/(\w+)/; + &Apache::lonnet::put('nohist_resevaldata',\%storestats,$1,$2); + } +# +# Return result +# return { num_students => $num, tries => $tries, max_tries => $mod,