Diff for /loncom/interface/Attic/lonspreadsheet.pm between versions 1.96 and 1.103

version 1.96, 2002/07/05 21:44:50 version 1.103, 2002/08/29 15:35:01
Line 71  use Apache::lonnet; Line 71  use Apache::lonnet;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use GDBM_File;  use GDBM_File;
 use HTML::TokeParser;  use HTML::TokeParser;
   use Apache::lonhtmlcommon;
 #  #
 # Caches for previously calculated spreadsheets  # Caches for previously calculated spreadsheets
 #  #
Line 146  undef %v; Line 146  undef %v;
 undef %t;  undef %t;
 undef %f;  undef %f;
 undef %c;  undef %c;
 undef %rl;  undef %rowlabel;
 undef @os;  undef @os;
   
 $maxrow=0;  $maxrow=0;
Line 721  sub SUMMIN { Line 721  sub SUMMIN {
     return $sum;         return $sum;   
 }  }
   
   #-------------------------------------------------------
   
   =item MINPARM(parametername)
   
   Returns the minimum value of the parameters matching the parametername.
   parametername should be a string such as 'duedate'.
   
   =cut
   
   #-------------------------------------------------------
   sub MINPARM {
       my ($expression) = @_;
       my $min = undef;
       study($expression);
       foreach $parameter (keys(%c)) {
           next if ($parameter !~ /$expression/);
           if ((! defined($min)) || ($min > $c{$parameter})) {
               $min = $c{$parameter} 
           }
       }
       return $min;
   }
   
   #-------------------------------------------------------
   
   =item MAXPARM(parametername)
   
   Returns the maximum value of the parameters matching the input parameter name.
   parametername should be a string such as 'duedate'.
   
   =cut
   
   #-------------------------------------------------------
   sub MAXPARM {
       my ($expression) = @_;
       my $max = undef;
       study($expression);
       foreach $parameter (keys(%c)) {
           next if ($parameter !~ /$expression/);
           if ((! defined($min)) || ($max < $c{$parameter})) {
               $max = $c{$parameter} 
           }
       }
       return $max;
   }
   
   #--------------------------------------------------------
 sub expandnamed {  sub expandnamed {
     my $expression=shift;      my $expression=shift;
     if ($expression=~/^\&/) {      if ($expression=~/^\&/) {
Line 768  sub expandnamed { Line 815  sub expandnamed {
         }          }
         if ($#matches == 0) {          if ($#matches == 0) {
             $returnvalue = '$c{\''.$matches[0].'\'}';              $returnvalue = '$c{\''.$matches[0].'\'}';
           } elsif ($#matches > 0) {
               # more than one match.  Look for a concise one
               $returnvalue =  "'non-unique parameter name : $expression'";
               foreach (@matches) {
                   if (/^$expression$/) {
                       $returnvalue = '$c{\''.$_.'\'}';
                   }
               }
         } else {          } else {
             $returnvalue =  "'bad parameter name : $expression'";              $returnvalue =  "'bad parameter name : $expression'";
         }          }
Line 783  sub sett { Line 838  sub sett {
     } else {      } else {
         $pattern='[A-Z]';          $pattern='[A-Z]';
     }      }
   
   # Deal with the template row
     foreach (keys(%f)) {      foreach (keys(%f)) {
  if ($_=~/template\_(\w)/) {   if ($_=~/template\_(\w)/) {
   my $col=$1;    my $col=$1;
Line 809  sub sett { Line 866  sub sett {
   }    }
       }        }
     }      }
   
   # Deal with the normal cells
     foreach (keys(%f)) {      foreach (keys(%f)) {
  if (($f{$_}) && ($_!~/template\_/)) {   if (($f{$_}) && ($_!~/template\_/)) {
             my $matches=($_=~/^$pattern(\d+)/);              my $matches=($_=~/^$pattern(\d+)/);
Line 824  sub sett { Line 883  sub sett {
             }              }
         }          }
     }      }
   # For inserted lines, [B-Z] is also valid
   
       unless ($sheettype eq 'assesscalc') {
          foreach (keys(%f)) {
      if ($_=~/[B-Z](\d+)/) {
          if ($f{'A'.$1}=~/^[\~\-]/) {
              $t{$_}=$f{$_};
                     $t{$_}=~s/\.\.+/\,/g;
                     $t{$_}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$v\{\'$2\'\}/g;
                     $t{$_}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.&expandnamed($2)/ge;
                  }
              }
          }
       }
   
     # For some reason 'A0' gets special treatment...  This seems superfluous      # For some reason 'A0' gets special treatment...  This seems superfluous
     # but I imagine it is here for a reason.      # but I imagine it is here for a reason.
     $t{'A0'}=$f{'A0'};      $t{'A0'}=$f{'A0'};
Line 836  sub calc { Line 910  sub calc {
     undef %v;      undef %v;
     &sett();      &sett();
     my $notfinished=1;      my $notfinished=1;
       my $lastcalc='';
     my $depth=0;      my $depth=0;
     while ($notfinished) {      while ($notfinished) {
  $notfinished=0;   $notfinished=0;
Line 846  sub calc { Line 921  sub calc {
  undef %v;   undef %v;
                 return $_.': '.$@;                  return $_.': '.$@;
             }              }
     if ($v{$_} ne $old) { $notfinished=1; }      if ($v{$_} ne $old) { $notfinished=1; $lastcalc=$_; }
         }          }
         $depth++;          $depth++;
         if ($depth>100) {          if ($depth>100) {
     undef %v;      undef %v;
             return 'Maximum calculation depth exceeded';              return $lastcalc.': Maximum calculation depth exceeded';
         }          }
     }      }
     return '';      return '';
Line 876  sub outrowassess { Line 951  sub outrowassess {
     my @cols=();      my @cols=();
     if ($n) {      if ($n) {
        my ($usy,$ufn)=split(/\_\_\&\&\&\_\_/,$f{'A'.$n});         my ($usy,$ufn)=split(/\_\_\&\&\&\_\_/,$f{'A'.$n});
       if ($rl{$usy}) {        if ($rowlabel{$usy}) {
        $cols[0]=$rl{$usy}.'<br>'.         $cols[0]=$rowlabel{$usy}.'<br>'.
                 '<select name="sel_'.$n.'" onChange="changesheet('.$n.                  '<select name="sel_'.$n.'" onChange="changesheet('.$n.
                 ')"><option name="default">Default</option>';                  ')"><option name="default">Default</option>';
       } else { $cols[0]=''; }        } else { $cols[0]=''; }
Line 907  sub outrow { Line 982  sub outrow {
     my $n=shift;      my $n=shift;
     my @cols=();      my @cols=();
     if ($n) {      if ($n) {
        $cols[0]=$rl{$f{'A'.$n}};         $cols[0]=$rowlabel{$f{'A'.$n}};
     } else {      } else {
        $cols[0]='<b><font size=+1>Export</font></b>';         $cols[0]='<b><font size=+1>Export</font></b>';
     }      }
Line 961  sub setothersheets { Line 1036  sub setothersheets {
 # ------------------------------------------------ Add or change formula values  # ------------------------------------------------ Add or change formula values
   
 sub setrowlabels {  sub setrowlabels {
     my ($safeeval,%rl)=@_;      my ($safeeval,%rowlabel)=@_;
     %{$safeeval->varglob('rl')}=%rl;      %{$safeeval->varglob('rowlabel')}=%rowlabel;
 }  }
   
 # ------------------------------------------------------- Calculate spreadsheet  # ------------------------------------------------------- Calculate spreadsheet
Line 986  sub getformulas { Line 1061  sub getformulas {
     return %{$safeeval->varglob('f')};      return %{$safeeval->varglob('f')};
 }  }
   
   # ----------------------------------------------------- Get value of $f{'A'.$n}
   
   sub getfa {
       my ($safeeval,$n)=@_;
       return $safeeval->reval('$f{"A'.$n.'"}');
   }
   
 # -------------------------------------------------------------------- Get type  # -------------------------------------------------------------------- Get type
   
 sub gettype {  sub gettype {
Line 1124  sub rown { Line 1206  sub rown {
     }      }
     my $showf=0;      my $showf=0;
     my $proc;      my $proc;
     my $maxred;      my $maxred=1;
     my $sheettype=&gettype($safeeval);      my $sheettype=&gettype($safeeval);
     if ($sheettype eq 'studentcalc') {      if ($sheettype eq 'studentcalc') {
         $proc='&outrowassess';          $proc='&outrowassess';
Line 1137  sub rown { Line 1219  sub rown {
     } else {      } else {
         $maxred=26;          $maxred=26;
     }      }
       if (&getfa($safeeval,$n)=~/^[\~\-]/) { $maxred=1; }
     if ($n eq '-') { $proc='&templaterow'; $n=-1; $dataflag=1; }      if ($n eq '-') { $proc='&templaterow'; $n=-1; $dataflag=1; }
     foreach ($safeeval->reval($proc.'('.$n.')')) {      foreach ($safeeval->reval($proc.'('.$n.')')) {
        my $bgcolor=$defaultbg.((($showf-1)/5==int(($showf-1)/5))?'99':'DD');         my $bgcolor=$defaultbg.((($showf-1)/5==int(($showf-1)/5))?'99':'DD');
Line 1195  sub outsheet { Line 1278  sub outsheet {
                   '><b><font size=+1>Import</font></b></td>'.                    '><b><font size=+1>Import</font></b></td>'.
                   '<td colspan='.$maxyellow.                    '<td colspan='.$maxyellow.
   '><b><font size=+1>Calculations</font></b></td></tr><tr>';    '><b><font size=+1>Calculations</font></b></td></tr><tr>';
     my $showf=0;         my $showf=0;
     foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M',         foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M',
      'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',                  'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
      'a','b','c','d','e','f','g','h','i','j','k','l','m',                  'a','b','c','d','e','f','g','h','i','j','k','l','m',
      'n','o','p','q','r','s','t','u','v','w','x','y','z') {                  'n','o','p','q','r','s','t','u','v','w','x','y','z') {
         $showf++;             $showf++;
         if ($showf<=$maxred) {              if ($showf<=$maxred) { 
            $tabledata.='<td bgcolor="#FFDDDD">';                  $tabledata.='<td bgcolor="#FFDDDD">'; 
         } else {             } else {
            $tabledata.='<td>';                 $tabledata.='<td>';
         }             }
         $tabledata.="<b><font size=+1>$_</font></b></td>";             $tabledata.="<b><font size=+1>$_</font></b></td>";
     }         }
     $tabledata.='</tr>'.&rown($safeeval,'-').&rown($safeeval,0);         $tabledata.='</tr>'.&rown($safeeval,'-').&rown($safeeval,0);
    } else { $tabledata='<pre>'; }     } else { $tabledata='<pre>'; }
   
     $r->print($tabledata);      $r->print($tabledata);
Line 1223  sub outsheet { Line 1306  sub outsheet {
        $sortidx[$row-1]=$row-1;         $sortidx[$row-1]=$row-1;
     }      }
     @sortidx=sort { $sortby[$a] cmp $sortby[$b]; } @sortidx;      @sortidx=sort { $sortby[$a] cmp $sortby[$b]; } @sortidx;
   
         my $what='Student';          my $what='Student';
         if (&gettype($safeeval) eq 'assesscalc') {          if (&gettype($safeeval) eq 'assesscalc') {
     $what='Item';      $what='Item';
Line 1233  sub outsheet { Line 1315  sub outsheet {
   
     my $n=0;      my $n=0;
     for ($row=0;$row<$maxrow;$row++) {      for ($row=0;$row<$maxrow;$row++) {
      my $thisrow=&rown($safeeval,$sortidx[$row]+1);          my $thisrow=&rown($safeeval,$sortidx[$row]+1);
      if ($thisrow) {          if ($thisrow) {
        if (($n/25==int($n/25)) && (!$ENV{'form.showcsv'})) {              if (($n/25==int($n/25)) && (!$ENV{'form.showcsv'})) {
  $r->print("</table>\n<br>\n");                  $r->print("</table>\n<br>\n");
         $r->rflush();                  $r->rflush();
         $r->print('<table border=2><tr><td>&nbsp;<td>'.$what.'</td>');                  $r->print('<table border=2><tr><td>&nbsp;<td>'.$what.'</td>');
         foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M',                  $r->print('<td>'.join('</td><td>',
  'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',                                        (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
  'a','b','c','d','e','f','g','h','i','j','k','l','m',                                              'abcdefghijklmnopqrstuvwxyz'))).
  'n','o','p','q','r','s','t','u','v','w','x','y','z') {                            "</td></tr>\n");
            $r->print('<td>'.$_.'</td>');              }
               $n++;
               $r->print($thisrow);
         }          }
         $r->print('</tr>');  
        }  
        $n++;  
        $r->print($thisrow);  
       }  
     }      }
     $r->print($ENV{'form.showcsv'}?'</pre>':'</table>');      $r->print($ENV{'form.showcsv'}?'</pre>':'</table>');
 }  }
Line 1611  sub updateclasssheet { Line 1690  sub updateclasssheet {
     my $cdom=&getcdom($safeeval);      my $cdom=&getcdom($safeeval);
     my $cid=&getcid($safeeval);      my $cid=&getcid($safeeval);
     my $chome=&getchome($safeeval);      my $chome=&getchome($safeeval);
       #
 # ---------------------------------------------- Read class list and row labels      # Read class list and row labels
       my %classlist;
     my $classlst=&Apache::lonnet::reply      my @tmp = &Apache::lonnet::dump('classlist',$cdom,$cnum);
                                  ('dump:'.$cdom.':'.$cnum.':classlist',$chome);      if ($tmp[0] !~ /^error/) {
           %classlist = @tmp;
       } else {
           return 'Could not access course data';
       }
       undef @tmp;
       #
     my %currentlist=();      my %currentlist=();
     my $now=time;      my $now=time;
     unless ($classlst=~/^error\:/) {      foreach my $student (keys(%classlist)) {
         foreach (split(/\&/,$classlst)) {          my ($end,$start)=split(/\:/,$classlist{$student});
             my ($name,$value)=split(/\=/,$_);          my $active=1;
             my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value));          $active = 0 if (($end) && ($now>$end));
             my $active=1;          $active = 1 if ($ENV{'form.Status'} eq 'Any');
             if (($end) && ($now>$end)) { $active=0; }          $active = !$active if ($ENV{'form.Status'} eq 'Expired');
             if ($active) {          if ($active) {
                 my $rowlabel='';              my $rowlabel='';
                 $name=&Apache::lonnet::unescape($name);              my ($studentName,$studentDomain)=split(/\:/,$student);
                 my ($sname,$sdom)=split(/\:/,$name);              my $studentSection=&Apache::lonnet::usection($studentDomain,
                 my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);                                                           $studentName,$cid);
                 if ($ssec==-1) {              if ($studentSection==-1) {
    unless ($ENV{'form.showcsv'}) {                  unless ($ENV{'form.showcsv'}) {
                     $rowlabel='<font color=red>Data not available: '.$name.                      $rowlabel='<font color=red>Data not available: '.
       '</font>';                          $studentName.'</font>';
    } else {  
        $rowlabel='ERROR","'.$name.  
                                  '","Data not available","","","';  
                    }  
                 } else {                  } else {
                     my %reply=&Apache::lonnet::idrget($sdom,$sname);                      $rowlabel='ERROR","'.$studentName.
                     my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname.                          '","Data not available","","","';
       ':environment:firstname&middlename&lastname&generation',                  }
                       &Apache::lonnet::homeserver($sname,$sdom));              } else {
    unless ($ENV{'form.showcsv'}) {                  my %reply=&Apache::lonnet::idrget($studentDomain,$studentName);
                     $rowlabel='<a href="/adm/studentcalc?uname='.$sname.                  my %studentInformation=&Apache::lonnet::get
                               '&udom='.$sdom.'">'.                      ('environment',
                               $ssec.'&nbsp;'.$reply{$sname}.'<br>';                       ['lastname','generation','firstname','middlename','id'],
                     foreach ( split(/\&/,$reply)) {                       $studentDomain,$studentName);
                         $rowlabel.=&Apache::lonnet::unescape($_).' ';                  if (! $ENV{'form.showcsv'}) {
                       $rowlabel='<a href="/adm/studentcalc?uname='.$studentName.
                           '&udom='.$studentDomain.'">'.
                               $studentSection.'&nbsp;';
                       foreach ('id','firstname','middlename',
                                'lastname','generation'){
                           $rowlabel.=$studentInformation{$_}."&nbsp;";
                     }                      }
                     $rowlabel.='</a>';                      $rowlabel.='</a>';
    } else {                  } else {
     $rowlabel=$ssec.'","'.$reply{$sname}.'"';                      $rowlabel= '"'.join('","',
                     my $ncount=0;                                          ($studentSection,
                     foreach (split(/\&/,$reply)) {                                           $studentInformation{'id'},
                         $rowlabel.=',"'.&Apache::lonnet::unescape($_).'"';                                           $studentInformation{'firstname'},
                         $ncount++;                                           $studentInformation{'middlename'},
                     }                                           $studentInformation{'lastname'},
                     unless ($ncount==4) { $rowlabel.=',""'; }                                           $studentInformation{'generation'})
                     $rowlabel=~s/\"$//;                                          ).'"';
    }  
                 }                  }
  $currentlist{&Apache::lonnet::unescape($name)}=$rowlabel;  
             }              }
         } # end of foreach (split(/\&/,$classlst))              $currentlist{$student}=$rowlabel;
 #          } # end of if ($active)
 # -------------------- Find discrepancies between the course row table and this      } # end of foreach my $student (keys(%classlist))
 #      #
         my %f=&getformulas($safeeval);      # Find discrepancies between the course row table and this
         my $changed=0;      #
       my %f=&getformulas($safeeval);
         my $maxrow=0;      my $changed=0;
         my %existing=();      #
       my $maxrow=0;
 # ----------------------------------------------------------- Now obsolete rows      my %existing=();
  foreach (keys(%f)) {      #
     if ($_=~/^A(\d+)/) {      # Now obsolete rows
                 $maxrow=($1>$maxrow)?$1:$maxrow;      foreach (keys(%f)) {
                 $existing{$f{$_}}=1;          if ($_=~/^A(\d+)/) {
  unless ((defined($currentlist{$f{$_}})) || (!$1)) {              $maxrow=($1>$maxrow)?$1:$maxrow;
    $f{$_}='!!! Obsolete';              $existing{$f{$_}}=1;
                    $changed=1;              unless ((defined($currentlist{$f{$_}})) || (!$1) ||
                 }                      ($f{$_}=~/^(\~\~\~|\-\-\-)/)) {
                   $f{$_}='!!! Obsolete';
                   $changed=1;
             }              }
         }          }
       }
 # -------------------------------------------------------- New and unknown keys      #
            # New and unknown keys
         foreach (sort keys(%currentlist)) {      foreach (sort keys(%currentlist)) {
             unless ($existing{$_}) {          unless ($existing{$_}) {
  $changed=1;              $changed=1;
                 $maxrow++;              $maxrow++;
                 $f{'A'.$maxrow}=$_;              $f{'A'.$maxrow}=$_;
             }  
         }          }
        
         if ($changed) { &setformulas($safeeval,%f); }  
   
         &setmaxrow($safeeval,$maxrow);  
         &setrowlabels($safeeval,%currentlist);  
   
     } else {  
         return 'Could not access course data';  
     }      }
       if ($changed) { &setformulas($safeeval,%f); }
       #
       &setmaxrow($safeeval,$maxrow);
       &setrowlabels($safeeval,%currentlist);
 }  }
   
 # ----------------------------------- Update rows for student and assess sheets  # ----------------------------------- Update rows for student and assess sheets
Line 1715  sub updatestudentassesssheet { Line 1797  sub updatestudentassesssheet {
     unless ($updatedata{$ENV{'request.course.fn'}.'_'.$stype}) {      unless ($updatedata{$ENV{'request.course.fn'}.'_'.$stype}) {
 # -------------------------------------------------------------------- Tie hash  # -------------------------------------------------------------------- Tie hash
       if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',        if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
                        &GDBM_READER,0640)) {                         &GDBM_READER(),0640)) {
 # --------------------------------------------------------- Get all assessments  # --------------------------------------------------------- Get all assessments
   
  my %allkeys=('timestamp' =>    my %allkeys=('timestamp' => 
Line 1817  sub updatestudentassesssheet { Line 1899  sub updatestudentassesssheet {
                 $maxrow=($1>$maxrow)?$1:$maxrow;                  $maxrow=($1>$maxrow)?$1:$maxrow;
                 my ($usy,$ufn)=split(/\_\_\&\&\&\_\_/,$f{$_});                  my ($usy,$ufn)=split(/\_\_\&\&\&\_\_/,$f{$_});
                 $existing{$usy}=1;                  $existing{$usy}=1;
  unless ((defined($current{$usy})) || (!$1)) {   unless ((defined($current{$usy})) || (!$1) ||
    $f{$_}='!!! Obsolete';                          ($f{$_}=~/^(\~\~\~|\-\-\-)/)){
       $f{$_}='!!! Obsolete';
                    $changed=1;                     $changed=1;
         } elsif ($ufn) {          } elsif ($ufn) {
     $current{$usy}      $current{$usy}
Line 1853  sub loadstudent { Line 1936  sub loadstudent {
     my %c=();      my %c=();
     my %f=&getformulas($safeeval);      my %f=&getformulas($safeeval);
     $cachedassess=&getuname($safeeval).':'.&getudom($safeeval);      $cachedassess=&getuname($safeeval).':'.&getudom($safeeval);
     %cachedstores=();      # Get ALL the student preformance data
     {      my @tmp = &Apache::lonnet::dump(&getcid($safeeval),
       my $reply=&Apache::lonnet::reply('dump:'.&getudom($safeeval).':'.                                      &getudom($safeeval),
                                                &getuname($safeeval).':'.                                      &getuname($safeeval),
                                                &getcid($safeeval),                                      undef);
                                                &getuhome($safeeval));      if ($tmp[0] !~ /^error:/) {
       unless ($reply=~/^error\:/) {          %cachedstores = @tmp;
  foreach ( split(/\&/,$reply)) {  
             my ($name,$value)=split(/\=/,$_);  
             $cachedstores{&Apache::lonnet::unescape($name)}=  
                   &Apache::lonnet::unescape($value);  
  }  
       }  
     }      }
       undef @tmp;
       # 
     my @assessdata=();      my @assessdata=();
     foreach (keys(%f)) {      foreach (keys(%f)) {
  if ($_=~/^A(\d+)/) {   if ($_=~/^A(\d+)/) {
    my $row=$1;     my $row=$1;
            unless (($f{$_}=~/^\!/) || ($row==0)) {             unless (($f{$_}=~/^[\!\~\-]/) || ($row==0)) {
       my ($usy,$ufn)=split(/\_\_\&\&\&\_\_/,$f{$_});        my ($usy,$ufn)=split(/__&&&\__/,$f{$_});
       @assessdata=&exportsheet(&getuname($safeeval),        @assessdata=&exportsheet(&getuname($safeeval),
                                        &getudom($safeeval),                                         &getudom($safeeval),
                                        'assesscalc',$usy,$ufn);                                         'assesscalc',$usy,$ufn);
Line 1910  sub loadcourse { Line 1989  sub loadcourse {
     my $total=0;      my $total=0;
     foreach (keys(%f)) {      foreach (keys(%f)) {
  if ($_=~/^A(\d+)/) {   if ($_=~/^A(\d+)/) {
     unless ($f{$_}=~/^\!/) { $total++; }      unless ($f{$_}=~/^[\!\~\-]/) { $total++; }
         }          }
     }      }
     my $now=0;      my $now=0;
Line 1930  ENDPOP Line 2009  ENDPOP
     foreach (keys(%f)) {      foreach (keys(%f)) {
  if ($_=~/^A(\d+)/) {   if ($_=~/^A(\d+)/) {
    my $row=$1;     my $row=$1;
            unless (($f{$_}=~/^\!/)  || ($row==0)) {             unless (($f{$_}=~/^[\!\~\-]/)  || ($row==0)) {
       my @studentdata=&exportsheet(split(/\:/,$f{$_}),        my @studentdata=&exportsheet(split(/\:/,$f{$_}),
                                            'studentcalc');                                             'studentcalc');
               undef %userrdatas;                undef %userrdatas;
Line 1941  ENDPOP Line 2020  ENDPOP
               $r->rflush();                 $r->rflush(); 
   
               my $index=0;                my $index=0;
              foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M',                foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M',
               'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') {                         'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') {
                   if ($studentdata[$index]) {                    if ($studentdata[$index]) {
      my $col=$_;                        my $col=$_;
      if ($studentdata[$index]=~/\D/) {                        if ($studentdata[$index]=~/\D/) {
                          $c{$col.$row}="'".$studentdata[$index]."'";                            $c{$col.$row}="'".$studentdata[$index]."'";
       } else {                        } else {
          $c{$col.$row}=$studentdata[$index];                            $c{$col.$row}=$studentdata[$index];
      }                        }
                      unless ($col eq 'A') {                         unless ($col eq 'A') { 
  $f{$col.$row}='import';                            $f{$col.$row}='import';
                      }                        }
   }    }
                   $index++;                    $index++;
               }                }
Line 2090  sub loadassessment { Line 2169  sub loadassessment {
    my %c=();     my %c=();
   
    if (tie(%parmhash,'GDBM_File',     if (tie(%parmhash,'GDBM_File',
            &getcfn($safeeval).'_parms.db',&GDBM_READER,0640)) {             &getcfn($safeeval).'_parms.db',&GDBM_READER(),0640)) {
     my %f=&getformulas($safeeval);      my %f=&getformulas($safeeval);
     foreach (keys(%f))  {      foreach (keys(%f))  {
  if ($_=~/^A/) {   if ($_=~/^A/) {
             unless ($f{$_}=~/^\!/) {              unless ($f{$_}=~/^[\!\~\-]/) {
         if ($f{$_}=~/^parameter/) {          if ($f{$_}=~/^parameter/) {
  if ($thisassess{$f{$_}}) {   if ($thisassess{$f{$_}}) {
                   my $val=&parmval($f{$_},$safeeval);                    my $val=&parmval($f{$_},$safeeval);
Line 2489  $tmpdir=$r->dir_config('lonDaemons').'/t Line 2568  $tmpdir=$r->dir_config('lonDaemons').'/t
   
 </script>  </script>
 ENDSCRIPT  ENDSCRIPT
     $r->print('</head><body bgcolor="#FFFFFF">'.     $r->print('</head>'.&Apache::loncommon::bodytag('Grades Spreadsheet').
        '<img align=right src=/adm/lonIcons/lonlogos.gif>'.  
        '<h1>LON-CAPA Spreadsheet</h1>'.  
        '<form action="'.$r->uri.'" name=sheet method=post>'.         '<form action="'.$r->uri.'" name=sheet method=post>'.
        &hiddenfield('uname',$ENV{'form.uname'}).         &hiddenfield('uname',$ENV{'form.uname'}).
        &hiddenfield('udom',$ENV{'form.udom'}).         &hiddenfield('udom',$ENV{'form.udom'}).
Line 2555  ENDSCRIPT Line 2632  ENDSCRIPT
         }          }
     }      }
   
 # ---------------------------------------------------------------- Course title  
   
     $r->print('<h1>'.  
             $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.  
              '</h1><h3>'.localtime().'</h3>');  
   
 # ---------------------------------------------------- See if user can see this  # ---------------------------------------------------- See if user can see this
   
     if ((&gettype($asheet) eq 'classcalc') ||       if ((&gettype($asheet) eq 'classcalc') || 
Line 2712  ENDSCRIPT Line 2783  ENDSCRIPT
     }      }
   
 # ------------------------------------------------------------------ Insertrows  # ------------------------------------------------------------------ Insertrows
       $r->print('&nbsp;Student Status: '.
                 &Apache::lonhtmlcommon::StatusOptions
                 ($ENV{'form.Status'},'sheet'));
   
    $r->print(<<ENDINSERTBUTTONS);     $r->print(<<ENDINSERTBUTTONS);
 <br>  <br>

Removed from v.1.96  
changed lines
  Added in v.1.103


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