version 1.106, 2002/09/01 18:06:52
|
version 1.115, 2002/10/01 07:09:05
|
Line 26
|
Line 26
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# Spreadsheet/Grades Display Handler |
# 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: |
# POD required stuff: |
|
|
=head1 NAME |
=head1 NAME |
Line 54 not the grades of their peers. The spre
|
Line 44 not the grades of their peers. The spre
|
offering the ability to use Perl code to manipulate data, as well as many |
offering the ability to use Perl code to manipulate data, as well as many |
built-in functions. |
built-in functions. |
|
|
|
|
=head2 Functions available to user of lonspreadsheet |
=head2 Functions available to user of lonspreadsheet |
|
|
=over 4 |
=over 4 |
Line 73 use GDBM_File;
|
Line 62 use GDBM_File;
|
use HTML::TokeParser; |
use HTML::TokeParser; |
use Apache::lonhtmlcommon; |
use Apache::lonhtmlcommon; |
# |
# |
|
# Caches for coursewide information |
|
# |
|
my %Section; |
|
|
|
# |
# Caches for previously calculated spreadsheets |
# Caches for previously calculated spreadsheets |
# |
# |
|
|
Line 167 $chome= '';
|
Line 161 $chome= '';
|
$cnum = ''; |
$cnum = ''; |
$cdom = ''; |
$cdom = ''; |
$cid = ''; |
$cid = ''; |
$cfn = ''; |
$coursefilename = ''; |
|
|
# symb |
# symb |
|
|
Line 863 sub sett {
|
Line 857 sub sett {
|
} |
} |
# Deal with the normal cells |
# Deal with the normal cells |
foreach (keys(%f)) { |
foreach (keys(%f)) { |
if (($f{$_}) && ($_!~/template\_/)) { |
if (exists($f{$_}) && ($_!~/template\_/)) { |
my $matches=($_=~/^$pattern(\d+)/); |
my $matches=($_=~/^$pattern(\d+)/); |
if (($matches) && ($1)) { |
if (($matches) && ($1)) { |
unless ($f{$_}=~/^\!/) { |
unless ($f{$_}=~/^\!/) { |
Line 1111 sub getcid {
|
Line 1105 sub getcid {
|
|
|
# --------------------------------------------------------- Get course filename |
# --------------------------------------------------------- Get course filename |
|
|
sub getcfn { |
sub getcoursefilename { |
my $safeeval=shift; |
my $safeeval=shift; |
return $safeeval->reval('$cfn'); |
return $safeeval->reval('$coursefilename'); |
} |
} |
|
|
# ----------------------------------------------------------- Get course number |
# ----------------------------------------------------------- Get course number |
Line 1237 sub rown {
|
Line 1231 sub rown {
|
if ($vl eq '') { |
if ($vl eq '') { |
$vl='<font size=+2 color='.$bgcolor.'>#</font>'; |
$vl='<font size=+2 color='.$bgcolor.'>#</font>'; |
} |
} |
$rowdata.='<td bgcolor='.$bgcolor.'>'. |
$rowdata.='<td bgcolor='.$bgcolor.'>'; |
'<a href="javascript:celledit('.$fm.');">'.$vl.'</a></td>'; |
if ($ENV{'request.role'} =~ /^st\./) { |
|
$rowdata.=$vl; |
|
} else { |
|
$rowdata.='<a href="javascript:celledit('.$fm.');">'. |
|
$vl.'</a>'; |
|
} |
|
$rowdata.='</td>'; |
} else { |
} else { |
$rowdata.='<td bgcolor='.$bgcolor.'> '.$vl.' </td>'; |
$rowdata.='<td bgcolor='.$bgcolor.'> '.$vl.' </td>'; |
} |
} |
Line 1310 sub outsheet {
|
Line 1310 sub outsheet {
|
push (@sortby, $safeeval->reval('$f{"A'.$row.'"}')); |
push (@sortby, $safeeval->reval('$f{"A'.$row.'"}')); |
push (@sortidx, $row-1); |
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 |
# Determine the type of child spreadsheets |
my $what='Student'; |
my $what='Student'; |
Line 1393 sub parse_sheet {
|
Line 1393 sub parse_sheet {
|
# |
# |
# -------------------------------------- Read spreadsheet formulas for a course |
# -------------------------------------- Read spreadsheet formulas for a course |
# |
# |
|
|
sub readsheet { |
sub readsheet { |
my ($safeeval,$fn)=@_; |
my ($safeeval,$sheetdata,$fn)=@_; |
my $stype = &gettype($safeeval); |
# |
my $cnum = &getcnum($safeeval); |
my $stype = $sheetdata->{'sheettype'}; |
my $cdom = &getcdom($safeeval); |
my $cnum = $sheetdata->{'cnum'}; |
my $chome = &getchome($safeeval); |
my $cdom = $sheetdata->{'cdom'}; |
|
my $chome = $sheetdata->{'chome'}; |
|
# |
if (! defined($fn)) { |
if (! defined($fn)) { |
# There is no filename. Look for defaults in course and global, cache |
# There is no filename. Look for defaults in course and global, cache |
unless ($fn=$defaultsheets{$cnum.'_'.$cdom.'_'.$stype}) { |
unless ($fn=$defaultsheets{$cnum.'_'.$cdom.'_'.$stype}) { |
Line 1464 sub readsheet {
|
Line 1464 sub readsheet {
|
} |
} |
|
|
# -------------------------------------------------------- Make new spreadsheet |
# -------------------------------------------------------- Make new spreadsheet |
|
|
sub makenewsheet { |
sub makenewsheet { |
my ($uname,$udom,$stype,$usymb)=@_; |
my ($uname,$udom,$stype,$usymb)=@_; |
my %sheetdata=(); |
my %sheetdata=(); |
Line 1473 sub makenewsheet {
|
Line 1472 sub makenewsheet {
|
$sheetdata{'sheettype'} = $stype; |
$sheetdata{'sheettype'} = $stype; |
$sheetdata{'usymb'} = $usymb; |
$sheetdata{'usymb'} = $usymb; |
$sheetdata{'cid'} = $ENV{'request.course.id'}; |
$sheetdata{'cid'} = $ENV{'request.course.id'}; |
$sheetdata{'csec'} = &Apache::lonnet::usection |
$sheetdata{'csec'} = $Section{$uname.':'.$udom}; |
($udom,$uname,$ENV{'request.course.id'}); |
$sheetdata{'coursefilename'} = $ENV{'request.course.fn'}; |
$sheetdata{'cfn'} = $ENV{'request.course.fn'}; |
|
$sheetdata{'cnum'} = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
$sheetdata{'cnum'} = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
$sheetdata{'cdom'} = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
$sheetdata{'cdom'} = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
$sheetdata{'chome'} = $ENV{'course.'.$ENV{'request.course.id'}.'.home'}; |
$sheetdata{'chome'} = $ENV{'course.'.$ENV{'request.course.id'}.'.home'}; |
Line 1491 sub makenewsheet {
|
Line 1489 sub makenewsheet {
|
} |
} |
|
|
# ------------------------------------------------------------ Save spreadsheet |
# ------------------------------------------------------------ Save spreadsheet |
|
|
sub writesheet { |
sub writesheet { |
my ($safeeval,$makedef)=@_; |
my ($safeeval,$makedef)=@_; |
my $cid=&getcid($safeeval); |
my $cid=&getcid($safeeval); |
Line 1543 sub writesheet {
|
Line 1540 sub writesheet {
|
# ----------------------------------------------- Make a temp copy of the sheet |
# ----------------------------------------------- Make a temp copy of the sheet |
# "Modified workcopy" - interactive only |
# "Modified workcopy" - interactive only |
# |
# |
|
|
sub tmpwrite { |
sub tmpwrite { |
my $safeeval=shift; |
my $safeeval=shift; |
my $fn=$ENV{'user.name'}.'_'. |
my $fn=$ENV{'user.name'}.'_'. |
Line 1558 sub tmpwrite {
|
Line 1554 sub tmpwrite {
|
} |
} |
|
|
# ---------------------------------------------------------- Read the temp copy |
# ---------------------------------------------------------- Read the temp copy |
|
|
sub tmpread { |
sub tmpread { |
my ($safeeval,$nfield,$nform)=@_; |
my ($safeeval,$nfield,$nform)=@_; |
my $fn=$ENV{'user.name'}.'_'. |
my $fn=$ENV{'user.name'}.'_'. |
Line 1655 sub parmval {
|
Line 1650 sub parmval {
|
my $courselevelr = $usercourseprefix.'.'.$symbparm; |
my $courselevelr = $usercourseprefix.'.'.$symbparm; |
my $courselevelm = $usercourseprefix.'.'.$mapparm; |
my $courselevelm = $usercourseprefix.'.'.$mapparm; |
# fourth, check user |
# fourth, check user |
if ($uname) { |
if (defined($uname)) { |
return $useropt{$courselevelr} if ($useropt{$courselevelr}); |
return $useropt{$courselevelr} if (defined($useropt{$courselevelr})); |
return $useropt{$courselevelm} if ($useropt{$courselevelm}); |
return $useropt{$courselevelm} if (defined($useropt{$courselevelm})); |
return $useropt{$courselevel} if ($useropt{$courselevel}); |
return $useropt{$courselevel} if (defined($useropt{$courselevel})); |
} |
} |
# third, check course |
# third, check course |
if ($csec) { |
if (defined($csec)) { |
return $courseopt{$seclevelr} if ($courseopt{$seclevelr}); |
return $courseopt{$seclevelr} if (defined($courseopt{$seclevelr})); |
return $courseopt{$seclevelm} if ($courseopt{$seclevelm}); |
return $courseopt{$seclevelm} if (defined($courseopt{$seclevelm})); |
return $courseopt{$seclevel} if ($courseopt{$seclevel}); |
return $courseopt{$seclevel} if (defined($courseopt{$seclevel})); |
} |
} |
# |
# |
return $courseopt{$courselevelr} if ($courseopt{$courselevelr}); |
return $courseopt{$courselevelr} if (defined($courseopt{$courselevelr})); |
return $courseopt{$courselevelm} if ($courseopt{$courselevelm}); |
return $courseopt{$courselevelm} if (defined($courseopt{$courselevelm})); |
return $courseopt{$courselevel} if ($courseopt{$courselevel}); |
return $courseopt{$courselevel} if (defined($courseopt{$courselevel})); |
# second, check map parms |
# second, check map parms |
my $thisparm = $parmhash{$symbparm}; |
my $thisparm = $parmhash{$symbparm}; |
return $thisparm if ($thisparm); |
return $thisparm if (defined($thisparm)); |
# first, check default |
# first, check default |
return &Apache::lonnet::metadata($fn,$rwhat.'.default'); |
return &Apache::lonnet::metadata($fn,$rwhat.'.default'); |
} |
} |
|
|
# ---------------------------------------------- Update rows for course listing |
# ---------------------------------------------- Update rows for course listing |
sub updateclasssheet { |
sub updateclasssheet { |
my $safeeval=shift; |
my ($safeeval,$sheetdata) = @_; |
my $cnum=&getcnum($safeeval); |
my $cnum =$sheetdata->{'cnum'}; |
my $cdom=&getcdom($safeeval); |
my $cdom =$sheetdata->{'cdom'}; |
my $cid=&getcid($safeeval); |
my $cid =$sheetdata->{'cid'}; |
my $chome=&getchome($safeeval); |
my $chome =$sheetdata->{'chome'}; |
|
# |
|
%Section = (); |
|
|
# |
# |
# Read class list and row labels |
# Read class list and row labels |
my %classlist; |
my %classlist; |
Line 1708 sub updateclasssheet {
|
Line 1706 sub updateclasssheet {
|
my ($studentName,$studentDomain)=split(/\:/,$student); |
my ($studentName,$studentDomain)=split(/\:/,$student); |
my $studentSection=&Apache::lonnet::usection($studentDomain, |
my $studentSection=&Apache::lonnet::usection($studentDomain, |
$studentName,$cid); |
$studentName,$cid); |
if ($studentSection==-1) { |
$Section{$studentName.':'.$studentDomain} = $studentSection; |
unless ($ENV{'form.showcsv'}) { |
# if ($studentSection==-1) { |
$rowlabel='<font color=red>Data not available: '. |
# unless ($ENV{'form.showcsv'}) { |
$studentName.'</font>'; |
# $rowlabel='<font color=red>Data not available: '. |
} else { |
# $studentName.'</font>'; |
$rowlabel='ERROR","'.$studentName. |
# } else { |
'","Data not available","","","'; |
# $rowlabel='ERROR","'.$studentName. |
} |
# '","Data not available","","","'; |
} else { |
# } |
|
# } else { |
my %reply=&Apache::lonnet::idrget($studentDomain,$studentName); |
my %reply=&Apache::lonnet::idrget($studentDomain,$studentName); |
my %studentInformation=&Apache::lonnet::get |
my %studentInformation=&Apache::lonnet::get |
('environment', |
('environment', |
Line 1741 sub updateclasssheet {
|
Line 1740 sub updateclasssheet {
|
$studentInformation{'generation'}) |
$studentInformation{'generation'}) |
).'"'; |
).'"'; |
} |
} |
} |
# } |
$currentlist{$student}=$rowlabel; |
$currentlist{$student}=$rowlabel; |
} # end of if ($active) |
} # end of if ($active) |
} # end of foreach my $student (keys(%classlist)) |
} # end of foreach my $student (keys(%classlist)) |
Line 1783 sub updateclasssheet {
|
Line 1782 sub updateclasssheet {
|
|
|
# ----------------------------------- Update rows for student and assess sheets |
# ----------------------------------- Update rows for student and assess sheets |
sub updatestudentassesssheet { |
sub updatestudentassesssheet { |
my $safeeval=shift; |
my ($safeeval,$sheetdata) = @_; |
my %bighash; |
my %bighash; |
my $stype=&gettype($safeeval); |
my $stype=$sheetdata->{'sheettype'}; |
|
my $uname=$sheetdata->{'uname'}; |
|
my $udom =$sheetdata->{'udom'}; |
my %current=(); |
my %current=(); |
if ($updatedata{$ENV{'request.course.fn'}.'_'.$stype}) { |
if ($updatedata |
|
{$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}) { |
%current=split(/\_\_\_\;\_\_\_/, |
%current=split(/\_\_\_\;\_\_\_/, |
$updatedata{$ENV{'request.course.fn'}.'_'.$stype}); |
$updatedata{$ENV{'request.course.fn'}. |
|
'_'.$stype.'_'.$uname.'_'.$udom}); |
} else { |
} else { |
# Tie hash |
# Tie hash |
tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
Line 1807 sub updatestudentassesssheet {
|
Line 1810 sub updatestudentassesssheet {
|
'totalpoints' => |
'totalpoints' => |
'Total Points Granted<br>totalpoints'); |
'Total Points Granted<br>totalpoints'); |
my $adduserstr=''; |
my $adduserstr=''; |
if ((&getuname($safeeval) ne $ENV{'user.name'}) || |
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})){ |
(&getudom($safeeval) ne $ENV{'user.domain'})) { |
$adduserstr='&uname='.$uname.'&udom='.$udom; |
$adduserstr='&uname='.&getuname($safeeval). |
|
'&udom='.&getudom($safeeval); |
|
} |
} |
my %allassess = |
my %allassess = |
('_feedback' =>'<a href="/adm/assesscalc?usymb=_feedback'. |
('_feedback' =>'<a href="/adm/assesscalc?usymb=_feedback'. |
Line 1822 sub updatestudentassesssheet {
|
Line 1823 sub updatestudentassesssheet {
|
'_discussion' =>'<a href="/adm/assesscalc?usymb=_discussion'. |
'_discussion' =>'<a href="/adm/assesscalc?usymb=_discussion'. |
$adduserstr.'">Discussion</a>' |
$adduserstr.'">Discussion</a>' |
); |
); |
foreach (keys(%bighash)) { |
while (($_,undef) = each(%bighash)) { |
next if ($_!~/^src\_(\d+)\.(\d+)$/); |
next if ($_!~/^src\_(\d+)\.(\d+)$/); |
my $mapid=$1; |
my $mapid=$1; |
my $resid=$2; |
my $resid=$2; |
Line 1861 sub updatestudentassesssheet {
|
Line 1862 sub updatestudentassesssheet {
|
} elsif ($stype eq 'studentcalc') { |
} elsif ($stype eq 'studentcalc') { |
%current=%allassess; |
%current=%allassess; |
} |
} |
$updatedata{$ENV{'request.course.fn'}.'_'.$stype}= |
$updatedata{$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}= |
join('___;___',%current); |
join('___;___',%current); |
# Get current from cache |
# Get current from cache |
} |
} |
Line 1953 sub loadstudent {
|
Line 1954 sub loadstudent {
|
} |
} |
|
|
# --------------------------------------------------- Load data for one student |
# --------------------------------------------------- Load data for one student |
|
# |
sub loadcourse { |
sub loadcourse { |
my ($safeeval,$sheetdata,$r)=@_; |
my ($safeeval,$sheetdata,$r)=@_; |
my %c=(); |
my %c=(); |
Line 2015 ENDPOP
|
Line 2016 ENDPOP
|
} |
} |
|
|
# ------------------------------------------------ Load data for one assessment |
# ------------------------------------------------ Load data for one assessment |
|
# |
sub loadassessment { |
sub loadassessment { |
my ($safeeval,$sheetdata)=@_; |
my ($safeeval,$sheetdata)=@_; |
|
|
Line 2047 sub loadassessment {
|
Line 2048 sub loadassessment {
|
# |
# |
# restore individual |
# restore individual |
# |
# |
my $answer=&Apache::lonnet::reply( |
%returnhash = &Apache::lonnet::restore($symb,$namespace,$udom,$uname); |
"restore:$udom:$uname:". |
for (my $version=1;$version<=$returnhash{'version'};$version++) { |
&Apache::lonnet::escape($namespace).":". |
|
&Apache::lonnet::escape($symb),$uhome); |
|
foreach (split(/\&/,$answer)) { |
|
my ($name,$value)=split(/\=/,$_); |
|
$returnhash{&Apache::lonnet::unescape($name)}= |
|
&Apache::lonnet::unescape($value); |
|
} |
|
my $version; |
|
for ($version=1;$version<=$returnhash{'version'};$version++) { |
|
foreach (split(/\:/,$returnhash{$version.':keys'})) { |
foreach (split(/\:/,$returnhash{$version.':keys'})) { |
$returnhash{$_}=$returnhash{$version.':'.$_}; |
$returnhash{$_}=$returnhash{$version.':'.$_}; |
} |
} |
} |
} |
} |
} |
|
# |
# returnhash now has all stores for this resource |
# returnhash now has all stores for this resource |
# convert all "_" to "." to be able to use libraries, multiparts, etc |
# convert all "_" to "." to be able to use libraries, multiparts, etc |
|
# |
|
# This is dumb. It is also necessary :( |
my @oldkeys=keys %returnhash; |
my @oldkeys=keys %returnhash; |
|
# |
foreach (@oldkeys) { |
foreach (@oldkeys) { |
my $name=$_; |
my $name=$_; |
my $value=$returnhash{$_}; |
my $value=$returnhash{$_}; |
Line 2096 sub loadassessment {
|
Line 2091 sub loadassessment {
|
&Apache::lonnet::unescape($value); |
&Apache::lonnet::unescape($value); |
} |
} |
# Get userdata (if present) |
# Get userdata (if present) |
unless |
unless ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) { |
((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) { |
my $reply= |
my $reply= |
&Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome); |
&Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome); |
if ($reply!~/^error\:/) { |
if ($reply!~/^error\:/) { |
$userrdatas{$uname.'___'.$udom}=$reply; |
$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})) { |
foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) { |
my ($name,$value)=split(/\=/,$_); |
my ($name,$value)=split(/\=/,$_); |
$useropt{$userprefix.&Apache::lonnet::unescape($name)}= |
$useropt{$userprefix.&Apache::lonnet::unescape($name)}= |
Line 2126 sub loadassessment {
|
Line 2123 sub loadassessment {
|
# |
# |
my %c=(); |
my %c=(); |
if (tie(%parmhash,'GDBM_File', |
if (tie(%parmhash,'GDBM_File', |
&getcfn($safeeval).'_parms.db',&GDBM_READER(),0640)) { |
&getcoursefilename($safeeval).'_parms.db',&GDBM_READER(),0640)) { |
my %f=&getformulas($safeeval); |
my %f=&getformulas($safeeval); |
foreach (keys(%f)) { |
foreach (keys(%f)) { |
next if ($_!~/^A/); |
next if ($_!~/^A/); |
Line 2184 sub updatesheet {
|
Line 2181 sub updatesheet {
|
my ($safeeval,$sheetdata)=@_; |
my ($safeeval,$sheetdata)=@_; |
my $stype=$sheetdata->{'sheettype'}; |
my $stype=$sheetdata->{'sheettype'}; |
if ($stype eq 'classcalc') { |
if ($stype eq 'classcalc') { |
return &updateclasssheet($safeeval); |
return &updateclasssheet($safeeval,$sheetdata); |
} else { |
} else { |
return &updatestudentassesssheet($safeeval); |
return &updatestudentassesssheet($safeeval,$sheetdata); |
} |
} |
} |
} |
|
|
Line 2292 sub exportsheet {
|
Line 2289 sub exportsheet {
|
# Not cached |
# Not cached |
# |
# |
my ($thissheet,$sheetdata)=&makenewsheet($uname,$udom,$stype,$usymb); |
my ($thissheet,$sheetdata)=&makenewsheet($uname,$udom,$stype,$usymb); |
&readsheet($thissheet,$fn); |
&readsheet($thissheet,$sheetdata,$fn); |
&updatesheet($thissheet,$sheetdata); |
&updatesheet($thissheet,$sheetdata); |
&loadrows($thissheet,$sheetdata); |
&loadrows($thissheet,$sheetdata); |
&calcsheet($thissheet,$sheetdata); |
&calcsheet($thissheet,$sheetdata); |
Line 2432 sub cachedssheets {
|
Line 2429 sub cachedssheets {
|
# Interactive call to screen |
# Interactive call to screen |
# |
# |
# |
# |
|
|
|
|
sub handler { |
sub handler { |
my $r=shift; |
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) { |
if ($r->header_only) { |
$r->content_type('text/html'); |
$r->content_type('text/html'); |
$r->send_http_header; |
$r->send_http_header; |
Line 2454 sub handler {
|
Line 2456 sub handler {
|
# Get query string for limited number of parameters |
# Get query string for limited number of parameters |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['uname','udom','usymb','ufn']); |
['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'})) { |
if (($ENV{'form.usymb'}=~/^\_(\w+)/) && (!$ENV{'form.ufn'})) { |
$ENV{'form.ufn'}='default_'.$1; |
$ENV{'form.ufn'}='default_'.$1; |
} |
} |
Line 2480 sub handler {
|
Line 2486 sub handler {
|
$r->send_http_header; |
$r->send_http_header; |
# Screen output |
# Screen output |
$r->print('<html><head><title>LON-CAPA Spreadsheet</title>'); |
$r->print('<html><head><title>LON-CAPA Spreadsheet</title>'); |
$r->print(<<ENDSCRIPT); |
if ($ENV{'request.role'} !~ /^st\./) { |
|
$r->print(<<ENDSCRIPT); |
<script language="JavaScript"> |
<script language="JavaScript"> |
|
|
function celledit(cn,cf) { |
function celledit(cn,cf) { |
Line 2506 sub handler {
|
Line 2513 sub handler {
|
|
|
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
|
} |
$r->print('</head>'.&Apache::loncommon::bodytag('Grades Spreadsheet'). |
$r->print('</head>'.&Apache::loncommon::bodytag('Grades Spreadsheet'). |
'<form action="'.$r->uri.'" name=sheet method=post>'); |
'<form action="'.$r->uri.'" name=sheet method=post>'); |
$r->print(&hiddenfield('uname',$ENV{'form.uname'}). |
$r->print(&hiddenfield('uname',$ENV{'form.uname'}). |
Line 2540 ENDSCRIPT
|
Line 2548 ENDSCRIPT
|
&setfilename($asheet,$ENV{'form.ufn'}); |
&setfilename($asheet,$ENV{'form.ufn'}); |
&tmpread($asheet); |
&tmpread($asheet); |
} else { |
} else { |
&readsheet($asheet,$ENV{'form.ufn'}); |
&readsheet($asheet,$asheetdata,$ENV{'form.ufn'}); |
} |
} |
# Print out user information |
# Print out user information |
unless ($asheetdata->{'sheettype'} eq 'classcalc') { |
unless ($asheetdata->{'sheettype'} eq 'classcalc') { |
$r->print('<p><b>User:</b> '.$asheetdata->{'uname'}. |
$r->print('<p><b>User:</b> '.$asheetdata->{'uname'}. |
'<br><b>Domain:</b> '.$asheetdata->{'udom'}); |
'<br><b>Domain:</b> '.$asheetdata->{'udom'}); |
if (&getcsec($asheet) eq '-1') { |
# if (&getcsec($asheet) eq '-1') { |
$r->print('<h3><font color=red>'. |
# $r->print('<h3><font color=red>'. |
'Not a student in this course</font></h3>'); |
# 'Not a student in this course</font></h3>'); |
} else { |
# } else { |
$r->print('<br><b>Section/Group:</b> '.$asheetdata->{'csec'}); |
$r->print('<br><b>Section/Group:</b> '.$asheetdata->{'csec'}); |
} |
# } |
if ($ENV{'form.usymb'}) { |
if ($ENV{'form.usymb'}) { |
$r->print('<br><b>Assessment:</b> <tt>'. |
$r->print('<br><b>Assessment:</b> <tt>'. |
$ENV{'form.usymb'}.'</tt>'); |
$ENV{'form.usymb'}.'</tt>'); |
Line 2607 ENDSCRIPT
|
Line 2615 ENDSCRIPT
|
$r->print('>'.$_.'</option>'); |
$r->print('>'.$_.'</option>'); |
} |
} |
$r->print('</select><p>'); |
$r->print('</select><p>'); |
if (&gettype($asheet) eq 'studentcalc') { |
if ($asheetdata->{'sheettype'} eq 'studentcalc') { |
&setothersheets($asheet,&othersheets($asheet,'assesscalc')); |
&setothersheets($asheet,&othersheets($asheet,'assesscalc')); |
} |
} |
} |
} |