File:  [LON-CAPA] / capa / capa51 / CapaTools / rebuild.pl
Revision 1.1: download - view: text, annotated - select for diffs
Tue Sep 28 21:25:35 1999 UTC (24 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
Initial revision

    1: #!/usr/local/bin/perl
    2: 
    3:  require('getopts.pl');
    4:  
    5:  
    6:  
    7:  sub  S_Enterpath {
    8:     local($set)=@_;
    9:     local($notdone,$path);
   10:     
   11:     $notdone = 1;
   12:     while ($notdone) {
   13:       print "Please enter the CLASS absolute path:\n";
   14:       $path = <>; chomp($path);
   15:       if( $path =~ /\/$/ ) {
   16:         $Rfullpath = "$path" . "records";
   17:         $Lfullpath = "$path" . "records/log$set.db";
   18:         $Wfullpath = "$path" . "records/weblog$set.db";
   19:       } else {
   20:         $Rfullpath = "$path" . "/records";
   21:         $Lfullpath = "$path" . "/records/log$set.db";
   22:         $Wfullpath = "$path" . "/records/weblog$set.db";
   23:       }
   24:       if( -d $path ) {
   25:         if( -d $Rfullpath ) {
   26:           if( -f $Lfullpath ) {
   27:             $notdone = 0;
   28:           } else {
   29:             print "File [$Lfullpath] does not exist!\n";
   30:           }
   31:           if( -f $Wfullpath ) {
   32:             $notdone = 0;
   33:           } else {
   34:             print "File [$Wfullpath] does not exist!\n";
   35:           }
   36:         } else {
   37:           print "Directory [$Rfullpath] does not exist!\n";
   38:         }
   39:       } else {
   40:         print "Directory [$path] does not exist!\n";
   41:       }
   42:     
   43:     }
   44:     return ($path);
   45:   }
   46:   
   47:   sub S_ScanDB  {
   48:     local($filename)=@_;
   49:     local($line_cnt)=0;
   50:     local($s_num,$dow,$mon,$sp,$day,$time,$yr,$ans_str);
   51:     local($rest);
   52:     local(@ans_char);
   53:     local($ii,$first,$cmd);
   54:     local($usr_ans,$usr_try,$prob_cnt);
   55:     
   56:     open(IN, "<$filename") || die "Cannot open $filename file!";
   57:     $Yes_cnt = 0; $No_cnt = 0;
   58:     while (<IN>) {
   59:       $line_cnt++;
   60:       chomp();
   61:       ($first,$ans_str) = split(/ [1-9][0-9][0-9][0-9] /);
   62:        # print "$ans_str\n";
   63:       ($s_num,$rest) = split(/ /,$first);
   64:       (@ans_char) = split(/ */,$ans_str);
   65:        $s_num = uc($s_num)
   66:        $usr_ans = "$s_num" . "ans";
   67:        $usr_try = "$s_num" . "try";
   68:        if( $prob_cnt == 0 ) {
   69:          $prob_cnt = $#ans_char +1;
   70:        }
   71:        if(! defined @$usr_ans  ) {
   72:          for($ii=0;$ii<=$#ans_char;$ii++) {
   73:            $$usr_ans[$ii] = '-';
   74:          }
   75:        }
   76:        if(! defined @$usr_try  ) {
   77:          for($ii=0;$ii<=$#ans_char;$ii++) {
   78:            $$usr_try[$ii] = 0;
   79:          }
   80:        }
   81:        for($ii=0;$ii<=$#ans_char;$ii++) {
   82:          if( $ans_char[$ii] eq 'Y') {
   83:            $$usr_ans[$ii] = 'Y';
   84:            $$usr_try[$ii]++;
   85:          }
   86:          if( $ans_char[$ii] eq 'N') {
   87:            if( $$usr_ans[$ii] ne 'Y') {
   88:              $$usr_ans[$ii] = 'N';
   89:            }
   90:            $$usr_try[$ii]++;
   91:          }
   92:        }
   93:        if(! defined $Exist{"$s_num"} ) {
   94:          $Exist{"$s_num"} = $s_num;
   95:        }
   96:      }
   97:      close(IN) || die "Cannot close $filename file!";
   98:      return ($prob_cnt);
   99:   }
  100:   
  101:   
  102:   
  103:   if(! &Getopts('s:') ) {
  104:      print STDERR "$Usage\n";
  105:      exit 2;
  106:   }
  107:   $opt_s = 1  if ! $opt_s;
  108:   S_Enterpath($opt_s);
  109:   
  110:   $cnt = S_ScanDB("$Lfullpath");
  111:   $cnt = S_ScanDB("$Wfullpath");
  112:   
  113:   foreach $sn (sort keys %Exist) {
  114:     $usr_ans = "$sn" . "ans";
  115:     $usr_try = "$sn" . "try";
  116:     print "$sn ";
  117:     for($ii = 0; $ii< $cnt;$ii++) {
  118:       print $$usr_ans[$ii];
  119:     }
  120:     for($ii = 0; $ii< $cnt;$ii++) {
  121:       printf ",%2d", $$usr_try[$ii];
  122:     }
  123:     print "\n";
  124:   }
  125:   
  126:   
  127:   
  128:   
  129:   
  130:   
  131:   

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