Diff for /loncom/interface/Attic/lonchart.pm between versions 1.39 and 1.42

version 1.39, 2002/05/29 17:57:52 version 1.42, 2002/06/04 19:59:34
Line 85  sub ExtractStudentData { Line 85  sub ExtractStudentData {
             substr($rowlabels[$index].              substr($rowlabels[$index].
             '                                                        ',0,45).' ! ';              '                                                        ',0,45).' ! ';
   
       my($checkForError)=keys (%result);
       if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
    my $PrTot = sprintf( "%5d", $ProbTotal );
    my $PrSvd = sprintf( "%5d", $ProbSolved );
    $Str .= ' '.'<font color="#000088">'.$PrSvd.'  /'.$PrTot.'</font> ';
    return $Str;
       }
   
     $ProbNo = 0;      $ProbNo = 0;
     $ProbTotal = 0;      $ProbTotal = 0;
     $ProbSolved = 0;      $ProbSolved = 0;
Line 229  sub usection { Line 237  sub usection {
     $courseid=~s/^(\w)/\/$1/;      $courseid=~s/^(\w)/\/$1/;
   
     my %result=&Apache::lonnet::dump('roles',$udom,$unam);      my %result=&Apache::lonnet::dump('roles',$udom,$unam);
   
       my($checkForError)=keys (%result);
       if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
    return -1;
       }
       my $cursection='-1';
       my $oldsection='-1';
       my $status='Expired';
     foreach my $key (keys (%result)) {      foreach my $key (keys (%result)) {
  my $value = $result{$key};   my $value = $result{$key};
         if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {          if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
             my $section=$1;              my $section=$1;
             if ($key eq $courseid.'_st') { $section=''; }              if ($key eq $courseid.'_st') { $section=''; }
     my ($dummy,$end,$start)=split(/\_/,$value);      my ($dummy,$end,$start)=split(/\_/,$value);
     if ( $ActiveFlag ne 'Any' ) {      my $now=time;
  my $now=time;      my $notactive=0;
  my $notactive=0;      if ($start) { if ($now<$start) { $notactive=1; } }
  if ($start) {      if ($end) { if ($now>$end) { $notactive=1; } }
     if ($now<$start) { $notactive=1; }      if ($notactive == 0) { $status='Active';$cursection=$section;}
  }      if ($notactive == 1) { $oldsection=$section;}
  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;  
         }          }
     }      }
       if ($status eq $ActiveFlag) {
         if ($cursection eq '-1') { return $oldsection; }
         return $cursection;
       }
       if ($ActiveFlag eq 'Any') { 
         if ($cursection eq '-1') { return $oldsection; }
         return $cursection;
       }
     return '-1';      return '-1';
 }  }
   
Line 267  sub BuildChart { Line 281  sub BuildChart {
         my ($cdom,$cnum)=split(/\_/,$cid);          my ($cdom,$cnum)=split(/\_/,$cid);
 # ---------------------------------------------- Read class list and row labels  # ---------------------------------------------- Read class list and row labels
  my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);   my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
  my $now=time;  
  foreach my $name (keys (%classlist)) {   my($checkForError)=keys (%classlist);
     my $value=$classlist{$name};   if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
     my ($end,$start)=split(/\:/,$value);      $r->print('<h1>Could not access course data</h1>');
     my $active=1;   } else {
     my $Status=$ENV{'form.status'};      my $now=time;
     $Status = ($Status) ? $Status : 'Active';      foreach my $name (sort(keys(%classlist))) {
     if ( ( ($end) && $now > $end ) &&    my $value=$classlist{$name};
  ( ($Status eq 'Active') ) ) { $active=0; }   my ($end,$start)=split(/\:/,$value);
     if ( ($Status eq 'Expired') &&    my $active=1;
  ($end == 0 || $now < $end) ) { $active=0; }   my $Status=$ENV{'form.status'};
     if ($active) {   $Status = ($Status) ? $Status : 'Active';
  my $thisindex=$#students+1;   if ( ( ($end) && $now > $end ) && 
  $students[$thisindex]=$name;       ( ($Status eq 'Active') ) ) { $active=0; }
  my ($sname,$sdom)=split(/\:/,$name);   if ( ($Status eq 'Expired') && 
  $PreCol[$thisindex]=$sname.':';       ($end == 0 || $now < $end) ) { $active=0; }
  my $ssec=&usection($sdom,$sname,$cid,$Status);   if ($active) {
  if ($ssec==-1) {      my $thisindex=$#students+1;
     $rowlabels[$thisindex]=      $students[$thisindex]=$name;
  'Data not available: '.$name;      my ($sname,$sdom)=split(/\:/,$name);
  } else {      $PreCol[$thisindex]=$sname.':';
     my %reply=&Apache::lonnet::idrget($sdom,$sname);      my $ssec=&usection($sdom,$sname,$cid,$Status);
     my $reply=&Apache::lonnet::get('environment',      if ($ssec==-1) {
  ['lastname','generation','firstname','middlename'],   $rowlabels[$thisindex]=
  $sdom,$sname);      'Data not available: '.$name;
     #$ssec=(int($ssec)) ? int($ssec) : $ssec;      } else {
     my $sec=sprintf('%3s',$ssec);   my %reply=&Apache::lonnet::idrget($sdom,$sname);
     $rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';   my %name=&Apache::lonnet::get('environment',
     $PreCol[$thisindex] .= $reply.':'.$sec;         ['lastname','generation'
     my $i=0;         ,'firstname'
     foreach (split(/\&/,$reply)) {         ,'middlename'],
  $i++;         $sdom,$sname);
  if ( $_ ne '') {   my $name=$name{'lastname'};
     $rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';   if ($name{'generation'}) {$name.=" $name{generation}";}
  }   $name.=',';
  if ($i == 2) {   if ($name{'firstname'}) {$name.=" $name{firstname}";}
     chop($rowlabels[$thisindex]);   if ($name{'middlename'}) {$name.=" $name{middlename}";}
     $rowlabels[$thisindex].=', ';   if ($name eq ',') {$name='';}
  }   #$ssec=(int($ssec)) ? int($ssec) : $ssec;
    my $sec=sprintf('%3s',$ssec);
    $rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';
    $PreCol[$thisindex] .= $name.':'.$sec;
    $rowlabels[$thisindex].=$name.' ';
     }      }
  }   }
     }      }

Removed from v.1.39  
changed lines
  Added in v.1.42


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