--- loncom/interface/Attic/lonspreadsheet.pm 2001/10/17 21:11:22 1.70 +++ loncom/interface/Attic/lonspreadsheet.pm 2001/11/28 18:42:50 1.76 @@ -7,7 +7,7 @@ # 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 Gerd Kortemeyer +# 10/16,10/17,10/20,11/05,11/28 Gerd Kortemeyer package Apache::lonspreadsheet; @@ -677,7 +677,11 @@ sub rown { } else { $defaultbg='#E0FF'; } - $rowdata.="\n$n"; + unless ($ENV{'form.showcsv'}) { + $rowdata.="\n$n"; + } else { + $rowdata.="\n".'"'.$n.'"'; + } my $showf=0; my $proc; my $maxred; @@ -700,6 +704,7 @@ sub rown { if ((($vl ne '') || ($vl eq '0')) && (($showf==1) || ($sheettype ne 'studentcalc'))) { $dataflag=1; } if ($showf==0) { $vl=$_; } + unless ($ENV{'form.showcsv'}) { if ($showf<=$maxred) { $bgcolor='#FFDDDD'; } if (($n==0) && ($showf<=26)) { $bgcolor='#CCCCFF'; } if (($showf>$maxred) || ((!$n) && ($showf>0))) { @@ -712,10 +717,13 @@ sub rown { } else { $rowdata.=' '.$vl.' '; } + } else { + $rowdata.=',"'.$vl.'"'; + } $showf++; } $safeeval->reval($proc.'('.$n.')'); if ($ENV{'form.showall'} || ($dataflag)) { - return $rowdata.''; + return $rowdata.($ENV{'form.showcsv'}?'':''); } else { return ''; } @@ -738,7 +746,9 @@ sub outsheet { $realm='Course'; } my $maxyellow=52-$maxred; - my $tabledata= + my $tabledata; + unless ($ENV{'form.showcsv'}) { + $tabledata= ''. '
'. $realm.'print($tabledata); + my $row; my $maxrow=&getmaxrow($safeeval); - $tabledata.=&rown($safeeval,'-').&rown($safeeval,0); - $r->print($tabledata); my @sortby=(); my @sortidx=(); @@ -783,7 +795,7 @@ sub outsheet { for ($row=0;$row<$maxrow;$row++) { my $thisrow=&rown($safeeval,$sortidx[$row]+1); if ($thisrow) { - if ($n/25==int($n/25)) { + if (($n/25==int($n/25)) && (!$ENV{'form.showcsv'})) { $r->print("
\n
\n"); $r->rflush(); $r->print(''); @@ -799,7 +811,7 @@ sub outsheet { $r->print($thisrow); } } - $r->print('
 '.$what.'
'); + $r->print($ENV{'form.showcsv'}?'':''); } # @@ -868,10 +880,13 @@ sub readsheet { my $sheetxml=''; { my $fh; - if ($fh=Apache::File->new($includedir. - '/default.'.&gettype($safeeval))) { + my $dfn=$fn; + $dfn=~s/\_/\./g; + if ($fh=Apache::File->new($includedir.'/'.$dfn)) { $sheetxml=join('',<$fh>); - } + } else { + $sheetxml='"Error"'; + } } my $parser=HTML::TokeParser->new(\$sheetxml); my $token; @@ -1141,13 +1156,19 @@ sub updateclasssheet { 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 { my %reply=&Apache::lonnet::idrget($sdom,$sname); my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname. ':environment:firstname&middlename&lastname&generation', &Apache::lonnet::homeserver($sname,$sdom)); + unless ($ENV{'form.showcsv'}) { $rowlabel=''. $ssec.' '.$reply{$sname}.'
'; @@ -1155,6 +1176,16 @@ sub updateclasssheet { $rowlabel.=&Apache::lonnet::unescape($_).' '; } split(/\&/,$reply); $rowlabel.='
'; + } else { + $rowlabel=$ssec.'","'.$reply{$sname}.'"'; + my $ncount=0; + map { + $rowlabel.=',"'.&Apache::lonnet::unescape($_).'"'; + $ncount++; + } split(/\&/,$reply); + unless ($ncount==4) { $rowlabel.=',""'; } + $rowlabel=~s/\"$//; + } } $currentlist{&Apache::lonnet::unescape($name)}=$rowlabel; } @@ -1214,8 +1245,13 @@ sub updatestudentassesssheet { # --------------------------------------------------------- Get all assessments my %allkeys=('timestamp' => - 'Timestamp of Last Transaction
timestamp'); - my %allassess=(); + 'Timestamp of Last Transaction
timestamp', + 'subnumber' => + 'Number of Submissions
subnumber', + 'tutornumber' => + 'Number of Tutor Responses
tutornumber', + 'totalpoints' => + 'Total Points Granted
totalpoints'); my $adduserstr=''; if ((&getuname($safeeval) ne $ENV{'user.name'}) || @@ -1224,6 +1260,20 @@ sub updatestudentassesssheet { '&udom='.&getudom($safeeval); } + my %allassess=('_feedback' => + 'Feedback', + '_evaluation' => + 'Evaluation', + '_tutoring' => + 'Tutoring', + '_discussion' => + 'Discussion' + ); + map { if ($_=~/^src\_(\d+)\.(\d+)$/) { my $mapid=$1; @@ -1497,6 +1547,18 @@ sub loadassessment { } # ----------------------------- returnhash now has all stores for this resource +# --------- convert all "_" to "." to be able to use libraries, multiparts, etc + + my @oldkeys=keys %returnhash; + + map { + my $name=$_; + my $value=$returnhash{$_}; + delete $returnhash{$_}; + $name=~s/\_/\./g; + $returnhash{$name}=$value; + } @oldkeys; + # ---------------------------- initialize coursedata and userdata for this user undef %courseopt; undef %useropt; @@ -1675,6 +1737,11 @@ sub forcedrecalc { sub exportsheet { my ($uname,$udom,$stype,$usymb,$fn)=@_; my @exportarr=(); + + if (($usymb=~/^\_(\w+)/) && (!$fn)) { + $fn='default_'.$1; + } + # # Check if cached # @@ -1899,6 +1966,10 @@ $tmpdir=$r->dir_config('lonDaemons').'/t } } (split(/&/,$ENV{'QUERY_STRING'})); + if (($ENV{'form.usymb'}=~/^\_(\w+)/) && (!$ENV{'form.ufn'})) { + $ENV{'form.ufn'}='default_'.$1; + } + # -------------------------------------- Interactive loading of specific sheet? if (($ENV{'form.load'}) && ($ENV{'form.loadthissheet'} ne 'Default')) { $ENV{'form.ufn'}=$ENV{'form.loadthissheet'};