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

version 1.34, 2002/02/28 23:25:50 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 121  sub ExtractStudentData { Line 120  sub ExtractStudentData {
  }   }
             }              }
   
             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 224  sub tracetable { Line 229  sub tracetable {
     }      }
 }  }
   
   
 sub usection2 {  
     my ($udom,$unam,$courseid,$ActiveFlag)=@_;  
     $courseid=~s/\_/\//g;  
     $courseid=~s/^(\w)/\/$1/;  
     foreach my $elem(split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',  
                      &Apache::lonnet::homeserver($unam,$udom)))) {  
         my ($key,$value)=split(/\=/,$elem);  
         $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));  
             my $now=time;  
             my $notactive=0;  
             if ($start) {  
  if ($now<$start) { $notactive=1; }  
             }  
             if ($end) {  
                 if ($now>$end) { $notactive=1; }  
             }   
     if ($ActiveFlag == 1) { $notactive=0; }  
             unless ($notactive) { return $section; }  
         }  
     }  
     return '-1';  
 }  
   
   
 sub usection {  sub usection {
     my ($udom,$unam,$courseid)=@_;      my ($udom,$unam,$courseid,$ActiveFlag)=@_;
     $courseid=~s/\_/\//g;      $courseid=~s/\_/\//g;
     $courseid=~s/^(\w)/\/$1/;      $courseid=~s/^(\w)/\/$1/;
     foreach (split(/\&/,&Apache::lonnet::reply('dump:'.      foreach (split(/\&/,&Apache::lonnet::reply('dump:'.
Line 266  sub usection { Line 242  sub usection {
             my $section=$1;              my $section=$1;
             if ($key eq $courseid.'_st') { $section=''; }              if ($key eq $courseid.'_st') { $section=''; }
     my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value));      my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value));
 #            $section=($section) ? $section : '(none)';      if ( $ActiveFlag ne 'Any' ) {
 #            $section=(int($section)) ? int($section) : $section;   my $now=time;
 #            $r->print($unam.'...'.$section.'<br>');   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 $section;
         }          }
     }      }
     #} split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',      return '-1';
     #                    &Apache::lonnet::homeserver($unam,$udom)));  
     return '';  
 }  }
   
 sub BuildChart {  sub BuildChart {
Line 295  sub BuildChart { Line 281  sub BuildChart {
  my ($name,$value)=split(/\=/,$KeyPoint);   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 ($ENV{'form.active'} eq 'All Students') { $active=1; }   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;
Line 305  sub BuildChart { Line 295  sub BuildChart {
     $students[$thisindex]=$name;      $students[$thisindex]=$name;
     my ($sname,$sdom)=split(/\:/,$name);      my ($sname,$sdom)=split(/\:/,$name);
     $PreCol[$thisindex]=$sname.':';      $PreCol[$thisindex]=$sname.':';
       my $ssec=&usection($sdom,$sname,$cid,$Status);
     my $ssec=&usection($sdom,$sname,$cid);#,$active);  
   
     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',
Line 365  sub BuildChart { Line 354  sub BuildChart {
 sub CreateForm {  sub CreateForm {
     my $OpSel1='';      my $OpSel1='';
     my $OpSel2='';      my $OpSel2='';
     if ( $ENV{'form.active'} eq 'All Students' ) { $OpSel2='selected'; }      my $OpSel3='';
       my $Status = $ENV{'form.status'};
       if ( $Status eq 'Any' ) { $OpSel3='selected'; }
       elsif ($Status eq 'Expired' ) { $OpSel2 = 'selected'; }
     else { $OpSel1 = '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";
Line 377  sub CreateForm { Line 369  sub CreateForm {
     $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><br>';      $Ptr .= '<br><br>';
     $Ptr .= '<b> Activation Area: &nbsp; </b>'."\n".      $Ptr .= '<b> Student Status: &nbsp; </b>'."\n".
             '<select name="active"> <option '.$OpSel1.' >Active Students</option>'."\n".              '<select name="status">'. 
     '<option '.$OpSel2.'>All Students</option> </select> '."\n";              '<option '.$OpSel1.' >Active</option>'."\n".
               '<option '.$OpSel2.' >Expired</option>'."\n".
       '<option '.$OpSel3.' >Any</option> </select> '."\n";
     $Ptr .= '&nbsp;&nbsp;&nbsp;';      $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";
Line 387  sub CreateForm { Line 381  sub CreateForm {
 }  }
   
 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 398  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 410  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 525  sub handler { Line 518  sub handler {
 }  }
 1;  1;
 __END__  __END__
   
   
   
   
   
   
   

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


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