--- loncom/interface/Attic/lonspreadsheet.pm 2002/09/10 19:04:13 1.109 +++ loncom/interface/Attic/lonspreadsheet.pm 2002/09/30 18:47:43 1.114 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.109 2002/09/10 19:04:13 matthew Exp $ +# $Id: lonspreadsheet.pm,v 1.114 2002/09/30 18:47:43 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,6 +62,11 @@ use GDBM_File; use HTML::TokeParser; use Apache::lonhtmlcommon; # +# Caches for coursewide information +# +my %Section; + +# # Caches for previously calculated spreadsheets # @@ -852,7 +857,7 @@ sub sett { } # Deal with the normal cells foreach (keys(%f)) { - if (($f{$_}) && ($_!~/template\_/)) { + if (exists($f{$_}) && ($_!~/template\_/)) { my $matches=($_=~/^$pattern(\d+)/); if (($matches) && ($1)) { unless ($f{$_}=~/^\!/) { @@ -1226,8 +1231,14 @@ sub rown { if ($vl eq '') { $vl='#'; } - $rowdata.=''. - ''.$vl.''; + $rowdata.=''; + if ($ENV{'request.role'} =~ /^st\./) { + $rowdata.=$vl; + } else { + $rowdata.=''. + $vl.''; + } + $rowdata.=''; } else { $rowdata.=' '.$vl.' '; } @@ -1299,7 +1310,7 @@ sub outsheet { push (@sortby, $safeeval->reval('$f{"A'.$row.'"}')); push (@sortidx, $row-1); } - @sortidx=sort { $sortby[$a] cmp $sortby[$b]; } @sortidx; + @sortidx=sort { lc($sortby[$a]) cmp lc($sortby[$b]); } @sortidx; # # Determine the type of child spreadsheets my $what='Student'; @@ -1461,8 +1472,7 @@ sub makenewsheet { $sheetdata{'sheettype'} = $stype; $sheetdata{'usymb'} = $usymb; $sheetdata{'cid'} = $ENV{'request.course.id'}; - $sheetdata{'csec'} = &Apache::lonnet::usection - ($udom,$uname,$ENV{'request.course.id'}); + $sheetdata{'csec'} = $Section{$uname.':'.$udom}; $sheetdata{'coursefilename'} = $ENV{'request.course.fn'}; $sheetdata{'cnum'} = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; $sheetdata{'cdom'} = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; @@ -1670,6 +1680,9 @@ sub updateclasssheet { my $cid =$sheetdata->{'cid'}; my $chome =$sheetdata->{'chome'}; # + %Section = (); + + # # Read class list and row labels my %classlist; my @tmp = &Apache::lonnet::dump('classlist',$cdom,$cnum); @@ -1693,6 +1706,7 @@ sub updateclasssheet { my ($studentName,$studentDomain)=split(/\:/,$student); my $studentSection=&Apache::lonnet::usection($studentDomain, $studentName,$cid); + $Section{$studentName.':'.$studentDomain} = $studentSection; # if ($studentSection==-1) { # unless ($ENV{'form.showcsv'}) { # $rowlabel='Data not available: '. @@ -2082,8 +2096,11 @@ sub loadassessment { &Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome); if ($reply!~/^error\:/) { $userrdatas{$uname.'___'.$udom}=$reply; - $userrdatas{$uname.'___'.$udom.'.last_cache'}=time; } + # Most of the time the user does not have a 'resourcedata.db' + # file. We need to cache that we got nothing instead of bothering + # with requesting it every time. + $userrdatas{$uname.'___'.$udom.'.last_cache'}=time; } foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) { my ($name,$value)=split(/\=/,$_); @@ -2412,10 +2429,15 @@ sub cachedssheets { # Interactive call to screen # # - - sub handler { my $r=shift; + + my $loaderror=&Apache::lonnet::overloaderror($r); + if ($loaderror) { return $loaderror; } + $loaderror= &Apache::lonnet::overloaderror($r, + $ENV{'course.'.$ENV{'request.course.id'}.'.home'}); + if ($loaderror) { return $loaderror; } + if ($r->header_only) { $r->content_type('text/html'); $r->send_http_header; @@ -2434,6 +2456,10 @@ sub handler { # Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['uname','udom','usymb','ufn']); + if ($ENV{'request.role'} =~ /^st\./) { + delete $ENV{'form.unewfield'} if (exists($ENV{'form.unewfield'})); + delete $ENV{'form.unewformula'} if (exists($ENV{'form.unewformula'})); + } if (($ENV{'form.usymb'}=~/^\_(\w+)/) && (!$ENV{'form.ufn'})) { $ENV{'form.ufn'}='default_'.$1; } @@ -2460,7 +2486,8 @@ sub handler { $r->send_http_header; # Screen output $r->print('LON-CAPA Spreadsheet'); - $r->print(<print(< function celledit(cn,cf) { @@ -2486,6 +2513,7 @@ sub handler { ENDSCRIPT + } $r->print(''.&Apache::loncommon::bodytag('Grades Spreadsheet'). '
'); $r->print(&hiddenfield('uname',$ENV{'form.uname'}).