--- loncom/interface/Attic/lonspreadsheet.pm 2002/07/15 12:26:51 1.97 +++ loncom/interface/Attic/lonspreadsheet.pm 2002/09/27 18:43:10 1.100.4.1 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.97 2002/07/15 12:26:51 www Exp $ +# $Id: lonspreadsheet.pm,v 1.100.4.1 2002/09/27 18:43:10 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -71,7 +71,7 @@ use Apache::lonnet; use Apache::Constants qw(:common :http); use GDBM_File; use HTML::TokeParser; - +use Apache::lonhtmlcommon; # # Caches for previously calculated spreadsheets # @@ -768,6 +768,14 @@ sub expandnamed { } if ($#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 { $returnvalue = "'bad parameter name : $expression'"; } @@ -1179,9 +1187,14 @@ sub rown { if ($vl eq '') { $vl='#'; } - $rowdata.= - ''.$vl. - ''; + $rowdata.=''; + if ($ENV{'request.role'} =~ /^st\./) { + $rowdata.=$vl; + } else { + $rowdata.=''. + $vl.''; + } + $rowdata.=''; } else { $rowdata.=' '.$vl.' '; } @@ -1652,20 +1665,22 @@ sub updateclasssheet { my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value)); my $active=1; if (($end) && ($now>$end)) { $active=0; } + $active = 1 if ($ENV{'form.Status'} eq 'Any'); + $active = !$active if ($ENV{'form.Status'} eq 'Expired'); if ($active) { my $rowlabel=''; $name=&Apache::lonnet::unescape($name); my ($sname,$sdom)=split(/\:/,$name); my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid); - if ($ssec==-1) { - unless ($ENV{'form.showcsv'}) { - $rowlabel='Data not available: '.$name. - ''; - } else { - $rowlabel='ERROR","'.$name. - '","Data not available","","","'; - } - } else { +# if ($ssec==-1) { +# unless ($ENV{'form.showcsv'}) { +# $rowlabel='Data not available: '.$name. +# ''; +# } else { +# $rowlabel='ERROR","'.$name. +# '","Data not available","","","'; +# } +# } else { my %reply=&Apache::lonnet::idrget($sdom,$sname); my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname. ':environment:firstname&middlename&lastname&generation', @@ -1688,7 +1703,7 @@ sub updateclasssheet { unless ($ncount==4) { $rowlabel.=',""'; } $rowlabel=~s/\"$//; } - } +# } $currentlist{&Apache::lonnet::unescape($name)}=$rowlabel; } } # end of foreach (split(/\&/,$classlst)) @@ -1740,11 +1755,14 @@ sub updatestudentassesssheet { my $safeeval=shift; my %bighash; my $stype=&gettype($safeeval); + my $uname=&getuname($safeeval); + my $udom =&getudom($safeeval); my %current=(); - unless ($updatedata{$ENV{'request.course.fn'}.'_'.$stype}) { + unless ($updatedata{ + $ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}) { # -------------------------------------------------------------------- Tie hash if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', - &GDBM_READER,0640)) { + &GDBM_READER(),0640)) { # --------------------------------------------------------- Get all assessments my %allkeys=('timestamp' => @@ -1822,7 +1840,7 @@ sub updatestudentassesssheet { } elsif ($stype eq 'studentcalc') { %current=%allassess; } - $updatedata{$ENV{'request.course.fn'}.'_'.$stype}= + $updatedata{$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}= join('___;___',%current); } else { return 'Could not access course data'; @@ -1830,7 +1848,7 @@ sub updatestudentassesssheet { # ------------------------------------------------------ Get current from cache } else { %current=split(/\_\_\_\;\_\_\_/, - $updatedata{$ENV{'request.course.fn'}.'_'.$stype}); + $updatedata{$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}); } # -------------------- Find discrepancies between the course row table and this # @@ -2120,7 +2138,7 @@ sub loadassessment { my %c=(); if (tie(%parmhash,'GDBM_File', - &getcfn($safeeval).'_parms.db',&GDBM_READER,0640)) { + &getcfn($safeeval).'_parms.db',&GDBM_READER(),0640)) { my %f=&getformulas($safeeval); foreach (keys(%f)) { if ($_=~/^A/) { @@ -2448,6 +2466,11 @@ sub handler { return OK; } + if ($ENV{'request.role'} =~ /^st\./) { + delete $ENV{'form.unewfield'} if (exists($ENV{'form.unewfield'})); + delete $ENV{'form.unewformula'} if (exists($ENV{'form.unewformula'})); + } + # ---------------------------------------------------- Global directory configs $includedir=$r->dir_config('lonIncludes'); @@ -2493,7 +2516,8 @@ $tmpdir=$r->dir_config('lonDaemons').'/t # --------------------------------------------------------------- Screen output $r->print('LON-CAPA Spreadsheet'); - $r->print(<print(< function celledit(cn,cf) { @@ -2519,6 +2543,7 @@ $tmpdir=$r->dir_config('lonDaemons').'/t ENDSCRIPT + } $r->print(''. ''. '

LON-CAPA Spreadsheet

'. @@ -2574,12 +2599,12 @@ ENDSCRIPT unless (&gettype($asheet) eq 'classcalc') { $r->print('

User: '.&getuname($asheet). '
Domain: '.&getudom($asheet)); - 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: '.&getcsec($asheet)); - } +# } if ($ENV{'form.usymb'}) { $r->print('
Assessment: '.$ENV{'form.usymb'}.''); } @@ -2742,6 +2767,9 @@ ENDSCRIPT } # ------------------------------------------------------------------ Insertrows + $r->print(' Student Status: '. + &Apache::lonhtmlcommon::StatusOptions + ($ENV{'form.Status'},'sheet')); $r->print(<