Diff for /loncom/interface/Attic/lonchart.pm between versions 1.30 and 1.38

version 1.30, 2002/02/19 18:58:10 version 1.38, 2002/05/09 17:06:09
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 #  
 # Homework Performance Chart  # Homework Performance Chart
 #  #
 # (Navigate Maps Handler  # (Navigate Maps Handler
Line 43 Line 42
 # 9/8 Gerd Kortemeyer  # 9/8 Gerd Kortemeyer
 # 10/1, 10/19, 11/17, 11/22, 11/24, 11/28 12/18 Behrouz Minaei  # 10/1, 10/19, 11/17, 11/22, 11/24, 11/28 12/18 Behrouz Minaei
 # YEAR=2002  # YEAR=2002
 # 2/1, 2/6, 2/19 Behrouz Minaei  # 2/1, 2/6, 2/19, 2/28 Behrouz Minaei
 #  #
 ###  ###
   
Line 64  my @rowlabels; Line 63  my @rowlabels;
 my @students;  my @students;
 my @PreCol;  my @PreCol;
 my $r;  my $r;
    
 # ------------------------------------------------------------- Find out status  # ------------------------------------------------------------- Find out status
   
 sub ExtractStudentData {  sub ExtractStudentData {
Line 88  sub ExtractStudentData { Line 87  sub ExtractStudentData {
             substr($rowlabels[$index].              substr($rowlabels[$index].
             '                                                        ',0,45).' ! ';              '                                                        ',0,45).' ! ';
     unless ($reply=~/^error\:/) {      unless ($reply=~/^error\:/) {
         map {          foreach (split(/\&/,$reply)) {
             my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_));              my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_));
             $result{$name}=$value;              $result{$name}=$value;
         } split(/\&/,$reply);          }
  $ProbNo = 0;   $ProbNo = 0;
  $ProbTotal = 0;   $ProbTotal = 0;
         $ProbSolved = 0;          $ProbSolved = 0;
Line 109  sub ExtractStudentData { Line 108  sub ExtractStudentData {
     my $meta=$hash{'src_'.$ResId};      my $meta=$hash{'src_'.$ResId};
     my $PartNo = 0;      my $PartNo = 0;
     undef %TempHash;      undef %TempHash;
     map {      foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) {
  if ($_=~/^stores\_(\d+)\_tries$/) {   if ($_=~/^stores\_(\d+)\_tries$/) {
                     my $Part=&Apache::lonnet::metadata($meta,$_.'.part');                      my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
     if ( $TempHash{"$Part"} eq '' ) {       if ( $TempHash{"$Part"} eq '' ) { 
Line 119  sub ExtractStudentData { Line 118  sub ExtractStudentData {
  $PartNo++;   $PartNo++;
     }      }
  }   }
             } split(/\,/,&Apache::lonnet::metadata($meta,'keys'));              }
   
             my $Prob = &Apache::lonnet::declutter( $hash{'map_id_'.$1} ).              my $Prob = &Apache::lonnet::symbclean(
                          &Apache::lonnet::declutter( $hash{'map_id_'.$1} ).
                        '___'.$2.'___'.                         '___'.$2.'___'.
                        &Apache::lonnet::declutter( $hash{'src_'.$ResId} );                         &Apache::lonnet::declutter( $hash{'src_'.$ResId} ));
             $Code=' ';              $Code=' ';
             $Tries = 0;              $Tries = 0;
      $LatestVersion = $result{"version:$Prob"};       $LatestVersion = $result{"version:$Prob"};
Line 149  sub ExtractStudentData { Line 149  sub ExtractStudentData {
     $TempHash{"$Part.Code"} = $Code;      $TempHash{"$Part.Code"} = $Code;
  }   }
          }           }
                 }                   }
   # Actually append problem to output (all parts)
                   $Str.='<a href="/adm/grades?symb='.
                   &Apache::lonnet::escape($Prob).
                   '&student='.$sname.'&domain='.$sdom.'&command=submission">'; 
  for ( my $n = 0; $n < $PartNo; $n++ ) {     for ( my $n = 0; $n < $PartNo; $n++ ) {  
     my $part = $TempHash{$n};      my $part = $TempHash{$n};
     my $Code = $TempHash{"$part.Code"};      my $Code = $TempHash{"$part.Code"};
Line 164  sub ExtractStudentData { Line 168  sub ExtractStudentData {
     $Str .= $TempHash{"$part.Code"};      $Str .= $TempHash{"$part.Code"};
     if ( $Code ne 'x' ) {$ProbTotal++;}      if ( $Code ne 'x' ) {$ProbTotal++;}
  }   }
                   $Str.='</a>';
             }                 }   
     else {      else {
  for(my $n=0; $n<$PartNo; $n++) {   for(my $n=0; $n<$PartNo; $n++) {
Line 217  sub tracetable { Line 222  sub tracetable {
           }            }
        }         }
        if (defined($hash{'to_'.$rid})) {         if (defined($hash{'to_'.$rid})) {
           map {            foreach (split(/\,/,$hash{'to_'.$rid})){
               &tracetable($hash{'goesto_'.$_},$beenhere);                &tracetable($hash{'goesto_'.$_},$beenhere);
           } split(/\,/,$hash{'to_'.$rid});            }
        }         }
     }      }
 }  }
   
   sub usection {
       my ($udom,$unam,$courseid,$ActiveFlag)=@_;
       $courseid=~s/\_/\//g;
       $courseid=~s/^(\w)/\/$1/;
       foreach (split(/\&/,&Apache::lonnet::reply('dump:'.
                $udom.':'.$unam.':roles',
                &Apache::lonnet::homeserver($unam,$udom)))){
           my ($key,$value)=split(/\=/,$_);
           $key=&Apache::lonnet::unescape($key);
           if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
               my $section=$1;
               if ($key eq $courseid.'_st') { $section=''; }
       my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value));
       if ( $ActiveFlag ne 'Any' ) {
    my $now=time;
    my $notactive=0;
    if ($start) {
       if ($now<$start) { $notactive=1; }
    }
    if ($end) {
       if ($now>$end) { $notactive=1; }
    }
    if ((($ActiveFlag eq 'Expired') && $notactive == 1) || 
                       (($ActiveFlag eq 'Active') && $notactive == 0 ) ) {
       return $section;
    }
    else { return '-1'; } 
       }
       return $section;
           }
       }
       return '-1';
   }
   
 sub BuildChart {  sub BuildChart {
 # ----------------------- Get first and last resource, see if there is anything  # ----------------------- Get first and last resource, see if there is anything
Line 239  sub BuildChart { Line 277  sub BuildChart {
                             ('dump:'.$cdom.':'.$cnum.':classlist',$chome);                              ('dump:'.$cdom.':'.$cnum.':classlist',$chome);
  my $now=time;   my $now=time;
  unless ($classlst=~/^error\:/) {   unless ($classlst=~/^error\:/) {
     map {      foreach my $KeyPoint(sort split(/\&/,$classlst)) {
  my ($name,$value)=split(/\=/,$_);   my ($name,$value)=split(/\=/,$KeyPoint);
  my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value));   my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value));
  my $active=1;   my $active=1;
  if (($end) && ($now>$end)) { $active=0; }   my $Status=$ENV{'form.status'};
    $Status = ($Status) ? $Status : 'Active';
    if ( ( ($end) && $now > $end ) && 
                        ( ($Status eq 'Active') ) ) { $active=0; }
   
    if ( ($Status eq 'Expired') && 
                        ($end == 0 || $now < $end) ) { $active=0; }
   
  if ($active) {   if ($active) {
     my $thisindex=$#students+1;      my $thisindex=$#students+1;
     $name=&Apache::lonnet::unescape($name);      $name=&Apache::lonnet::unescape($name);
     $students[$thisindex]=$name;      $students[$thisindex]=$name;
     my ($sname,$sdom)=split(/\:/,$name);      my ($sname,$sdom)=split(/\:/,$name);
     $PreCol[$thisindex]=$sname.':';      $PreCol[$thisindex]=$sname.':';
     my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);      my $ssec=&usection($sdom,$sname,$cid,$Status);
     if ($ssec==-1) {      if ($ssec==-1) {
  $rowlabels[$thisindex]=   $rowlabels[$thisindex]=
     '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:lastname&generation&firstname&middlename',                                    ':environment:lastname&generation&firstname&middlename',
                                                  &Apache::lonnet::homeserver($sname,$sdom));                                    &Apache::lonnet::homeserver($sname,$sdom));
  #$ssec=(int($ssec)) ? int($ssec) : $ssec;   #$ssec=(int($ssec)) ? int($ssec) : $ssec;
  $rowlabels[$thisindex]=   my $sec=sprintf('%3s',$ssec);
     sprintf('%3s',$ssec).' '.$reply{$sname}.' ';   $rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';
  $PreCol[$thisindex] .= $reply.':'.$ssec;   $PreCol[$thisindex] .= $reply.':'.$sec;
  my $i=0;   my $i=0;
  map {   foreach (split(/\&/,$reply)) {
     $i++;      $i++;
     if ( $_ ne '') {      if ( $_ ne '') {
  $rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';   $rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';
Line 273  sub BuildChart { Line 319  sub BuildChart {
  chop($rowlabels[$thisindex]);   chop($rowlabels[$thisindex]);
  $rowlabels[$thisindex].=', ';   $rowlabels[$thisindex].=', ';
     }      }
  } split(/\&/,$reply);   }
     }      }
  }   }
     } sort split(/\&/,$classlst);      }
   
  } else {   } else {
     $r->print('<h1>Could not access course data</h1>');      $r->print('<h1>Could not access course data</h1>');
Line 306  sub BuildChart { Line 352  sub BuildChart {
 }  }
   
 sub CreateForm {  sub CreateForm {
       my $OpSel1='';
       my $OpSel2='';
       my $OpSel3='';
       my $Status = $ENV{'form.status'};
       if ( $Status eq 'Any' ) { $OpSel3='selected'; }
       elsif ($Status eq 'Expired' ) { $OpSel2 = 'selected'; }
       else { $OpSel1 = 'selected'; }
   
     my $Ptr = '<form name=stat method=post action="/adm/chart" >'."\n";      my $Ptr = '<form name=stat method=post action="/adm/chart" >'."\n";
     $Ptr .= '<b> Sort by: &nbsp; </b>'."\n";      $Ptr .= '<b> Sort by: &nbsp; </b>'."\n";
     $Ptr .= '&nbsp;&nbsp;&nbsp;';      $Ptr .= '&nbsp;&nbsp;&nbsp;';
     $Ptr .= '<input type=submit name=sort value="Email Name" />'."\n";      $Ptr .= '<input type=submit name=sort value="User Name" />'."\n";
     $Ptr .= '&nbsp;&nbsp;&nbsp;';      $Ptr .= '&nbsp;&nbsp;&nbsp;';
     $Ptr .= '<input type=submit name=sort value="Last Name" />'."\n";      $Ptr .= '<input type=submit name=sort value="Last Name" />'."\n";
     $Ptr .= '&nbsp;&nbsp;&nbsp;';      $Ptr .= '&nbsp;&nbsp;&nbsp;';
     $Ptr .= '<input type=submit name=sort value="Section"/>'."\n";      $Ptr .= '<input type=submit name=sort value="Section"/>'."\n";
     $Ptr .= '<br>';      $Ptr .= '<br><br>';
       $Ptr .= '<b> Student Status: &nbsp; </b>'."\n".
               '<select name="status">'. 
               '<option '.$OpSel1.' >Active</option>'."\n".
               '<option '.$OpSel2.' >Expired</option>'."\n".
       '<option '.$OpSel3.' >Any</option> </select> '."\n";
       $Ptr .= '&nbsp;&nbsp;&nbsp;';
     $Ptr .= '<input type=submit name=sort value="Recalculate Chart"/>'."\n";      $Ptr .= '<input type=submit name=sort value="Recalculate Chart"/>'."\n";
     $Ptr .= '</form>'."\n";      $Ptr .= '</form>'."\n";
     $r->print( $Ptr );      $r->print( $Ptr );
 }  }
   
 sub CacheChart {  sub CacheChart {
     my @list = ();      my %list = ();
     my $count=0;      my $count=0;
   
     my $Pos = $ENV{'form.sort'};      my $Pos = $ENV{'form.sort'};
Line 332  sub CacheChart { Line 392  sub CacheChart {
     foreach my $key( keys %CachData) {       foreach my $key( keys %CachData) { 
  my @Temp=split(/\:/,$key);   my @Temp=split(/\:/,$key);
  my $Use = $Temp[$Pos];   my $Use = $Temp[$Pos];
  $list[$count]=$Use.$key.'*'.$CachData{$key};   $list{$Use.$key}=$key;
  $count++;   $count++;
     }      }
   
     @list = sort (@list);      my @order = sort(keys(%list));
   
     $r->print('<h3>'.$count.' students</h3>');      $r->print('<h3>'.$count.' students</h3>');
     &CreateForm();      &CreateForm();
Line 344  sub CacheChart { Line 404  sub CacheChart {
           
     $r->print('<p><pre>');      $r->print('<p><pre>');
     for ( my $n; $n < $count; $n++) {      for ( my $n; $n < $count; $n++) {
  my ($dummy, $Line) = split(/\*/,$list[$n]);   $r->print($CachData{$list{$order[$n]}}.'<br>');
  $r->print($Line.'<br>');  
     }      }
     $r->print('</pre>');      $r->print('</pre>');
 }  }
Line 459  sub handler { Line 518  sub handler {
 }  }
 1;  1;
 __END__  __END__
   
   
   
   
   
   
   

Removed from v.1.30  
changed lines
  Added in v.1.38


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