Diff for /loncom/interface/Attic/lonchart.pm between versions 1.1 and 1.18

version 1.1, 2001/01/31 23:21:06 version 1.18, 2001/11/28 17:52:00
Line 11 Line 11
 # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23,  # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23,
 # 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer)  # 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer)
 #  #
 # 3/1/1,6/1,17/1,29/1,30/1 Gerd Kortemeyer)  # 3/1/1,6/1,17/1,29/1,30/1,31/1 Gerd Kortemeyer)
 #  # 7/10/01 Behrouz Minaei
 # 1/31 Gerd Kortemeyer  # 9/8 Gerd Kortemeyer
   # 10/18/01, 10/19/01 Behrouz Minaei
   # 11/17/01, 11/22/01, 11/24/01 Behrouz Minaei
   
 package Apache::lonchart;  package Apache::lonchart;
   
Line 28  my %hash; Line 30  my %hash;
 my @cols;  my @cols;
 my @rowlabels;  my @rowlabels;
 my @students;  my @students;
   my $r;
   
 # ------------------------------------------------------------- Find out status  # ------------------------------------------------------------- Find out status
   
 sub astatus {  sub ExtractStudentData {
     my $rid=shift;      my ($index,$coid)=@_;
     my $code=' ';      my ($sname,$sdom) = split( /\:/, $students[$index] );
     $rid=~/(\d+)\.(\d+)/;      my $shome=&Apache::lonnet::homeserver( $sname,$sdom );          
     my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.      my $reply=&Apache::lonnet::reply('dump:'.$sdom.':'.$sname.':'.$coid,$shome );
      &Apache::lonnet::declutter($hash{'src_'.$rid});      my %result=();
     my $answer=&Apache::lonnet::reply(      my $ResId;
               "restore:$ENV{'user.domain'}:$ENV{'user.name'}:".      my $Code;
               $ENV{'request.course.id'}.':'.      my $Tries;
               &Apache::lonnet::escape($symb),      my $Wrongs;
               "$ENV{'user.home'}");      my %TempHash;
     my %returnhash=();      my $Version;
     map {      my $ProbNo;
  my ($name,$value)=split(/\=/,$_);      my $PrTotal;
         $returnhash{&Apache::lonnet::unescape($name)}=      my $LatestVersion;            
                     &Apache::lonnet::unescape($value);  
     } split(/\&/,$answer);      my $test = $ENV{'request.course.fn'};
     if ($returnhash{'version'}) {      my $comp = '/home/httpd/perl/tmp/minaeibi_msu_12679c3ed543a25msul1'; 
        my $version;                 
        for ($version=1;$version<=$returnhash{'version'};$version++) {      my $Str=substr($students[$index].
           map {              '                                                        ',0,14).' ! '.
              $returnhash{$_}=$returnhash{$version.':'.$_};              substr($rowlabels[$index].
           } split(/\:/,$returnhash{$version.':keys'});              '                                                        ',0,45).' ! ';
        }      unless ($reply=~/^error\:/) {
        my $totaltries=0;          map {
        map {              my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_));
            if (($_=~/\.(\w+)\.solved$/) && ($_!~/^\d+\:/)) {              $result{$name}=$value;
                my $part=$1;          } split(/\&/,$reply);
        if ($returnhash{$_} eq 'correct_by_student') {   $ProbNo = 0;
                    unless (($code eq '.') || ($code eq '-')) { $code='*'; }   $PrTotal = 0;
                    $totaltries+=$returnhash{'resource.'.$part.'.tries'};   my $IterationNo = 0;
                } elsif ($returnhash{$_} eq 'correct_by_override') {          foreach $ResId (@cols) {
                    unless (($code eq '.') || ($code eq '-')) { $code='+'; }      if ($IterationNo == 0) {$IterationNo++; next;}
                } elsif ($returnhash{$_} eq 'incorrect_attempted') {      if (!$ResId) { 
                    $code='.';   my $PrNo = sprintf( "%3d", $ProbNo );
                } elsif ($returnhash{$_} eq 'incorrect_by_override') {   $Str .= ' '.'<font color="#007700">'.$PrNo.'</font> ';
                    $code='-';   $PrTotal += $ProbNo;
                } elsif ($returnhash{$_} eq 'excused') {   $ProbNo=0;
                    unless (($code eq '.') || ($code eq '-')) { $code='x'; }   next; 
                }      }
            }              $ResId=~/(\d+)\.(\d+)/;
        } keys %returnhash;      my $meta=$hash{'src_'.$ResId};
        if (($code eq '*') && ($totaltries<10)) { $code="$totaltries"; }      my $PartNo = 0;
       undef %TempHash;
       map {
    if ($_=~/^stores\_(\d+)\_tries$/) {
                       my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
       if ( $TempHash{"$Part"} eq '' ) { 
    $TempHash{"$Part"} = $Part;
    $TempHash{$PartNo}=$Part;
    $TempHash{"$Part.Code"} = ' ';  
    $PartNo++;
       }
    }
               } split(/\,/,&Apache::lonnet::metadata($meta,'keys'));
   
               my $Prob = &Apache::lonnet::declutter( $hash{'map_id_'.$1} ).
                          '___'.$2.'___'.
                          &Apache::lonnet::declutter( $hash{'src_'.$ResId} );
               $Code=' ';
               $Tries = 0;
        $LatestVersion = $result{"version:$Prob"};
   
               if ( $LatestVersion ) {
    for ( my $Version=1; $Version<=$LatestVersion; $Version++ ) {
       my $vkeys = $result{"$Version:keys:$Prob"};
       my @keys = split(/\:/,$vkeys);  
   
       foreach my $Key (@keys) {  
    if (($Key=~/\.(\w+)\.solved$/) && ($Key!~/^\d+\:/)) {
       my $Part = $1;
       $Tries = $result{"$Version:$Prob:resource.$Part.tries"};
       #if ($Tries) {$TempHash{"$Part.Tries"}=$Tries;}
       #my $Val = $result{"$Version:$Prob:$Key"};
       my $Val = $result{"$Version:$Prob:resource.$Part.solved"};
       if ($Val eq 'correct_by_student'){
                                   $Code='*';
                                   $TempHash{$Part.'.Tries'}=$Tries;
                               } 
       elsif ($Val eq 'correct_by_override'){$Code = '+';}                        
       elsif ($Val eq 'incorrect_attempted'){$Code = '.';} 
       elsif ($Val eq 'incorrect_by_override'){$Code = '-';}
       elsif ($Val eq 'excused'){$Code = 'x';}
       else {$Code = ' ';}
       $TempHash{"$Part.Code"} = $Code;
   #            if ($test=~/*minaeibi*/) {
    $r->print($Key."  PartNo =$PartNo "." Tries=$Tries!<br>$Version:$Prob:resource.$Part.tries".' = '.$result{"$Version:$Prob:resource.$Part.tries"}."  $Val "."($Code)".'<br>');
   #    }
    }
            }
                   } 
   
    for ( my $n = 0; $n < $PartNo; $n++ ) {  
       my $part = $TempHash{$n};
                       if ($TempHash{$part.'.Code'} eq '*') {
    $ProbNo++;
                           if ($TempHash{$part.'.Tries'}<10) {
       $TempHash{$part.'.Code'}=$Tries;
    }
                       }
       $Str .= $TempHash{$part.'.Code'};
       $r->print($n.") Part=".$part."  code=$TempHash{$part.'.Code'}<br>");
    }
               }   
       else {for(my $n=0; $n<$PartNo; $n++) {$Str.=' ';}}
           } 
     }      }
     return $code;      my $PrTot = sprintf( "%5d", $PrTotal );
       $Str .= ' '.'<font color="#000088">'.$PrTot.'</font> ';
   
       return $Str ;
 }  }
   
   
 # ------------------------------------------------------------ Build page table  # ------------------------------------------------------------ Build page table
   
 sub tracetable {  sub tracetable {
     my ($rid,$beenhere)=@_;      my ($rid,$beenhere)=@_;
     unless ($beenhere=~/\&$rid\&/) {      unless ($beenhere=~/\&$rid\&/) {
        $beenhere.=$rid.'&';           $beenhere.=$rid.'&';  
   # new ... updating the map according to sequence and page
        if (defined($hash{'is_map_'.$rid})) {         if (defined($hash{'is_map_'.$rid})) {
            if ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}      my $cmap=$hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}};
             eq 'sequence') {              if ( $cmap eq 'sequence' || $cmap eq 'page' ) { 
                $cols[$#cols+1]=0;                  $cols[$#cols+1]=0; 
            }             }
            if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&             if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
Line 123  sub tracetable { Line 194  sub tracetable {
 # ================================================================ Main Handler  # ================================================================ Main Handler
   
 sub handler {  sub handler {
   my $r=shift;    $r=shift;
   
   if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {    if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
 # ------------------------------------------- Set document type for header only  # ------------------------------------------- Set document type for header only
Line 164  sub handler { Line 235  sub handler {
 # ---------------------------------------------------------------- Course title  # ---------------------------------------------------------------- Course title
   
     $r->print('<h1>'.      $r->print('<h1>'.
             $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.'</h1>');      $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.'</h1><h3>'.
       localtime()."</h3><p><pre>1..9: correct by student in 1..9 tries\n".
                               "   *: correct by student in more than 9 tries\n".
                       "   +: correct by override\n".
                               "   -: incorrect by override\n".
                       "   .: incorrect attempted\n".
                               "    : not attempted\n".
                       "   x: excused</pre><p>");
     
 # ------------------------------- This is going to take a while, produce output  # ------------------------------- This is going to take a while, produce output
   
              $r->rflush();               $r->rflush();
Line 208  sub handler { Line 285  sub handler {
                       'Data not available: '.$name;                        'Data not available: '.$name;
                 } else {                  } else {
                     my %reply=&Apache::lonnet::idrget($sdom,$sname);                      my %reply=&Apache::lonnet::idrget($sdom,$sname);
                     my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname.      my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname.
       ':environment:firstname&middlename&lastname&generation',                                                       ':environment:lastname&generation&firstname&middlename',
                       &Apache::lonnet::homeserver($sname,$sdom));                                                       &Apache::lonnet::homeserver($sname,$sdom));
                     $rowlabels[$thisindex]=                      $rowlabels[$thisindex]=
                       $ssec.' '.$reply{$sname}.' ';                        sprintf('%3s',$ssec).' '.$reply{$sname}.' ';
                       my $i=0;
                     map {                      map {
                      $rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';                        $i++;
                         if ( $_ ne '') {
                           $rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';
                         }
                         if ($i == 2) {
                           chop($rowlabels[$thisindex]);
                           $rowlabels[$thisindex].=', ';
                         }
                     } split(/\&/,$reply);                      } split(/\&/,$reply);
   
                 }                  }
             }              }
         } sort split(/\&/,$classlst);          } sort split(/\&/,$classlst);
Line 237  sub handler { Line 323  sub handler {
                           $r->print('<p><pre>');                            $r->print('<p><pre>');
    my $index;     my $index;
                            for ($index=0;$index<=$#students;$index++) {                             for ($index=0;$index<=$#students;$index++) {
                               $r->print(                                $r->print(&ExtractStudentData($index,$cid).'<br>');
                                        substr($students[$index].  
        '                                                        ',0,14).' ! '.  
  substr($rowlabels[$index].  
        '                                                        ',0,45).' ! ');  
                               map {  
                                   if ($_) {  
                                      $r->print(&astatus($_,$students[$index]));  
                                   } else {  
                                      $r->print(' ! ');  
                                   }  
                               } @cols;  
                               $r->print("\n");  
                               $r->rflush();                                $r->rflush();
                           }                            }
                           $r->print('</pre>');                            $r->print('</pre>');

Removed from v.1.1  
changed lines
  Added in v.1.18


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