--- loncom/interface/statistics/lonproblemanalysis.pm 2002/11/22 03:46:57 1.11 +++ loncom/interface/statistics/lonproblemanalysis.pm 2003/03/03 21:52:24 1.20 @@ -1,7 +1,6 @@ # The LearningOnline Network with CAPA -# (Publication Handler # -# $Id: lonproblemanalysis.pm,v 1.11 2002/11/22 03:46:57 minaeibi Exp $ +# $Id: lonproblemanalysis.pm,v 1.20 2003/03/03 21:52:24 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -56,9 +55,7 @@ sub BuildProblemAnalysisPage { $Ptr .= ''."\n"; my @sectionsSelected = split(':',$cache{'sectionsSelected'}); my @sections = split(':',$cache{'sectionList'}); - $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, - \@sectionsSelected, - 'Statistics'); + $Ptr .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); $Ptr .= ''."\n"; $Ptr .= 'Intervals'."\n"; $Ptr .= ''; @@ -66,6 +63,7 @@ sub BuildProblemAnalysisPage { $Ptr .= '
'; $r->print($Ptr); $r->rflush(); +# $r->print($cache{'OptionResponses'}.'
'); $r->print(&OptionResponseTable($cache{'OptionResponses'}, \%cache, $r)); untie(%cache); @@ -90,7 +88,9 @@ sub BuildAnalyzePage { # Remove students who don't have the proper section. my @sectionsSelected = split(':',$cache{'sectionsSelected'}); - for(my $studentIndex=((scalar @$students)-1); $studentIndex>=0; + + my $studentCount = scalar @$students; + for(my $studentIndex=$studentCount-1; $studentIndex>=0; $studentIndex--) { my $value = $cache{$students->[$studentIndex].':section'}; my $found = 0; @@ -116,19 +116,21 @@ sub BuildAnalyzePage { $r->rflush(); } - my $error = - &Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, - 'true', - $cacheDB, - 'true', - 'true', - $courseID, - $r, $c); - if($error ne 'OK') { - $r->print($error.'
Error downloading course data
'); - return; - } + &Apache::lonhtmlcommon::Close_PrgWin($r); +### jason code for checing is there data in cache +# my $error = +# &Apache::loncoursedata::DownloadStudentCourseDataSeparate($students, +# 'true', +# $cacheDB, +# 'true', +# 'true', +# $courseID, +# $r, $c); +# if($error ne 'OK') { +# $r->print($error.'
Error downloading course data
'); +# return; +# } unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { $Str .= 'Unable to tie database.'; @@ -141,6 +143,8 @@ sub BuildAnalyzePage { my $problem = $cache{$problemId.':problem'}; my $title = $cache{$problemId.':title'}; my $interval = $cache{'Interval'}; + my $heading = 'Restore this particular Option Response Problem '. + 'Results, Please wait...'; my %ConceptData; $ConceptData{"Interval"} = $interval; @@ -169,13 +173,20 @@ sub BuildAnalyzePage { $Str = ''; if($c->aborted()) { untie(%cache); return; } + + my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r, $title, + $heading,$#students+1); + #Java script Progress window for(my $index=0; $index<(scalar @$students); $index++) { if($c->aborted()) { untie(%cache); return; } + &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, + 'last student '.$students->[$index]); &OpStatus($problemId, $students->[$index], \%ConceptData, - $analyzeData->{'foil_to_concept'}, $analyzeData, + $analyzeData->{'foil_to_concept'}, $analyzeData, \%cache, $courseID); } + &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); $Str .= '
'; for (my $k=0; $k<$interval; $k++ ) { @@ -290,7 +301,7 @@ sub OptionResponseTable { #---- Analyze Web Page ------------------------------------------------------- -#restore the student submissions and finding the result +# Joson code for reading data from cache =pod sub OpStatus { my ($problemID, $student, $ConceptData, $foil_to_concept, @@ -331,6 +342,9 @@ sub OpStatus { } =cut + +#restore the student submissions and finding the result + sub OpStatus { my ($problemID, $student, $ConceptData, $foil_to_concept, $analyzeData, $cache, $courseID)=@_; @@ -344,116 +358,44 @@ sub OpStatus { my $flag=0; my $tries=0; -# $jr->print("
ID= $problemID
student= $student
prob= $symb
"); - foreach my $id (@$ids) { my ($part, $response) = split(/\./, $id); -=pod - my %reshash=&Apache::lonnet::restore($symb,$courseID,$udom,$uname); - if ($reshash{'version'}) { - my $tries=0; - #&Apache::lonhomework::showhash(%$analyzeData); - for (my $version=1;$version<=$reshash{'version'};$version++) { - my $time=$reshash{"$version:timestamp"}; - - foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) { - if (($key=~/\.(\w+)\.(\w+)\.submission$/)) { - my $Id1 = $1; my $Id2 = $2; - #check if this is a repeat submission, if so skip it - if ($reshash{"$version:resource.$Id1.previous"}) { next; } - #if no solved this wasn't a real submission, ignore it - if (!defined($reshash{"$version:resource.$Id1.solved"})) { - &Apache::lonxml::debug("skipping "); - next; - } - my $Resp = $reshash{"$version:$key"}; - my %submission=&Apache::lonnet::str2hash($Resp); - foreach (keys %submission) { - my $Ansr = $analyzeData->{"$Id1.$Id2.foil.value.$_"}; - if ($submission{$_}) { - if ($submission{$_} eq $Ansr) { - &Decide("true",$_,$time ); - } - else {&Decide("false",$_,$time );} - } - } + my %reshash=&Apache::lonnet::restore($symb,$courseID,$udom,$uname); + if ($reshash{'version'}) { + my $tries=0; + for (my $version=1;$version<=$reshash{'version'};$version++) { + my $time=$reshash{"$version:timestamp"}; + foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) { + if (($key=~/\.(\w+)\.(\w+)\.submission$/)) { + my $Id1 = $1; my $Id2 = $2; + #check if this is a repeat submission, if so skip it + if ($reshash{"$version:resource.$Id1.previous"}) { next; } + #if no solved this wasn't a real submission, ignore it + if (!defined($reshash{"$version:resource.$Id1.solved"})) { + &Apache::lonxml::debug("skipping "); + next; + } + my $Resp = $reshash{"$version:$key"}; + my %submission=&Apache::lonnet::str2hash($Resp); + foreach (keys %submission) { + my $Ansr = $analyzeData->{"$Id1.$Id2.foil.value.$_"}; + if($submission{$_} eq $Ansr) { + &Decide("true", $foil_to_concept->{$_}, + $time, $ConceptData); + } else { + &Decide("false", $foil_to_concept->{$_}, + $time, $ConceptData); + } + } + } } - } - } - } -=cut - - my $time=$cache->{$student.':'.$problemID.':'.$part.':timestamp'}; - my @submissions = split(':::', $cache->{$student.':'.$problemID.':'. - $part.':'.$response. - ':submission'}); - foreach my $Resp (@submissions) { - my %submission=&Apache::lonnet::str2hash($Resp); - foreach (keys(%submission)) { - if($submission{$_}) { - my $answer = $analyzeData->{$id.'.foil.value.'.$_}; - if($submission{$_} eq $answer) { - &Decide("true", $foil_to_concept->{$_}, - $time, $ConceptData); - } else { - &Decide("false", $foil_to_concept->{$_}, - $time, $ConceptData); - } - } } } - - } return; } -=pod -sub OpStatus { - my ($rid,$student,$ConceptData,$foil_to_concept,$analyzeData,$cache)=@_; - my ($uname,$udom)=split(/\:/,$student); - my $code='U'; - $rid=~/(\d+)\.(\d+)/; - my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'. - &Apache::lonnet::declutter($hash{'src_'.$rid}); - my %reshash=&Apache::lonnet::restore($symb,$cid,$udom,$uname); - my @True = (); - my @False = (); - my $flag=0; - if ($reshash{'version'}) { - my $tries=0; - &Apache::lonhomework::showhash(%Answer); - for (my $version=1;$version<=$reshash{'version'};$version++) { - my $time=$reshash{"$version:timestamp"}; - - foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) { - if (($key=~/\.(\w+)\.(\w+)\.submission$/)) { - my $Id1 = $1; my $Id2 = $2; - #check if this is a repeat submission, if so skip it - if ($reshash{"$version:resource.$Id1.previous"}) { next; } - #if no solved this wasn't a real submission, ignore it - if (!defined($reshash{"$version:resource.$Id1.solved"})) { - &Apache::lonxml::debug("skipping "); - next; - } - my $Resp = $reshash{"$version:$key"}; - my %submission=&Apache::lonnet::str2hash($Resp); - foreach (keys %submission) { - my $Ansr = $Answer{"$Id1.$Id2.foil.value.$_"}; - if ($submission{$_}) { - if ($submission{$_} eq $Ansr) { - &Decide("true",$_,$time ); - } - else {&Decide("false",$_,$time );} - } - } - } - } - } - } -} -=cut sub DrawGraph { my ($k,$Src,$Concepts,$ConceptData)=@_; @@ -491,7 +433,7 @@ sub DrawGraph { $GData = $Titr.'&Concepts&Answers&'.$Max.'&'.$P_No.'&'; $GData .= (join(',',@data1)).'&'.(join(',',@data2)); - return ''; + return ''; } sub DrawTable {