Diff for /loncom/interface/Attic/lonchart.pm between versions 1.32 and 1.33

version 1.32, 2002/02/28 01:49:33 version 1.33, 2002/02/28 23:14:57
Line 43 Line 43
 # 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 64  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 225  sub tracetable { Line 225  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 {
       my ($udom,$unam,$courseid)=@_;
       $courseid=~s/\_/\//g;
       $courseid=~s/^(\w)/\/$1/;
       map {
           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));
   #            $section=($section) ? $section : '(none)';
   #            $section=(int($section)) ? int($section) : $section;
   #            $r->print($unam.'...'.$section.'<br>');
       return $section;
           }
       } split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
                           &Apache::lonnet::homeserver($unam,$udom)));
       return '';
   }
   
 sub BuildChart {  sub BuildChart {
 # ----------------------- Get first and last resource, see if there is anything  # ----------------------- Get first and last resource, see if there is anything
     my $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};      my $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};
Line 244  sub BuildChart { Line 293  sub BuildChart {
  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; }   if (($end) && ($now>$end)) { $active=0; }
   
    if ($ENV{'form.active'} eq 'All Students') { $active=1; }
   
  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);#,$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',
                                                  &Apache::lonnet::homeserver($sname,$sdom));                                    &Apache::lonnet::homeserver($sname,$sdom));
  #$ssec=(int($ssec)) ? int($ssec) : $ssec;   #$ssec=(int($ssec)) ? int($ssec) : $ssec;
  my $sec=sprintf('%3s',$ssec);   my $sec=sprintf('%3s',$ssec);
  $rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';   $rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';
Line 306  sub BuildChart { Line 360  sub BuildChart {
 }  }
   
 sub CreateForm {  sub CreateForm {
       my $OpSel1='';
       my $OpSel2='';
       if ( $ENV{'form.active'} eq 'All Students' ) { $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> Activation Area: &nbsp; </b>'."\n".
               '<select name="active"> <option '.$OpSel1.' >Active Students</option>'."\n".
       '<option '.$OpSel2.'>All Students</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 395  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{$Use.$key}=$key;   $list[$count]=$Use.$key.'*'.$CachData{$key};
  $count++;   $count++;
     }      }
   
     my @order = sort(keys(%list));      @list = sort (@list);
   
     $r->print('<h3>'.$count.' students</h3>');      $r->print('<h3>'.$count.' students</h3>');
     &CreateForm();      &CreateForm();
Line 344  sub CacheChart { Line 407  sub CacheChart {
           
     $r->print('<p><pre>');      $r->print('<p><pre>');
     for ( my $n; $n < $count; $n++) {      for ( my $n; $n < $count; $n++) {
  $r->print($CachData{$list{$order[$n]}}.'<br>');   my ($dummy, $Line) = split(/\*/,$list[$n]);
    $r->print($Line.'<br>');
     }      }
     $r->print('</pre>');      $r->print('</pre>');
 }  }

Removed from v.1.32  
changed lines
  Added in v.1.33


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