--- loncom/interface/statistics/lonproblemanalysis.pm 2002/07/24 14:52:32 1.1
+++ loncom/interface/statistics/lonproblemanalysis.pm 2003/09/29 21:13:23 1.24
@@ -1,7 +1,6 @@
# The LearningOnline Network with CAPA
-# (Publication Handler
#
-# $Id: lonproblemanalysis.pm,v 1.1 2002/07/24 14:52:32 stredwic Exp $
+# $Id: lonproblemanalysis.pm,v 1.24 2003/09/29 21:13:23 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,363 +25,202 @@
# http://www.lon-capa.org/
#
# (Navigate problems for statistical reports
-# YEAR=2001
-# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
-# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
# YEAR=2002
-# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
-# 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei
+# 5/12,7/26,9/7,11/22 Behrouz Minaei
#
###
-package Apache::lonproblemanalysis;
+package Apache::lonproblemanalysis;
use strict;
use Apache::lonnet();
-use GDBM_File;
+use Apache::lonhtmlcommon();
+use Apache::loncoursedata();
+use Apache::lonstatistics;
+use Apache::lonlocal;
sub BuildProblemAnalysisPage {
- my ($cacheDB)=@_;
-
- my %cache;
- my $Str = '';
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- $Str .= '
Unable to tie database.';
- return $Str;
- }
-
- $Str .= &IntervalOptions($cache{'Interval'});
- $Str .= &OptionResponseTable($cache{'OptionResponses'});
-
- untie(%cache);
-
- return $Str;
-}
-
-sub BuildAnalyzePage {
- my ($cacheDB, $students, $courseID)=@_;
-
- my $Str = '';
- my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- $Str .= 'Unable to tie database.';
- return $Str;
- }
-
- my $uri = $cache{'AnalyzeURI'},
- my $part = $cache{'AnalyzePart'},
- my $problem = $cache{'AnalyzeProblem'},
- my $title = $cache{'AnalyzeTitle'},
- my $interval = $cache{'Interval'},
-
- my %ConceptData;
- $ConceptData{"Interval"} = $interval;
-
- #Initialize the option response true answers
- my ($Concepts, $foil_to_concept, $answer) = &InitAnalysis($uri, $part,
- $problem,
- $students->[0],
- $courseID);
-
- #compute the intervals
- &Interval($part, $problem, $interval, $Concepts, \%ConceptData);
-
- $title =~ s/\ /"_"/eg;
- $Str .= '
'.$uri.'';
-
- #Java script Progress window
- &Create_PrgWin();
- &Update_PrgWin("Starting-to-analyze-problem");
- for (my $index=0;$index<(scalar @$students);$index++) {
- &Update_PrgWin($index);
- &OpStatus($problem, $students->[$index], $courseID, $answer);
- }
- &Close_PrgWin();
-
- $Str .= '
';
- for (my $k=0; $k<$interval; $k++ ) {
- $Str .= &DrawGraph($k, $title, $Concepts, \%ConceptData);
- }
- for (my $k=0; $k<$interval; $k++ ) {
- $Str .= &DrawTable($k, $Concepts, \%ConceptData);
- }
-#$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%ConceptData);
-#$Apache::lonxml::debug=0;
- my $Answ=&Apache::lonnet::ssi($uri);
- $Str .= '
Here you can see the Problem:
'.$Answ;
-
- untie(%cache);
-
- return $Str;
-}
-
-#---- Problem Analysis Web Page ----------------------------------------------
-
-sub IntervalOptions {
- my ($selectedInterval)=@_;
-
- my $interval = 1;
- for(my $n=1; $n<=7; $n++) {
- if($selectedInterval == $n) {
- $interval = $n;
- }
- }
-
- my $Ptr = '
Select number of intervals'."\n".
- ''."\n";
-
- return $Ptr;
+ $r->print('');
+ $r->print("render problem\n");
+ $r->print("image tag for plot\n");
+ $r->print("plot key\n");
+ $r->print('
');
+ $r->print("\nProblem choice = $symb $id\n
\n");
+ $r->print('
');
+ }
+ $r->print('');
+ $r->print(&CreateInterface());
+ if (! exists($ENV{'form.analysisfirstcall'})) {
+ return;
+ }
+ # Okay, they asked for data, so make sure we get the latest data.
+ &Apache::lonnet::logthis('got here for some reason');
+# &Apache::lonstatistics::Gather_Full_Student_Data($r);
+ $r->print(&OptionResponseProblemSelector());
+}
+
+sub get_problem_symb {
+ my $problemstring = shift();
+ my ($symb,$id) = ($problemstring=~ /^(.*):([^:]*)$/);
+ return ($symb,$id);
}
-sub OptionResponseTable {
- my ($optionResponses)=@_;
+sub CreateInterface {
my $Str = '';
- $Str .= '
Option Response Problems in this course:'."\n";
- $Str .= '
'."\n";
- $Str .= " \# | Problem Title | ";
- $Str .= ' Resource | Analysis |
'."\n";
-
- my $number=1;
- foreach (split(':::', $optionResponses)) {
- my ($uri,$title,$part,$problem)=split('::',$_);
- my $Temp = ''.$title.'';
- $Str .= '';
- $Str .= ' '.$number.' | ';
- $Str .= ' '.$Temp.' | ';
- $Str .= ' '.$uri.' | ';
- $Str .= ' |
'."\n";
- $number++;
- }
+ $Str .= ''."\n";
+ $Str .= '';
+ $Str .= ''.&mt('Sections').' | ';
+ $Str .= ''.&mt('Enrollment Status').' | ';
+ $Str .= ''.&mt('Sequences and Folders').' | ';
+ $Str .= '
'."\n";
+ #
+ $Str .= ''."\n";
+ $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
+ $Str .= ' | ';
+ $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
+ $Str .= ' | ';
+ my $only_seq_with_assessments = sub {
+ my $s=shift;
+ if ($s->{'num_assess'} < 1) {
+ return 0;
+ } else {
+ return 1;
+ }
+ };
+ $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
+ $only_seq_with_assessments);
+ $Str .= ' |
'."\n";
$Str .= '
'."\n";
-
- return $Str;
-}
-
-#---- END Problem Analysis Web Page ------------------------------------------
-
-#---- Analyze Web Page -------------------------------------------------------
-
-#restore the student submissions and finding the result
-sub OpStatus {
- my ($problem, $student, $courseID, $ConceptData, $foil_to_concept,
- $Answer)=@_;
- my ($username,$userdomain)=split(/':'/,$student);
- my $code='U';
- my %reshash=&Apache::lonnet::restore($problem, $courseID, $userdomain,
- $username);
- 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", $foil_to_concept->{$_},
- $time, $ConceptData);
- } else {
- &Decide("false", $foil_to_concept->{$_},
- $time, $ConceptData);}
- }
- }
- }
- }
+ $Str .= '';
+ $Str .= ' 'x5;
+ $Str .= '';
+ $Str .= ' 'x5;
+ return ($Str);
+}
+
+sub OptionResponseProblemSelector {
+ my $Str;
+ $Str = "\n\n";
+ return $Str;
}
-sub DrawTable {
- my ($k,$Concepts,$ConceptData)=@_;
- my $Max=0;
- my @data1;
- my @data2;
- my $Correct=0;
- my $Wrong=0;
- for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
- my $tmp=$Concepts->[$n];
- $data1[$n]=$ConceptData->{$tmp.'.'.$k.'.true'};
- $Correct+=$data1[$n];
- $data2[$n]=$ConceptData->{$tmp.'.'.$k.'.false'};
- $Wrong+=$data2[$n];
- my $Sum=$data1[$n]+$data2[$n];
- if($Max < $Sum) {
- $Max=$Sum;
+sub get_resource_from_symb {
+ my ($symb) = @_;
+ &Apache::lonnet::logthis('target symb = :'.$symb.':');
+ foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
+ foreach my $res (@{$seq->{'contents'}}) {
+ &Apache::lonnet::logthis('symb = :'.$res->{'symb'}.':');
+ if ($res->{'symb'} eq $symb) {
+ return $res;
+ }
}
}
- for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
- if ($data1[$n]+$data2[$n]<$Max) {
- $data2[$n]+=$Max-($data1[$n]+$data2[$n]);
- }
- }
- my $P_No = (scalar @data1);
- my $Str = '';
-# $Str .= '
From: ['.localtime($ConceptData->{'Int.'.($k-1)});
-# $Str .= '] To: ['.localtime($ConceptData->{"Int.$k"}).']';
- $Str .= "\n".''.
- "\n".''.
- "\n".' # | '.
- "\n".' Concept | '.
- "\n".' Correct | '.
- "\n".' Wrong | '.
- "\n".'
';
-
- for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
- $Str .= ''."\n";
- $Str .= ''.($n+1).' | '."\n";
- $Str .= ''.$Concepts->[$n];
- $Str .= ' | '."\n";
- $Str .= ''.$data1[$n].' | '."\n";
- $Str .= ''.$data2[$n].' | '."\n";
- $Str .= '
'."\n";
- }
- $Str .= ' | From:['.localtime($ConceptData->{'Int.'.$k});
- $Str .= '] To: ['.localtime($ConceptData->{'Int.'.($k+1)}-1);
- $Str .= '] | '.$Correct.' | '.$Wrong.' | ';
- $Str .= '
'."\n";
-
- return $Str;
-#$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%ConceptData);
-#$Apache::lonxml::debug=0;
+ return undef;
}
-#---- END Analyze Web Page ----------------------------------------------
-
-sub Decide {
- #deciding the true or false answer belongs to each interval
- my ($type,$concept,$time,$ConceptData)=@_;
- my $k=0;
- while ($time>$ConceptData->{'Int.'.($k+1)} &&
- $k<$ConceptData->{'Interval'}) {$k++;}
- $ConceptData->{$concept.'.'.$k.'.'.$type}++;
-
- return;
-}
+=pod
sub InitAnalysis {
- my ($uri,$part,$problem,$student,$courseID)=@_;
- my ($name,$domain)=split(/\:/,$student);
-
- # Render the student's view of the problem. $Answ is the problem
- # Stringafied
- my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze',
- 'grade_username' => $name,
- 'grade_domain' => $domain,
- 'grade_courseid' => $courseID,
- 'grade_symb' => $problem));
+ my ($resource,$sname,$sdom)=@_;
+ my $symb = $resource->
+ my $URI = $hash{'src_'.$rid};
+
+ my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze',
+ 'grade_username' => $sname,
+ 'grade_domain' => $sdom,
+ 'grade_courseid' => $cid,
+ 'grade_symb' => $symb));
# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze'));
-# (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2);
- my %Answer=();
+ (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2);
+ %Answer=();
%Answer=&Apache::lonnet::str2hash($Answ);
my $parts='';
- foreach my $elm (@{$Answer{'parts'}}) {
- $parts.= $elm.',';
- }
- $parts =~ s/,$//;
-
- my @Concepts=();
- foreach my $elm (@{$Answer{$parts.'.concepts'}}) {
- push(@Concepts, $elm);
+ foreach my $elm (@{$Answer{"parts"}}) {
+ $parts.="$elm,";
}
-
- my %foil_to_concept;
- foreach my $concept (@Concepts) {
- foreach my $foil (@{$Answer{$parts.'.concept.'.$concept}}) {
- $foil_to_concept{$foil} = $concept;
- #$ConceptData{$foil} = $Answer{$parts.'.foil.value.'.$foil};
- }
+ chop($parts);
+ my $conc='';
+ foreach my $elm (@{$Answer{"$parts.concepts"}}) {
+ $conc.="$elm@";
+ }
+ chop($conc);
+
+ @Concepts=split(/\@/,$conc);
+ foreach my $concept (@{$Answer{"$parts.concepts"}}) {
+ foreach my $foil (@{$Answer{"$parts.concept.$concept"}}) {
+ $foil_to_concept{$foil} = $concept;
+ #$ConceptData{$foil} = $Answer{"$parts.foil.value.$foil"};
+ }
}
-
- return (\@Concepts, \%foil_to_concept, \%Answer);
+ return $symb;
}
-sub Interval {
- my ($part,$symb,$interval,$Concepts,$ConceptData)=@_;
- my $Int=$interval;
- my $due = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb);
- my $opn = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);
- my $add=int(($due-$opn)/$Int);
- $ConceptData->{'Int.0'}=$opn;
- for (my $i=1;$i<$Int;$i++) {
- $ConceptData->{'Int.'.$i}=$opn+$i*$add;
- }
- $ConceptData->{'Int.'.$Int}=$due;
- for (my $i=0;$i<$Int;$i++) {
- for (my $n=0; $n<(scalar @$Concepts); $n++ ) {
- my $tmp=$Concepts->[$n];
- $ConceptData->{$tmp.'.'.$i.'.true'}=0;
- $ConceptData->{$tmp.'.'.$i.'.false'}=0;
- }
- }
-}
+=cut
+
1;
+
__END__