--- loncom/interface/Attic/lonspreadsheet.pm 2002/09/05 14:38:57 1.107 +++ loncom/interface/Attic/lonspreadsheet.pm 2002/09/16 20:09:45 1.110 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.107 2002/09/05 14:38:57 matthew Exp $ +# $Id: lonspreadsheet.pm,v 1.110 2002/09/16 20:09:45 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,16 +26,6 @@ # The LearningOnline Network with CAPA # Spreadsheet/Grades Display Handler # -# 11/11,11/15,11/27,12/04,12/05,12/06,12/07, -# 12/08,12/09,12/11,12/12,12/15,12/16,12/18,12/19,12/30, -# 01/01/01,02/01,03/01,19/01,20/01,22/01, -# 03/05,03/08,03/10,03/12,03/13,03/15,03/17, -# 03/19,03/20,03/21,03/27,04/05,04/09, -# 07/09,07/14,07/21,09/01,09/10,9/11,9/12,9/13,9/14,9/17, -# 10/16,10/17,10/20,11/05,11/28,12/27 Gerd Kortemeyer -# 01/14/02 Matthew -# 02/04/02 Matthew - # POD required stuff: =head1 NAME @@ -54,7 +44,6 @@ not the grades of their peers. The spre offering the ability to use Perl code to manipulate data, as well as many built-in functions. - =head2 Functions available to user of lonspreadsheet =over 4 @@ -167,7 +156,7 @@ $chome= ''; $cnum = ''; $cdom = ''; $cid = ''; -$cfn = ''; +$coursefilename = ''; # symb @@ -1111,9 +1100,9 @@ sub getcid { # --------------------------------------------------------- Get course filename -sub getcfn { +sub getcoursefilename { my $safeeval=shift; - return $safeeval->reval('$cfn'); + return $safeeval->reval('$coursefilename'); } # ----------------------------------------------------------- Get course number @@ -1393,7 +1382,6 @@ sub parse_sheet { # # -------------------------------------- Read spreadsheet formulas for a course # - sub readsheet { my ($safeeval,$sheetdata,$fn)=@_; # @@ -1465,7 +1453,6 @@ sub readsheet { } # -------------------------------------------------------- Make new spreadsheet - sub makenewsheet { my ($uname,$udom,$stype,$usymb)=@_; my %sheetdata=(); @@ -1476,7 +1463,7 @@ sub makenewsheet { $sheetdata{'cid'} = $ENV{'request.course.id'}; $sheetdata{'csec'} = &Apache::lonnet::usection ($udom,$uname,$ENV{'request.course.id'}); - $sheetdata{'cfn'} = $ENV{'request.course.fn'}; + $sheetdata{'coursefilename'} = $ENV{'request.course.fn'}; $sheetdata{'cnum'} = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; $sheetdata{'cdom'} = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; $sheetdata{'chome'} = $ENV{'course.'.$ENV{'request.course.id'}.'.home'}; @@ -1492,7 +1479,6 @@ sub makenewsheet { } # ------------------------------------------------------------ Save spreadsheet - sub writesheet { my ($safeeval,$makedef)=@_; my $cid=&getcid($safeeval); @@ -1544,7 +1530,6 @@ sub writesheet { # ----------------------------------------------- Make a temp copy of the sheet # "Modified workcopy" - interactive only # - sub tmpwrite { my $safeeval=shift; my $fn=$ENV{'user.name'}.'_'. @@ -1559,7 +1544,6 @@ sub tmpwrite { } # ---------------------------------------------------------- Read the temp copy - sub tmpread { my ($safeeval,$nfield,$nform)=@_; my $fn=$ENV{'user.name'}.'_'. @@ -1680,11 +1664,11 @@ sub parmval { # ---------------------------------------------- Update rows for course listing sub updateclasssheet { - my $safeeval=shift; - my $cnum=&getcnum($safeeval); - my $cdom=&getcdom($safeeval); - my $cid=&getcid($safeeval); - my $chome=&getchome($safeeval); + my ($safeeval,$sheetdata) = @_; + my $cnum =$sheetdata->{'cnum'}; + my $cdom =$sheetdata->{'cdom'}; + my $cid =$sheetdata->{'cid'}; + my $chome =$sheetdata->{'chome'}; # # Read class list and row labels my %classlist; @@ -1709,15 +1693,15 @@ sub updateclasssheet { my ($studentName,$studentDomain)=split(/\:/,$student); my $studentSection=&Apache::lonnet::usection($studentDomain, $studentName,$cid); - if ($studentSection==-1) { - unless ($ENV{'form.showcsv'}) { - $rowlabel='Data not available: '. - $studentName.''; - } else { - $rowlabel='ERROR","'.$studentName. - '","Data not available","","","'; - } - } else { +# if ($studentSection==-1) { +# unless ($ENV{'form.showcsv'}) { +# $rowlabel='Data not available: '. +# $studentName.''; +# } else { +# $rowlabel='ERROR","'.$studentName. +# '","Data not available","","","'; +# } +# } else { my %reply=&Apache::lonnet::idrget($studentDomain,$studentName); my %studentInformation=&Apache::lonnet::get ('environment', @@ -1742,7 +1726,7 @@ sub updateclasssheet { $studentInformation{'generation'}) ).'"'; } - } + # } $currentlist{$student}=$rowlabel; } # end of if ($active) } # end of foreach my $student (keys(%classlist)) @@ -1784,13 +1768,17 @@ sub updateclasssheet { # ----------------------------------- Update rows for student and assess sheets sub updatestudentassesssheet { - my $safeeval=shift; + my ($safeeval,$sheetdata) = @_; my %bighash; - my $stype=&gettype($safeeval); + my $stype=$sheetdata->{'sheettype'}; + my $uname=$sheetdata->{'uname'}; + my $udom =$sheetdata->{'udom'}; my %current=(); - if ($updatedata{$ENV{'request.course.fn'}.'_'.$stype}) { + if ($updatedata + {$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}) { %current=split(/\_\_\_\;\_\_\_/, - $updatedata{$ENV{'request.course.fn'}.'_'.$stype}); + $updatedata{$ENV{'request.course.fn'}. + '_'.$stype.'_'.$uname.'_'.$udom}); } else { # Tie hash tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', @@ -1808,10 +1796,8 @@ sub updatestudentassesssheet { 'totalpoints' => 'Total Points Granted
totalpoints'); my $adduserstr=''; - if ((&getuname($safeeval) ne $ENV{'user.name'}) || - (&getudom($safeeval) ne $ENV{'user.domain'})) { - $adduserstr='&uname='.&getuname($safeeval). - '&udom='.&getudom($safeeval); + if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})){ + $adduserstr='&uname='.$uname.'&udom='.$udom; } my %allassess = ('_feedback' =>'{'sheettype'}; if ($stype eq 'classcalc') { - return &updateclasssheet($safeeval); + return &updateclasssheet($safeeval,$sheetdata); } else { - return &updatestudentassesssheet($safeeval); + return &updatestudentassesssheet($safeeval,$sheetdata); } } @@ -2437,6 +2416,14 @@ sub cachedssheets { 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; @@ -2547,12 +2534,12 @@ ENDSCRIPT unless ($asheetdata->{'sheettype'} eq 'classcalc') { $r->print('

User: '.$asheetdata->{'uname'}. '
Domain: '.$asheetdata->{'udom'}); - if (&getcsec($asheet) eq '-1') { - $r->print('

'. - 'Not a student in this course

'); - } else { +# if (&getcsec($asheet) eq '-1') { +# $r->print('

'. +# 'Not a student in this course

'); +# } else { $r->print('
Section/Group: '.$asheetdata->{'csec'}); - } +# } if ($ENV{'form.usymb'}) { $r->print('
Assessment: '. $ENV{'form.usymb'}.''); @@ -2608,7 +2595,7 @@ ENDSCRIPT $r->print('>'.$_.''); } $r->print('

'); - if (&gettype($asheet) eq 'studentcalc') { + if ($asheetdata->{'sheettype'} eq 'studentcalc') { &setothersheets($asheet,&othersheets($asheet,'assesscalc')); } }