Diff for /loncom/interface/lonstatistics.pm between versions 1.27 and 1.28

version 1.27, 2002/07/17 12:53:00 version 1.28, 2002/07/19 18:17:34
Line 31 Line 31
 # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei  # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
 # YEAR=2002  # 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  # 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 Behrouz Minaei  # 5/12,5/14,5/15,5/19,5/26,7/16  Behrouz Minaei
 #  #
 ###  ###
   
Line 42  use Apache::Constants qw(:common :http); Line 42  use Apache::Constants qw(:common :http);
 use Apache::lonnet();  use Apache::lonnet();
 use Apache::lonhomework;  use Apache::lonhomework;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::loncoursedata;  
 use HTML::TokeParser;  use HTML::TokeParser;
 use GDBM_File;  use GDBM_File;
   
Line 50  use GDBM_File; Line 49  use GDBM_File;
 my %hash;  my %hash;
 my %CachData;  my %CachData;
 my %GraphDat;  my %GraphDat;
 my %mapsort;  
 my $Pos;  
 my $r;  my $r;
 my $GData;  my $GData;
 my %color;  my %color;
 my %foil_to_concept;  my %foil_to_concept;
 my @Concepts;  my @Concepts;
 my %ConceptData;  my %ConceptData;
 my %Answer = ();  my %Answer=();
   my %mapsort;
   
   my %Activity=();
   my %Grade=();
   my %DoDiff=();
   my %Discuss=();
   my $TotalDiscuss=0;
   my $TotalDiscuss_=0;
   
   
   sub LoadDiscussion {
   #    my $symb=shift;
   #    $r->print('<br>$cid ... '.$symb);
   #    my %contrib=&Apache::lonnet::dump('msu_2964385f9033c63msul1','msu','2964385f9033c63msul1');
       my $cid=$ENV{'request.course.id'};
       my %contrib=&Apache::lonnet::dump(
                   $ENV{'request.course.id'},
                   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                   $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
                               
       foreach my $temp(keys %contrib) {
    if ($temp=~/^version/) {
       my $ver=$contrib{$temp};
       my ($dummy,$prb)=split(':',$temp);
       for (my $idx=1; $idx<=$ver; $idx++ ) {
    my $name=$contrib{"$idx:$prb:sendername"};
    $Discuss{"$name:$prb"}=$idx;
       }
    }
       }       
   #   $r->print('<br>cid='.$cid);
   #    my %contrib=&Apache::lonnet::restore($symb,$cid,
   # $ENV{$cid.'.domain'},
   # $ENV{'course.'.$cid.'.num'});
   
   #    $Apache::lonxml::debug=1;
   #    &Apache::lonhomework::showhash(%Discuss);
   #    $Apache::lonxml::debug=0;
   }
   
   sub LoadDoDiffFile {
       my $file="/home/minaeibi/183d.txt";
       open(FILEID, "<$file");
       my $line=<FILEID>;
       %DoDiff=();
       my @Act=split('&',$line);
       
   #    $r->print('<br>'.$#Act);
       for(my $n=0;$n<=$#Act;$n++){
          my ($res,$Degree)=split('@',$Act[$n]);
         $DoDiff{$res}=$Degree;
       }
   }
   
   
   sub LoadClassFile {
       my $file="/home/minaeibi/class.txt";
       open(FILEID, "<$file");
       my $line;
       %Grade=();
       while ($line=<FILEID>) {
           my ($id,$ex1,$ex2,$ex3,$ex4,$hw,$final,$grade)=split(' ',$line);
           $Grade{$id}=$grade;
       }
   }
   
   
   #------- Classification  
   sub Classify {
       my ($DiscFac, $students)=@_;
       &LoadClassFile();
       my $Count=0;
       my @List=();
       my @LS=();
       my @LF=();
       my @LM=();
       my $cf=0;
       my $cs=0;
       my $cm=0;
       foreach (keys(%$DiscFac)){  
    my @l=split(/\:/,$_);
    if (!($students->{$l[1]})) {next;}
    my $Grade=$Grade{$students->{$l[1]}};
    if( $Grade > 3 ) {
       $cs++;
       push(@LS,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Successful"));
    } elsif ( $Grade > 2 ) {
       $cm++;
       push(@LM,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Average"));
    } else {
       $cf++;
       push(@LF,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Failed"));
    }
       }    
       for(my $n=0;$n<$cs;$n++){$r->print('<br>'.$LS[$n]);}
       for(my $n=0;$n<$cm;$n++){$r->print('<br>'.$LM[$n]);}  
       for(my $n=0;$n<$cf;$n++){$r->print('<br>'.$LF[$n]);}
   } 
   
   
   sub ProcAct {
       # return;
       my ($Act,$Submit)=@_;
       my @Act=split(/\@/,$Act);
       @Act = sort(@Act);
   
       ##$r->print('<br>'.$#Act);
       ##for(my $n=0;$n<=$#Act;$n++){
   ## $r->print('<br>n='.$n.')'.$Act[$n]);
   ##    }
   
   #    my $Beg=$Act[0];
       my $Dif=$Submit-$Act[0];
       $Dif = ($Dif>0) ? ($Dif/3600) : 0; 
   
   #    $r->print('<br>Access Number = '.$#Act.'<br>Submit Time='.$Submit.'<br>First Access='.$Act[0].'<br>Last Access='.$Act[$#Act].'<br> Submit - First = <b>'.$Dif.'</b>');
   
   
   #time spent for solving the problem           
   #    $r->print('<br>Def'.($Act[$#Act-1]-$Act[0]));
   
       return $Dif;
   }
   
   
   
   sub LoadActivityLog {
   #    my $CacheDB = "/home/minaeibi/act183.log.cache";
       my $CacheDB = "/home/httpd/perl/tmp/act183.log.cache";
       
       if (-e "$CacheDB") {
    if (tie(%Activity,'GDBM_File',"$CacheDB",&GDBM_READER,0640)) {
       return;
           }
           else {
       $r->print("Unable to tie log Cache hash to db file");
           }
       }
       else {
    if (tie(%Activity,'GDBM_File',$CacheDB,&GDBM_WRCREAT,0640)) {
       foreach (keys %Activity) {delete $Activity{$_};}
       &Build_log(); 
    }
           else {
       $r->print("Unable to tie log Build hash to db file");
           }
       }
   }
   
   sub Build_log {
       my $file="/home/minaeibi/act183.log";
       open(FILEID, "<$file");
       my $line;
       my $count=0;
       while ($line=<FILEID>) {
    my ($time,$machine,$what)=split(':',$line);
    $what=&Apache::lonnet::unescape($what);
    my @accesses=split('&',$what);
              
    foreach my $access (@accesses) {
   
       $count++;
   
       my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access);
       if (!$resource) { next; }
       my $res=&Apache::lonnet::unescape($resource);
       if (($res =~ /\.problem/)) {
    $Activity{$who.':'.$res}.=$date.'@';
                   #$r->print('<br>'.$time.':'.$who.'---'.$res);
    &Update_PrgInit($count);
   
       }
    }
       }
   
   # my $c=1;
   # foreach (sort keys %Activity) {
   #     $r->print('<br>'.$c.')'.$_.' ... '.$Activity{$_});
   #     $c++;
   # }
   
   }
   
 sub Activity {  sub Activity {
   #    $rid=~/(\d+)\.(\d+)/;
   #    my $MapId=$1;
   #    my $PrbId=$2;
   #    my $MapOrg = $hash{'map_id_'.$MapId};
   #    my $Map = &Apache::lonnet::declutter($MapOrg);
   #    my $URI = $hash{'src_'.$rid};
   #    my $Symb = $Map.'___'.$PrbId.'___'.&Apache::lonnet::declutter($URI);
     my $file="/home/minaeibi/activity.log";      my $file="/home/minaeibi/activity.log";
     my $userid='adamsde1';      my $userid='adamsde1';
     $r->print("<br>Using $file");      $r->print("<br>Using $file");
Line 75  sub Activity { Line 261  sub Activity {
  my @accesses=split('&',$what);   my @accesses=split('&',$what);
  foreach my $access (@accesses) {   foreach my $access (@accesses) {
     my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access);      my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access);
     if ($who ne $userid) { next; }      #if ($who ne $userid) { next; }
     if (!$resource) { next; }      if (!$resource) { next; }
     my $res=&Apache::lonnet::unescape($resource);      my $res=&Apache::lonnet::unescape($resource);
     if (($res =~ /\.(problem|htm|html)/)) {      if (($res =~ /\.(sequence|problem|htm|html|page)/)) {
  $Count++;       $Count++;
  $r->print("<br>$Count) ".localtime($date).": $who --> $res");   $r->print("<br>$Count) ".localtime($date).": $who --> $res");
 #        if ($post) {   #        if ($post) { 
 #    $Count++;  #    $Count++;
Line 88  sub Activity { Line 274  sub Activity {
 # }  # }
  $r->rflush();   $r->rflush();
     }      }
  ##    push (@allaccess,unescape($access));      #push (@allaccess,unescape($access));
     #print $machine;      #print $machine;
  }   }
     }      }
Line 105  sub Activity { Line 291  sub Activity {
 #    }  #    }
 }  }
   
 #---- Analyze Web Page ---------------------------------------------------  
   
 sub InitAnalysis {  sub InitAnalysis {
     my ($uri,$part,$problem,$student,$courseID)=@_;      my ($uri,$part,$problem,$student,$courseID)=@_;
     my ($username,$userdomain)=split(/\:/,$student);      my ($uname,$udom)=split(/\:/,$student);
   
   
     # Render the student's view of the problem.  $Answ is the problem       # Render the student's view of the problem.  $Answ is the problem 
     # Stringafied      # Stringafied
     my $Answ=&Apache::lonnet::ssi($uri,('grade_target'   => 'analyze',      my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze',
                                         'grade_username' => $username,                                    'grade_username' => $uname,
                                         'grade_domain'   => $userdomain,                                    'grade_domain' => $udom,
                                         'grade_courseid' => $courseID,                                    'grade_courseid' => $courseID,
                                         'grade_symb'     => $problem));                                    'grade_symb' => $problem));
 #    my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze'));  #    my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze'));
   
 #    (undef,$Answ)=split(/_HASH_REF__/,$Answ,2);  #    (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2);
     %Answer=();      %Answer=();
     %Answer=&Apache::lonnet::str2hash($Answ);      %Answer=&Apache::lonnet::str2hash($Answ);
   
 #    foreach (sort(keys(%Answer))) {  
 #        $r->print($_.'  '.$Answer{$_}.'<br>');  
 #    }  
   
     my $parts='';      my $parts='';
     foreach my $elm (@{$Answer{"parts"}}) {      foreach my $elm (@{$Answer{"parts"}}) {
  $parts.="$elm,";   $parts.="$elm,";
Line 150  sub InitAnalysis { Line 332  sub InitAnalysis {
     return;      return;
 }  }
   
   
 sub Interval {  sub Interval {
     my ($part,$symb)=@_;      my ($part,$symb)=@_;
     my $interval=$ConceptData{"Interval"};      my $Int=$ConceptData{"Interval"};
     my $due  = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb)+1;      my $due = &Apache::lonnet::EXT('resource.$part.duedate',$symb)+1;
     my $open = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);      my $opn = &Apache::lonnet::EXT('resource.$part.opendate',$symb);
     my $add=int(($due-$open)/$interval);      my $add=int(($due-$opn)/$Int);
     $ConceptData{'Interval.0'}=$open;      $ConceptData{"Int.0"}=$opn;
     for (my $i=1;$i<$interval;$i++) {      for (my $i=1;$i<$Int;$i++) {
  $ConceptData{'Interval.'.$i}=$open+$i*$add;   $ConceptData{"Int.$i"}=$opn+$i*$add;
     }      }
     $ConceptData{'Interval.'.$interval}=$due;           $ConceptData{"Int.$Int"}=$due;     
     for (my $i=0;$i<$interval;$i++) {      for (my $i=0;$i<$Int;$i++) {
  for (my $n=0; $n<=$#Concepts; $n++ ) {   for (my $n=0; $n<=$#Concepts; $n++ ) {
     my $tmp=$Concepts[$n];      my $tmp=$Concepts[$n];
     $ConceptData{$tmp.'.'.$i.'.true'}=0;      $ConceptData{"$tmp.$i.true"}=0;
     $ConceptData{$tmp.'.'.$i.'.false'}=0;      $ConceptData{"$tmp.$i.false"}=0;
  }   }
     }      }
 }  }
   
   
 sub ShowOpGraph {  sub ShowOpGraph {
     my ($cache, $students, $courseID)=@_;      my ($cache, $students, $courseID)=@_;
     my $uri      = $cache->{'AnalyzeURI'};      my $uri      = $cache->{'AnalyzeURI'};
     my $part     = $cache->{'AnalyzePart'};      my $part     = $cache->{'AnalyzePart'};
     my $problem  = $cache->{'AnalyzeProblem'};      my $problem  = $cache->{'AnalyzeProblem'};
     my $title    = $cache->{'AnalyzeProblem'};      my $title    = $cache->{'AnalyzeTitle'};
     my $interval = $cache->{'Interval'};      my $interval = $cache->{'Interval'};
     $ConceptData{"Interval"} = $interval;      $ConceptData{"Interval"} = $interval;
   
Line 188  sub ShowOpGraph { Line 372  sub ShowOpGraph {
     $title =~ s/\ /"_"/eg;      $title =~ s/\ /"_"/eg;
     $r->print('<br><b>'.$uri.'</b>');      $r->print('<br><b>'.$uri.'</b>');
     $r->rflush();      $r->rflush();
                
     #Java script Progress window      #Java script Progress window
     &Create_PrgWin();      &Create_PrgWin();
     &Update_PrgWin("Starting to analyze problem",0,0,'');      &Update_PrgWin("Starting-to-analyze-problem");
     for(my $index=0; $index<(scalar @$students); $index++) {      for (my $index=0;$index<(scalar @$students);$index++) {
  &Update_PrgWin(scalar @$students, $index+1, $students->[$index]);   &Update_PrgWin($index);
  &OpStatus($problem, $students->[$index], $courseID);   &OpStatus($problem,$students->[$index],$courseID);
     }      }
     &Close_PrgWin();      &Close_PrgWin();
   
     $r->print('<br>');      $r->print('<br>');
     for(my $k=0; $k<$interval; $k++ ) {      for (my $k=0; $k<$interval; $k++ ) {
  &DrawGraph($k,$title);   &DrawGraph($k,$title);
     }      }
     for(my $k=0; $k<$interval; $k++ ) {      for (my $k=0; $k<$interval; $k++ ) {
  &DrawTable($k);   &DrawTable($k);
     }      }
 #$Apache::lonxml::debug=1;  #$Apache::lonxml::debug=1;
Line 212  sub ShowOpGraph { Line 396  sub ShowOpGraph {
     $r->print("<br><b>Here you can see the Problem:</b><br>$Answ");      $r->print("<br><b>Here you can see the Problem:</b><br>$Answ");
 }  }
   
   
 sub DrawTable {  sub DrawTable {
     my $k=shift;      my $k=shift;
     my $Max=0;      my $Max=0;
Line 266  sub DrawTable { Line 451  sub DrawTable {
   
   
 sub DrawGraph {  sub DrawGraph {
     my ($currentInterval,$title)=@_;      my ($k,$Src)=@_;
     my $Max=0;      my $Max=0;
     my @data1;      my @data1;
     my @data2;      my @data2;
   
     # Adjust Data and find the Max       # Adjust Data and find the Max 
     for(my $n=0; $n<=$#Concepts; $n++ ) {      for (my $n=0; $n<=$#Concepts; $n++ ) {
  my $tmp=$Concepts[$n];   my $tmp=$Concepts[$n];
  $data1[$n]=$ConceptData{$tmp.'.'.$currentInterval.'.true'};   $data1[$n]=$ConceptData{"$tmp.$k.true"};
  $data2[$n]=$ConceptData{$tmp.'.'.$currentInterval.'.false'};   $data2[$n]=$ConceptData{"$tmp.$k.false"};
  my $Sum=$data1[$n]+$data2[$n];   my $Sum=$data1[$n]+$data2[$n];
  if($Max < $Sum) { $Max = $Sum; }   if ( $Max<$Sum ) {$Max=$Sum;}
     }      }
     for(my $n=0; $n<=$#Concepts; $n++) {      for (my $n=0; $n<=$#Concepts; $n++ ) {
  if($data1[$n]+$data2[$n]<$Max) {   if ($data1[$n]+$data2[$n]<$Max) {
     $data2[$n]+=$Max-($data1[$n]+$data2[$n]);      $data2[$n]+=$Max-($data1[$n]+$data2[$n]);
  }   }
     }      }
     my $P_No = scalar @data1;      my $P_No = $#data1+1;
   
     if($Max > 1) {       if ( $Max > 1 ) { 
  $Max += (10 - $Max % 10);   $Max += (10 - $Max % 10);
  $Max = int($Max);   $Max = int($Max);
     } else {       } else { $Max = 1; }
         $Max = 1;  
     }  
   
     my $Titr=($ConceptData{'Interval'}>1) ?       my $Titr=($ConceptData{'Interval'}>1) ? $Src.'_interval_'.($k+1) : $Src;
         $title.'_interval_'.($currentInterval+1) : $title;  
 #    $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2;  #    $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2;
     $GData  = $Titr.'&Concepts&Answers&'.$Max.'&'.$P_No.'&';      $GData="$Titr&Concepts&Answers&$Max&$P_No&".
     $GData .= (join(',',@data1)).'&'.(join(',',@data2));             (join(',',@data1)).'&'.(join(',',@data2));
   
     $r->print('<IMG src="/cgi-bin/graph.gif?'.$GData.'" border=1/>');      $r->print('<IMG src="/cgi-bin/graph.gif?'.$GData.'" border=1/>');
 }  }
Line 312  sub Decide { Line 494  sub Decide {
     $ConceptData{"$foil_to_concept{$foil}.$k.$type"}++;      $ConceptData{"$foil_to_concept{$foil}.$k.$type"}++;
 }  }
   
   
 #restore the student submissions and finding the result  #restore the student submissions and finding the result
 sub OpStatus {  sub OpStatus {
     my ($problem, $student, $courseID)=@_;      my ($problem, $student, $courseID)=@_;
Line 356  sub OpStatus { Line 537  sub OpStatus {
     }      }
 }  }
   
   
 #---- END Analyze Web Page ----------------------------------------------  #---- END Analyze Web Page ----------------------------------------------
   
 #---- Problem Statistics Web Page ---------------------------------------  #---- Problem Statistics Web Page ---------------------------------------
Line 398  sub ProcessDiscriminant { Line 580  sub ProcessDiscriminant {
 }  }
   
   
   
 #------- Creating Discimination factor     #------- Creating Discimination factor   
 sub Discriminant {  sub Discriminant {
     my ($discriminantFactor)=@_;      my ($discriminantFactor)=@_;
Line 430  sub Discriminant { Line 613  sub Discriminant {
     return (\%DisUp, \%DisLow);      return (\%DisUp, \%DisLow);
 }  }
   
      
 sub NumericSort {            sub NumericSort {          
     $a <=> $b;      $a <=> $b;
 }  }
   
   
 sub CreateProblemStatisticsTableHeading {  sub CreateProblemStatisticsTableHeading {
     my ($displayFormat,$sequenceSource,$sequenceTitle,$headings)=@_;      my ($displayFormat,$sequenceSource,$sequenceTitle,$headings)=@_;
     if($displayFormat eq 'Display CSV Format') {      if($displayFormat eq 'Display CSV Format') {
Line 465  sub CloseTable { Line 650  sub CloseTable {
     $r->rflush();      $r->rflush();
 }  }
   
   
    
 # ------ Dump the Student's DB file and handling the data for statistics table   # ------ Dump the Student's DB file and handling the data for statistics table 
 sub ExtractStudentData {  sub ExtractStudentData {
     my ($cache,$name)=@_;      my ($cache,$name,$list)=@_;
     my %discriminantFactor;      my %discriminantFactor;
     my @list=();  
   
     my $totalTries = 0;      my $totalTries = 0;
     my $totalAwarded = 0;      my $totalAwarded = 0;
     my $tempProblemOrder=0;      my $tempProblemOrder=0;
       my $spent=0;
       my $spent_yes=0;
       my $TotDiscuss=0;
       my $TotalOpend = 0;
       my $ProbSolved = 0;
       my $ProbTot = 0;
       my $TotFirst = 0;
       my $TimeTot = 0;
       my $Discussed=0;
   
     foreach my $sequence (split(':', $cache->{'orderedSequences'})) {      foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
         if($cache->{'ProblemStatisticsMap'} ne 'All Maps'  &&          if($cache->{'ProblemStatisticsMap'} ne 'All Maps'  &&
            $cache->{'ProblemStatisticsMap'} ne $cache->{$sequence.':title'}) {             $cache->{'ProblemStatisticsMap'} ne $cache->{$sequence.':title'}) {
Line 525  sub ExtractStudentData { Line 721  sub ExtractStudentData {
                     my $tries=0;                      my $tries=0;
                     my $time=0;                      my $time=0;
                     my $awarded=0;                      my $awarded=0;
       $Discussed=0;
                     my $code='U';                      my $code='U';
   
                     $awarded = $cache->{$name.                      $awarded = $cache->{$name.
Line 571  sub ExtractStudentData { Line 768  sub ExtractStudentData {
                     $ptr .= "*(part $_)";                      $ptr .= "*(part $_)";
                     $Dis .= '&';                      $Dis .= '&';
                 }                  }
   
    my ($pr_no,$dod)=split('&',$ptr);
    my $DoDiff=$DoDiff{$dod};
   #               $r->print('<br>'.$name.'---'.$ptr.'==='.$DoDiff);
   
                 my $Fac = ($partData{$_.':Tries'}) ?                   my $Fac = ($partData{$_.':Tries'}) ? 
                     ($partData{$_.':awarded'}/$partData{$_.':tries'}) : 0;                      ($partData{$_.':awarded'}/$partData{$_.':tries'}) : 0;
                 my $DisF;                  my $DisF;
Line 579  sub ExtractStudentData { Line 781  sub ExtractStudentData {
                 } else {                  } else {
                     $DisF = $Fac;                      $DisF = $Fac;
                 }                  }
   
                   if ($Discuss{"$name:$problem"}) {
       $TotDiscuss++;
                       $Discussed=1;
                   }
                   my $time = $cache->{"$name:$LatestVersion:$problem:timestamp"};
                 $Dis .= $tempProblemOrder.'='.$DisF.'+'.$Yes;                  $Dis .= $tempProblemOrder.'='.$DisF.'+'.$Yes;
                 $ptr .= '&'.$partData{$_.'.Tries'}.                  $ptr .= '&'.$partData{$_.'.Tries'}.
                         '&'.$partData{$_.'.Wrongs'}.                          '&'.$partData{$_.'.Wrongs'}.
                         '&'.$partData{$_.'.Code'};                          '&'.$partData{$_.'.Code'};
                 push (@list, $ptr);                  push (@$list, $ptr."&$Discussed");
   
   #### if ($DoDiff>0.85) {
   
                   $TimeTot += $time;
   
                   if ($Yes==1 && $partData{$_.'.Tries'}==1) {
       $TotFirst++;
                   }
    my $Acts= $Activity{$name.':'.$problem};
    if ($Acts) {
       my $Pt=&ProcAct( $Acts, $time );
       #my ($spe,$beg) = split(/\+/,$Pt);
                       my $spe= $Pt;
       if ($Yes==1) {$spent_yes += $spe;}
       $spent += $spe;
       #$Beg += $beg;
   #                   $r->print('<br>'.$name.'---'.$problem.'---'.$spe);
    }
    $TotalOpend++;
    $ProbTot++;
   
                 $tempProblemOrder++;                  $tempProblemOrder++;
             }              }
         }          }
    my $pstr;
         if($totalTries) {          if($totalTries) {
     my $DisFac = ($totalAwarded/$totalTries);      my $DisFac = ($totalAwarded/$totalTries);
     my $DisFactor = sprintf( "%.4f", $DisFac );      my $DisFactor = sprintf( "%.4f", $DisFac );
     $discriminantFactor{$DisFactor}=$Dis;              my $TS = sprintf( "%.2f", $spent );
               my $TS_yes = sprintf( "%.2f", $spent_yes );
      # $DiscFac{$DisFactor}=$Dis;
       $pstr=$DisFactor.':'.$name.':'.$ProbTot.':'.$TotalOpend.':'.
                     $totalTries.':'.$ProbSolved.':'.$TotFirst.':'.
                     $TS_yes.':'.$TS.':'.$TotDiscuss;
       $discriminantFactor{$pstr}=$Dis;
  }   }
     }      }
   
     return (\%discriminantFactor, \@list);      return (\%discriminantFactor);
 }  }
   
   
   =pod
 sub MySort {            sub MySort {          
     if ( $Pos > 0 ) {      if ( $Pos > 0 ) {
  if ($ENV{'form.order'} eq 'Descending') {$b <=> $a;}   if ($ENV{'form.order'} eq 'Descending') {$b <=> $a;}
Line 607  sub MySort { Line 845  sub MySort {
  else { $a cmp $b; }   else { $a cmp $b; }
     }      }
 }  }
   =cut
   
 sub BuildStatisticsTable {  sub BuildStatisticsTable {
     my ($cache,$discriminantFactor,$list,$headings)=@_;      my ($cache,$discriminantFactor,$list,$headings,$students)=@_;
   
   #6666666
   #    my $file="/home/httpd/perl/tmp/183d.txt";
   #    open(OUT, ">$file");
   #6666666
       &Create_PrgWin();
   ##777777
   ##    &LoadActivityLog();
   ##    $r->print('<script>popwin.document.popremain.remaining.value="'.
   ##              'Loading Discussion...";</script>');
   ##    &LoadDoDiffFile();
       &LoadDiscussion();
   
     my $p_count = 0;      my $p_count = 0;
     my $nIndex = 0;      my $nIndex = 0;
Line 628  sub BuildStatisticsTable { Line 879  sub BuildStatisticsTable {
                                              $cache->{$sequence.':source'},                                                $cache->{$sequence.':source'}, 
                                              $cache->{$sequence.':title'},                                               $cache->{$sequence.':title'},
                                              $headings);                                               $headings);
   
   ##777777
   ##    &Classify($discriminantFactor, $students);
   
   
  my ($Hid,$pr)=split(/\:/,$mapsort{$_});   my ($Hid,$pr)=split(/\:/,$mapsort{$_});
  my @lpr=split(/\&/,$pr);   my @lpr=split(/\&/,$pr);
  for (my $i=1; $i<=$#lpr; $i++) {   for (my $i=1; $i<=$#lpr; $i++) {
     my %storestats=();      my %storestats=();
     my ($PrOrd,$Prob,$Tries,$Wrongs,$Code)=split(/\&/,$list->[$nIndex]);      my ($PrOrd,$Prob,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,$list->[$nIndex]);
     my $Temp = $Prob;      my $Temp = $Prob;
     my $MxTries = 0;      my $MxTries = 0;
     my $TotalTries = 0;      my $TotalTries = 0;
Line 640  sub BuildStatisticsTable { Line 896  sub BuildStatisticsTable {
     my $Incorrect = 0;      my $Incorrect = 0;
     my $Override = 0;      my $Override = 0;
     my $StdNo = 0;      my $StdNo = 0;
       my $DiscNo=0;
     my @StdLst;      my @StdLst;
     while ( $PrOrd == $lpr[$i] )       while ( $PrOrd == $lpr[$i] ) 
     {      {
Line 652  sub BuildStatisticsTable { Line 909  sub BuildStatisticsTable {
  elsif( $Code eq 'I' ) { $Incorrect++; }   elsif( $Code eq 'I' ) { $Incorrect++; }
  elsif( $Code eq 'O' ) { $Override++; }   elsif( $Code eq 'O' ) { $Override++; }
  elsif( $Code eq 'U' ) { $StdNo--; }   elsif( $Code eq 'U' ) { $StdNo--; }
  ($PrOrd,$Prob,$Tries,$Wrongs,$Code)=split(/\&/,$list->[$nIndex]);   ($PrOrd,$Prob,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,$list->[$nIndex]);
     }      }
   
     $p_count++;      $p_count++;
Line 732  sub BuildStatisticsTable { Line 989  sub BuildStatisticsTable {
                        $TotalTries.'&'.$MxTries.'&'.$Avg.'&'.                         $TotalTries.'&'.$MxTries.'&'.$Avg.'&'.
                        $YES.'&'.$Override.'&'.$Wrng.'&'.$DoD.'&'.                         $YES.'&'.$Override.'&'.$Wrng.'&'.$DoD.'&'.
        $SD.'&'.$Sk.'&'.$_D1.'&'.$_D2.'&'.         $SD.'&'.$Sk.'&'.$_D1.'&'.$_D2.'&'.
                        $Prob;                         $DiscNo.'&'.$Prob;
     $CachData{($p_count-1)}=$join;      $CachData{($p_count-1)}=$join;
   
   #6666666
   #    $r->print('<br>'.$out.'&'.$DoD);
   #            print (OUT $out.'@'.$DoD.'&');
   #6666666
   
     $urlres=~/^(\w+)\/(\w+)/;      $urlres=~/^(\w+)\/(\w+)/;
     if ($StdNo) {       if ($StdNo) { 
  &Apache::lonnet::put('resevaldata',\%storestats,$1,$2);    &Apache::lonnet::put('resevaldata',\%storestats,$1,$2); 
Line 745  sub BuildStatisticsTable { Line 1007  sub BuildStatisticsTable {
  &CloseTable($cache);   &CloseTable($cache);
     }      }
     &Close_PrgWin();      &Close_PrgWin();
   #666666
   #    close( OUT );
   #666666
 }  }
   
 =pod  =pod
Line 797  sub Cache_Statistics { Line 1062  sub Cache_Statistics {
  &CloseTable($cache);   &CloseTable($cache);
     }      }
 }  }
 =cut  =cut 
   
   
   
 sub TableRow {  sub TableRow {
     my ($cache,$Str,$Idx,$RealIdx)=@_;      my ($Str,$Idx,$RealIdx)=@_;
     my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,      my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,
        $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$Prob)=split(/\&/,$Str);         $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$DiscNo,$Prob)=split(/\&/,$Str);
     if($cache->{'DisplayFormat'} eq 'Display CSV Format') {      if ($ENV{'form.showcsv'}) {
         my ($ResId,$Dummy)=split(/\*/,$Prob);          my ($ResId,$Dummy)=split(/\*/,$Prob);
         my $Ptr =  "\n".'<br>'.          my $Ptr =  "\n".'<br>'.
                "\n".'"'.($RealIdx+1).'",'.                 "\n".'"'.($RealIdx+1).'",'.
Line 819  sub TableRow { Line 1087  sub TableRow {
                "\n".'"'.$SD.'",'.                 "\n".'"'.$SD.'",'.
                "\n".'"'.$Sk.'",'.                 "\n".'"'.$Sk.'",'.
                "\n".'"'.$_D1.'",'.                 "\n".'"'.$_D1.'",'.
        "\n".'"'.$_D2.'"';         "\n".'"'.$_D2.'"'.
          "\n".'"'.$DiscNo.'"';
   
         $r->print("\n".$Ptr);          $r->print("\n".$Ptr);
     } else {      }
       else{
         my $Ptr =  "\n".'<tr>'.          my $Ptr =  "\n".'<tr>'.
                "\n".'<td>'.($RealIdx+1).'</td>'.                 "\n".'<td>'.($RealIdx+1).'</td>'.
           #     "\n".'<td>'.$PrOrd.$Temp.'</td>'.            #     "\n".'<td>'.$PrOrd.$Temp.'</td>'.
Line 837  sub TableRow { Line 1108  sub TableRow {
                "\n".'<td bgcolor='.$color{"green"}.'> '.$SD.'</td>'.                 "\n".'<td bgcolor='.$color{"green"}.'> '.$SD.'</td>'.
                "\n".'<td bgcolor='.$color{"green"}.'> '.$Sk.'</td>'.                 "\n".'<td bgcolor='.$color{"green"}.'> '.$Sk.'</td>'.
                "\n".'<td bgcolor='.$color{"purple"}.'> '.$_D1.'</td>'.                 "\n".'<td bgcolor='.$color{"purple"}.'> '.$_D1.'</td>'.
        "\n".'<td bgcolor='.$color{"purple"}.'> '.$_D2.'</td>';         "\n".'<td bgcolor='.$color{"purple"}.'> '.$_D2.'</td>'.
                  "\n".'<td bgcolor='.$color{"yellow"}.'> '.$DiscNo.'</td>';
         $r->print("\n".$Ptr.'</tr>' );          $r->print("\n".$Ptr.'</tr>' );
     }      }
     $GraphDat{$RealIdx}=$DoD.':'.$Wrng;      $GraphDat{$RealIdx}=$DoD.':'.$Wrng;
 }  }
   
 sub StatusOptions {  sub StatusOptions {
     my ($cache)=@_;      my ($cache)=@_;
   
Line 965  sub ProblemStatisticsLegend { Line 1236  sub ProblemStatisticsLegend {
     $Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>';      $Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>';
     $Ptr .= '<b>2nd Criterion</b> for Sorting the Students: ';      $Ptr .= '<b>2nd Criterion</b> for Sorting the Students: ';
     $Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>';      $Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>';
       $Ptr .= '</td>';
       $Ptr .= '<td><b>Disc.</b></td>';
       $Ptr .= '<td>Number of Students had at least one discussion.';
     $Ptr .= '</td></tr></table>';      $Ptr .= '</td></tr></table>';
   
     return $Ptr;      return $Ptr;
Line 974  sub ProblemStatisticsLegend { Line 1248  sub ProblemStatisticsLegend {
   
 #---- Problem Statistics Graph Web Page --------------------------------------  #---- Problem Statistics Graph Web Page --------------------------------------
   
   # ------------------------------------------- Prepare data for Graphical chart
   
 sub GetGraphData {  sub GetGraphData {
     my ($whichGraph, $courseID)=@_;      my $ylab = shift;
     my $Col=0;      my $Col;
     my $graphTitle='';  
     my $data='';      my $data='';
     my $count = 0;      my $count = 0;
     my $Max = 0;      my $Max = 0;
     my $graphData='Graph data does not exist.';      my $cid=$ENV{'request.course.id'};
     my $GraphDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".      my $GraphDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
                   "_$ENV{'user.domain'}_$courseID\_graph.db";                    "_$ENV{'user.domain'}_$cid\_graph.db";
     if(-e $GraphDB) {      foreach (keys %GraphDat) {delete $GraphDat{$_};}
  if(tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) {      if (-e "$GraphDB") {
     if($whichGraph eq 'DiffGraph') {   if (tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) {
  $graphTitle = 'Degree-of-Difficulty';      if ( $ylab eq 'DoDiff Graph' ) {
    $ylab = 'Degree-of-Difficulty';
  $Col = 0;   $Col = 0;
     } else {      }
  $graphTitle = 'Wrong-Percentage';      else {
    $ylab = 'Wrong-Percentage';
  $Col = 1;   $Col = 1;
     }      }
     foreach (sort NumericSort keys %GraphDat) {       foreach (sort NumericSort keys %GraphDat) { 
  my @Temp=split(/\:/,$GraphDat{$_});   my @Temp=split(/\:/,$GraphDat{$_});
                 my $inf = $Temp[$Col];                   my $inf = $Temp[$Col]; 
  if($Max < $inf) {   if ( $Max < $inf ) {$Max = $inf;}
                     $Max = $inf;  
                 }  
  $data .= $inf.',';   $data .= $inf.',';
  $count++;   $count++;
     }      }
     if($Max > 1) {       if ( $Max > 1 ) { 
  $Max += (10 - $Max % 10);   $Max += (10 - $Max % 10);
  $Max = int($Max);   $Max = int($Max);
     } else {       }
                 $Max = 1;      else { $Max = 1; }
             }  
             untie(%GraphDat);              untie(%GraphDat);
     my $Course = $ENV{'course.'.$courseID.'.description'};      my $Course = $ENV{'course.'.$cid.'.description'};
     $Course =~ s/\ /"_"/eg;      $Course =~ s/\ /"_"/eg;
     $graphData  = $Course.'&'.'Problems'.'&'.$graphTitle.'&'.$Max.'&';      $GData=$Course.'&'.'Problems'.'&'.$ylab.'&'.$Max.'&'.$count.'&'.$data;
             $graphData .= $count.'&'.$data;   }
  } else {   else {
     $graphData = "Unable to tie hash to db file";      $r->print("Unable to tie hash to db file");
  }   }
     }      }
   
     return $graphData;  
 }  }
   
 #---- END Problem Statistics Graph Web Page ----------------------------------  
   
 #---- Problem Analysis Web Page ----------------------------------------------  #---- Problem Analysis Web Page ----------------------------------------------
   
 sub IntervalOptions {  sub IntervalOptions {
Line 1581  sub initial { Line 1850  sub initial {
     undef %CachData;      undef %CachData;
     undef %GraphDat;      undef %GraphDat;
     undef %ConceptData;      undef %ConceptData;
     undef $Pos;  
     undef $GData;      undef $GData;
 }  }
   
Line 1613  sub BuildProblemStatisticsPage { Line 1881  sub BuildProblemStatisticsPage {
     $r->print(&ProblemStatisticsLegend());      $r->print(&ProblemStatisticsLegend());
   
 #    my $discriminantFactor;  #    my $discriminantFactor;
 #    my $list;  #    my @list=();
 #    foreach (@$students) {  #    foreach (@$students) {
 #        ($discriminantFactor, $list) = &ExtractStudentData($_);  #        ($discriminantFactor, $list) = &ExtractStudentData(\%cache, $_,
   #                                                           \@list);
 #    }  #    }
   
 #    my ($upper, $lower) = &Discriminant($discriminantFactor);  #    my ($upper, $lower) = &Discriminant($discriminantFactor);
 #    my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod",  #    my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod",
 #                  4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff",  #                  4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff",
 #                  9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd");  #                  9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc.");
 #    &BuildStatisticsTable(\%cache, $discriminantFactor, $list, \%Header);  #    &BuildStatisticsTable(\%cache, $discriminantFactor, \@list, \%Header, 
   #                           $students);
   
     $r->print('</form>');      $r->print('</form>');
   

Removed from v.1.27  
changed lines
  Added in v.1.28


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>