version 1.115, 2002/10/01 07:09:05
|
version 1.116, 2002/10/07 19:11:39
|
Line 1006 ENDDEFS
|
Line 1006 ENDDEFS
|
} |
} |
|
|
# ------------------------------------------------ Add or change formula values |
# ------------------------------------------------ Add or change formula values |
|
|
sub setformulas { |
sub setformulas { |
my ($safeeval,%f)=@_; |
my ($safeeval,%f)=@_; |
%{$safeeval->varglob('f')}=%f; |
%{$safeeval->varglob('f')}=%f; |
} |
} |
|
|
# ------------------------------------------------ Add or change formula values |
# ------------------------------------------------ Add or change formula values |
|
|
sub setconstants { |
sub setconstants { |
my ($safeeval,%c)=@_; |
my ($safeeval,%c)=@_; |
%{$safeeval->varglob('c')}=%c; |
%{$safeeval->varglob('c')}=%c; |
} |
} |
|
|
# --------------------------------------------- Set names of other spreadsheets |
# --------------------------------------------- Set names of other spreadsheets |
|
|
sub setothersheets { |
sub setothersheets { |
my ($safeeval,@os)=@_; |
my ($safeeval,@os)=@_; |
@{$safeeval->varglob('os')}=@os; |
@{$safeeval->varglob('os')}=@os; |
} |
} |
|
|
# ------------------------------------------------ Add or change formula values |
# ------------------------------------------------ Add or change formula values |
|
|
sub setrowlabels { |
sub setrowlabels { |
my ($safeeval,%rowlabel)=@_; |
my ($safeeval,%rowlabel)=@_; |
%{$safeeval->varglob('rowlabel')}=%rowlabel; |
%{$safeeval->varglob('rowlabel')}=%rowlabel; |
} |
} |
|
|
# ------------------------------------------------------- Calculate spreadsheet |
# ------------------------------------------------------- Calculate spreadsheet |
|
|
sub calcsheet { |
sub calcsheet { |
my $safeeval=shift; |
my $safeeval=shift; |
return $safeeval->reval('&calc();'); |
return $safeeval->reval('&calc();'); |
} |
} |
|
|
# ------------------------------------------------------------------ Get values |
|
|
|
sub getvalues { |
|
my $safeeval=shift; |
|
return $safeeval->reval('%sheet_values'); |
|
} |
|
|
|
# ---------------------------------------------------------------- Get formulas |
# ---------------------------------------------------------------- Get formulas |
|
|
sub getformulas { |
sub getformulas { |
my $safeeval=shift; |
my $safeeval=shift; |
return %{$safeeval->varglob('f')}; |
return %{$safeeval->varglob('f')}; |
} |
} |
|
|
# ----------------------------------------------------- Get value of $f{'A'.$n} |
# ----------------------------------------------------- Get value of $f{'A'.$n} |
|
|
sub getfa { |
sub getfa { |
my ($safeeval,$n)=@_; |
my ($safeeval,$n)=@_; |
return $safeeval->reval('$f{"A'.$n.'"}'); |
return $safeeval->reval('$f{"A'.$n.'"}'); |
} |
} |
|
|
# -------------------------------------------------------------------- Get type |
|
|
|
sub gettype { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$sheettype'); |
|
} |
|
|
|
# ------------------------------------------------------------------ Set maxrow |
|
|
|
sub setmaxrow { |
|
my ($safeeval,$row)=@_; |
|
$safeeval->reval('$maxrow='.$row.';'); |
|
} |
|
|
|
# ------------------------------------------------------------------ Get maxrow |
|
|
|
sub getmaxrow { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$maxrow'); |
|
} |
|
|
|
# ---------------------------------------------------------------- Set filename |
|
|
|
sub setfilename { |
|
my ($safeeval,$fn)=@_; |
|
$safeeval->reval('$filename="'.$fn.'";'); |
|
} |
|
|
|
# ---------------------------------------------------------------- Get filename |
|
|
|
sub getfilename { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$filename'); |
|
} |
|
|
|
# --------------------------------------------------------------- Get course ID |
|
|
|
sub getcid { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$cid'); |
|
} |
|
|
|
# --------------------------------------------------------- Get course filename |
|
|
|
sub getcoursefilename { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$coursefilename'); |
|
} |
|
|
|
# ----------------------------------------------------------- Get course number |
|
|
|
sub getcnum { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$cnum'); |
|
} |
|
|
|
# ------------------------------------------------------------- Get course home |
|
|
|
sub getchome { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$chome'); |
|
} |
|
|
|
# ----------------------------------------------------------- Get course domain |
|
|
|
sub getcdom { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$cdom'); |
|
} |
|
|
|
# ---------------------------------------------------------- Get course section |
|
|
|
sub getcsec { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$csec'); |
|
} |
|
|
|
# --------------------------------------------------------------- Get user name |
|
|
|
sub getuname { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$uname'); |
|
} |
|
|
|
# ------------------------------------------------------------- Get user domain |
|
|
|
sub getudom { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$udom'); |
|
} |
|
|
|
# --------------------------------------------------------------- Get user home |
|
|
|
sub getuhome { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$uhome'); |
|
} |
|
|
|
# -------------------------------------------------------------------- Get symb |
|
|
|
sub getusymb { |
|
my $safeeval=shift; |
|
return $safeeval->reval('$usymb'); |
|
} |
|
|
|
# ------------------------------------------------------------- Export of A-row |
# ------------------------------------------------------------- Export of A-row |
|
|
sub exportdata { |
sub exportdata { |
my $safeeval=shift; |
my $safeeval=shift; |
return $safeeval->reval('&exportrowa()'); |
return $safeeval->reval('&exportrowa()'); |
Line 1183 sub exportdata {
|
Line 1063 sub exportdata {
|
# --------------------------------------------- Produce output row n from sheet |
# --------------------------------------------- Produce output row n from sheet |
|
|
sub rown { |
sub rown { |
my ($safeeval,$n)=@_; |
my ($safeeval,$n,$sheetdata)=@_; |
my $defaultbg; |
my $defaultbg; |
my $rowdata=''; |
my $rowdata=''; |
my $dataflag=0; |
my $dataflag=0; |
Line 1200 sub rown {
|
Line 1080 sub rown {
|
my $showf=0; |
my $showf=0; |
my $proc; |
my $proc; |
my $maxred=1; |
my $maxred=1; |
my $sheettype=&gettype($safeeval); |
my $sheettype=$sheetdata->{'sheettype'}; |
if ($sheettype eq 'studentcalc') { |
if ($sheettype eq 'studentcalc') { |
$proc='&outrowassess'; |
$proc='&outrowassess'; |
$maxred=26; |
$maxred=26; |
Line 1296 sub outsheet {
|
Line 1176 sub outsheet {
|
} |
} |
$tabledata.="<b><font size=+1>$_</font></b></td>"; |
$tabledata.="<b><font size=+1>$_</font></b></td>"; |
} |
} |
$tabledata.='</tr>'.&rown($safeeval,'-').&rown($safeeval,0); |
$tabledata.='</tr>'.&rown($safeeval,'-',$sheetdata). |
|
&rown($safeeval,0,$sheetdata); |
} |
} |
$r->print($tabledata); |
$r->print($tabledata); |
# |
# |
# Prepare to output rows |
# Prepare to output rows |
my $row; |
my $row; |
my $maxrow=&getmaxrow($safeeval); |
my $maxrow=$sheetdata->{'maxrow'}; |
# |
# |
my @sortby=(); |
my @sortby=(); |
my @sortidx=(); |
my @sortidx=(); |
Line 1323 sub outsheet {
|
Line 1204 sub outsheet {
|
# Loop through the rows and output them one at a time |
# Loop through the rows and output them one at a time |
my $n=0; |
my $n=0; |
for ($row=0;$row<$maxrow;$row++) { |
for ($row=0;$row<$maxrow;$row++) { |
my $thisrow=&rown($safeeval,$sortidx[$row]+1); |
my $thisrow=&rown($safeeval,$sortidx[$row]+1,$sheetdata); |
if ($thisrow) { |
if ($thisrow) { |
if (($n/25==int($n/25)) && (!$ENV{'form.showcsv'})) { |
if (($n/25==int($n/25)) && (!$ENV{'form.showcsv'})) { |
$r->print("</table>\n<br>\n"); |
$r->print("</table>\n<br>\n"); |
Line 1346 sub outsheet {
|
Line 1227 sub outsheet {
|
# ----------------------------------------------- Read list of available sheets |
# ----------------------------------------------- Read list of available sheets |
# |
# |
sub othersheets { |
sub othersheets { |
my ($safeeval,$stype)=@_; |
my ($safeeval,$stype,$sheetdata)=@_; |
# |
# |
my $cnum = &getcnum($safeeval); |
my $cnum = $sheetdata->{'cnum'}; |
my $cdom = &getcdom($safeeval); |
my $cdom = $sheetdata->{'cdom'}; |
my $chome = &getchome($safeeval); |
my $chome = $sheetdata->{'chome'}; |
# |
# |
my @alternatives=(); |
my @alternatives=(); |
my %results=&Apache::lonnet::dump($stype.'_spreadsheets',$cdom,$cnum); |
my %results=&Apache::lonnet::dump($stype.'_spreadsheets',$cdom,$cnum); |
Line 1420 sub readsheet {
|
Line 1301 sub readsheet {
|
} |
} |
} |
} |
# $fn now has a value |
# $fn now has a value |
&setfilename($safeeval,$fn); |
$sheetdata->{'filename'} = $fn; |
# see if sheet is cached |
# see if sheet is cached |
my $fstring=''; |
my $fstring=''; |
if ($fstring=$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}) { |
if ($fstring=$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}) { |
Line 1480 sub makenewsheet {
|
Line 1361 sub makenewsheet {
|
$sheetdata{'uhome'} = &Apache::lonnet::homeserver($uname,$udom); |
$sheetdata{'uhome'} = &Apache::lonnet::homeserver($uname,$udom); |
|
|
my $safeeval=initsheet($stype); |
my $safeeval=initsheet($stype); |
|
# |
|
# Place all the %sheetdata items into the safe space |
my $initstring = ''; |
my $initstring = ''; |
foreach (keys(%sheetdata)) { |
foreach (keys(%sheetdata)) { |
$initstring.= qq{\$$_="$sheetdata{$_}";}; |
$initstring.= qq{\$$_="$sheetdata{$_}";}; |
Line 1490 sub makenewsheet {
|
Line 1373 sub makenewsheet {
|
|
|
# ------------------------------------------------------------ Save spreadsheet |
# ------------------------------------------------------------ Save spreadsheet |
sub writesheet { |
sub writesheet { |
my ($safeeval,$makedef)=@_; |
my ($safeeval,$makedef,$sheetdata)=@_; |
my $cid=&getcid($safeeval); |
my $cid=$sheetdata->{'cid'}; |
if (&Apache::lonnet::allowed('opa',$cid)) { |
if (&Apache::lonnet::allowed('opa',$cid)) { |
my %f=&getformulas($safeeval); |
my %f=&getformulas($safeeval); |
my $stype=&gettype($safeeval); |
my $stype= $sheetdata->{'sheettype'}; |
my $cnum=&getcnum($safeeval); |
my $cnum = $sheetdata->{'cnum'}; |
my $cdom=&getcdom($safeeval); |
my $cdom = $sheetdata->{'cdom'}; |
my $chome=&getchome($safeeval); |
my $chome= $sheetdata->{'chome'}; |
my $fn=&getfilename($safeeval); |
my $fn = $sheetdata->{'filename'}; |
# Cache new sheet |
# Cache new sheet |
$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}=join('___;___',%f); |
$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}=join('___;___',%f); |
# Write sheet |
# Write sheet |
Line 1541 sub writesheet {
|
Line 1424 sub writesheet {
|
# "Modified workcopy" - interactive only |
# "Modified workcopy" - interactive only |
# |
# |
sub tmpwrite { |
sub tmpwrite { |
my $safeeval=shift; |
my ($safeeval,$sheetdata) = @_; |
my $fn=$ENV{'user.name'}.'_'. |
my $fn=$ENV{'user.name'}.'_'. |
$ENV{'user.domain'}.'_spreadsheet_'.&getusymb($safeeval).'_'. |
$ENV{'user.domain'}.'_spreadsheet_'.$sheetdata->{'usymb'}.'_'. |
&getfilename($safeeval); |
$sheetdata->{'filename'}; |
$fn=~s/\W/\_/g; |
$fn=~s/\W/\_/g; |
$fn=$tmpdir.$fn.'.tmp'; |
$fn=$tmpdir.$fn.'.tmp'; |
my $fh; |
my $fh; |
Line 1555 sub tmpwrite {
|
Line 1438 sub tmpwrite {
|
|
|
# ---------------------------------------------------------- Read the temp copy |
# ---------------------------------------------------------- Read the temp copy |
sub tmpread { |
sub tmpread { |
my ($safeeval,$nfield,$nform)=@_; |
my ($safeeval,$sheetdata,$nfield,$nform)=@_; |
my $fn=$ENV{'user.name'}.'_'. |
my $fn=$ENV{'user.name'}.'_'. |
$ENV{'user.domain'}.'_spreadsheet_'.&getusymb($safeeval).'_'. |
$ENV{'user.domain'}.'_spreadsheet_'.$sheetdata->{'usymb'}.'_'. |
&getfilename($safeeval); |
$sheetdata->{'filename'}; |
$fn=~s/\W/\_/g; |
$fn=~s/\W/\_/g; |
$fn=$tmpdir.$fn.'.tmp'; |
$fn=$tmpdir.$fn.'.tmp'; |
my $fh; |
my $fh; |
Line 1776 sub updateclasssheet {
|
Line 1659 sub updateclasssheet {
|
} |
} |
if ($changed) { &setformulas($safeeval,%f); } |
if ($changed) { &setformulas($safeeval,%f); } |
# |
# |
&setmaxrow($safeeval,$maxrow); |
$sheetdata->{'maxrow'} = $maxrow; |
&setrowlabels($safeeval,%currentlist); |
&setrowlabels($safeeval,%currentlist); |
} |
} |
|
|
Line 1897 sub updatestudentassesssheet {
|
Line 1780 sub updatestudentassesssheet {
|
} |
} |
} |
} |
if ($changed) { &setformulas($safeeval,%f); } |
if ($changed) { &setformulas($safeeval,%f); } |
&setmaxrow($safeeval,$maxrow); |
$sheetdata->{'maxrow'} = $maxrow; |
&setrowlabels($safeeval,%current); |
&setrowlabels($safeeval,%current); |
# |
# |
undef %current; |
undef %current; |
Line 2062 sub loadassessment {
|
Line 1945 sub loadassessment {
|
# This is dumb. It is also necessary :( |
# This is dumb. It is also necessary :( |
my @oldkeys=keys %returnhash; |
my @oldkeys=keys %returnhash; |
# |
# |
foreach (@oldkeys) { |
foreach my $name (@oldkeys) { |
my $name=$_; |
my $value=$returnhash{$name}; |
my $value=$returnhash{$_}; |
delete $returnhash{$name}; |
delete $returnhash{$_}; |
|
$name=~s/\_/\./g; |
$name=~s/\_/\./g; |
$returnhash{$name}=$value; |
$returnhash{$name}=$value; |
} |
} |
Line 2074 sub loadassessment {
|
Line 1956 sub loadassessment {
|
undef %useropt; |
undef %useropt; |
|
|
my $userprefix=$uname.'_'.$udom.'_'; |
my $userprefix=$uname.'_'.$udom.'_'; |
|
|
unless ($uhome eq 'no_host') { |
unless ($uhome eq 'no_host') { |
# Get coursedata |
# Get coursedata |
unless ((time-$courserdatas{$cid.'.last_cache'})<240) { |
unless ((time-$courserdatas{$cid.'.last_cache'})<240) { |
my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum. |
my %Tmp = &Apache::lonnet::dump('resourcedata',$cdom,$cnum); |
':resourcedata',$chome); |
$courserdatas{$cid}=\%Tmp; |
if ($reply!~/^error\:/) { |
$courserdatas{$cid.'.last_cache'}=time; |
$courserdatas{$cid}=$reply; |
|
$courserdatas{$cid.'.last_cache'}=time; |
|
} |
|
} |
} |
foreach (split(/\&/,$courserdatas{$cid})) { |
while (my ($name,$value) = each(%{$courserdatas{$cid}})) { |
my ($name,$value)=split(/\=/,$_); |
$courseopt{$userprefix.$name}=$value; |
$courseopt{$userprefix.&Apache::lonnet::unescape($name)}= |
|
&Apache::lonnet::unescape($value); |
|
} |
} |
# Get userdata (if present) |
# Get userdata (if present) |
unless ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) { |
unless ((time-$userrdatas{$uname.'@'.$udom.'.last_cache'})<240) { |
my $reply= |
my %Tmp = &Apache::lonnet::dump('resourcedata',$udom,$uname); |
&Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome); |
$userrdatas{$cid} = \%Tmp; |
if ($reply!~/^error\:/) { |
|
$userrdatas{$uname.'___'.$udom}=$reply; |
|
} |
|
# Most of the time the user does not have a 'resourcedata.db' |
# Most of the time the user does not have a 'resourcedata.db' |
# file. We need to cache that we got nothing instead of bothering |
# file. We need to cache that we got nothing instead of bothering |
# with requesting it every time. |
# with requesting it every time. |
$userrdatas{$uname.'___'.$udom.'.last_cache'}=time; |
$userrdatas{$uname.'@'.$udom.'.last_cache'}=time; |
} |
} |
foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) { |
while (my ($name,$value) = each(%{$userrdatas{$cid}})) { |
my ($name,$value)=split(/\=/,$_); |
$useropt{$userprefix.$name}=$value; |
$useropt{$userprefix.&Apache::lonnet::unescape($name)}= |
|
&Apache::lonnet::unescape($value); |
|
} |
} |
} |
} |
# now courseopt, useropt initialized for this user and course |
# now courseopt, useropt initialized for this user and course |
Line 2123 sub loadassessment {
|
Line 1995 sub loadassessment {
|
# |
# |
my %c=(); |
my %c=(); |
if (tie(%parmhash,'GDBM_File', |
if (tie(%parmhash,'GDBM_File', |
&getcoursefilename($safeeval).'_parms.db',&GDBM_READER(),0640)) { |
$sheetdata->{'coursefilename'}.'_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 2292 sub exportsheet {
|
Line 2164 sub exportsheet {
|
&readsheet($thissheet,$sheetdata,$fn); |
&readsheet($thissheet,$sheetdata,$fn); |
&updatesheet($thissheet,$sheetdata); |
&updatesheet($thissheet,$sheetdata); |
&loadrows($thissheet,$sheetdata); |
&loadrows($thissheet,$sheetdata); |
&calcsheet($thissheet,$sheetdata); |
&calcsheet($thissheet); |
@exportarr=&exportdata($thissheet,$sheetdata); |
@exportarr=&exportdata($thissheet); |
# |
# |
# Store now |
# Store now |
# |
# |
Line 2432 sub cachedssheets {
|
Line 2304 sub cachedssheets {
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
|
|
|
# Check this server |
my $loaderror=&Apache::lonnet::overloaderror($r); |
my $loaderror=&Apache::lonnet::overloaderror($r); |
if ($loaderror) { return $loaderror; } |
if ($loaderror) { return $loaderror; } |
|
# Check the course homeserver |
$loaderror= &Apache::lonnet::overloaderror($r, |
$loaderror= &Apache::lonnet::overloaderror($r, |
$ENV{'course.'.$ENV{'request.course.id'}.'.home'}); |
$ENV{'course.'.$ENV{'request.course.id'}.'.home'}); |
if ($loaderror) { return $loaderror; } |
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 2534 ENDSCRIPT
|
Line 2408 ENDSCRIPT
|
} |
} |
# Read new sheet or modified worksheet |
# Read new sheet or modified worksheet |
$r->uri=~/\/(\w+)$/; |
$r->uri=~/\/(\w+)$/; |
my ($asheet,$asheetdata)=&makenewsheet($aname,$adom,$1,$ENV{'form.usymb'}); |
my ($sheet,$sheetdata)=&makenewsheet($aname,$adom,$1,$ENV{'form.usymb'}); |
# |
# |
# If a new formula had been entered, go from work copy |
# If a new formula had been entered, go from work copy |
if ($ENV{'form.unewfield'}) { |
if ($ENV{'form.unewfield'}) { |
Line 2542 ENDSCRIPT
|
Line 2416 ENDSCRIPT
|
$ENV{'form.unewformula'}=~s/\'/\"/g; |
$ENV{'form.unewformula'}=~s/\'/\"/g; |
$r->print('<p>New formula: '.$ENV{'form.unewfield'}.'='. |
$r->print('<p>New formula: '.$ENV{'form.unewfield'}.'='. |
$ENV{'form.unewformula'}.'<p>'); |
$ENV{'form.unewformula'}.'<p>'); |
&setfilename($asheet,$ENV{'form.ufn'}); |
$sheetdata->{'filename'} = $ENV{'form.ufn'}; |
&tmpread($asheet,$ENV{'form.unewfield'},$ENV{'form.unewformula'}); |
&tmpread($sheet,$sheetdata, |
|
$ENV{'form.unewfield'},$ENV{'form.unewformula'}); |
} elsif ($ENV{'form.saveas'}) { |
} elsif ($ENV{'form.saveas'}) { |
&setfilename($asheet,$ENV{'form.ufn'}); |
$sheetdata->{'filename'} = $ENV{'form.ufn'}; |
&tmpread($asheet); |
&tmpread($sheet,$sheetdata); |
} else { |
} else { |
&readsheet($asheet,$asheetdata,$ENV{'form.ufn'}); |
&readsheet($sheet,$sheetdata,$ENV{'form.ufn'}); |
} |
} |
# Print out user information |
# Print out user information |
unless ($asheetdata->{'sheettype'} eq 'classcalc') { |
unless ($sheetdata->{'sheettype'} eq 'classcalc') { |
$r->print('<p><b>User:</b> '.$asheetdata->{'uname'}. |
$r->print('<p><b>User:</b> '.$sheetdata->{'uname'}. |
'<br><b>Domain:</b> '.$asheetdata->{'udom'}); |
'<br><b>Domain:</b> '.$sheetdata->{'udom'}); |
# if (&getcsec($asheet) eq '-1') { |
$r->print('<br><b>Section/Group:</b> '.$sheetdata->{'csec'}); |
# $r->print('<h3><font color=red>'. |
|
# 'Not a student in this course</font></h3>'); |
|
# } else { |
|
$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 2567 ENDSCRIPT
|
Line 2437 ENDSCRIPT
|
} |
} |
# |
# |
# Check user permissions |
# Check user permissions |
if (($asheetdata->{'sheettype'} eq 'classcalc' ) || |
if (($sheetdata->{'sheettype'} eq 'classcalc' ) || |
($asheetdata->{'uname'} ne $ENV{'user.name'} ) || |
($sheetdata->{'uname'} ne $ENV{'user.name'} ) || |
($asheetdata->{'udom'} ne $ENV{'user.domain'})) { |
($sheetdata->{'udom'} ne $ENV{'user.domain'})) { |
unless (&Apache::lonnet::allowed('vgr',$asheetdata->{'cid'})) { |
unless (&Apache::lonnet::allowed('vgr',$sheetdata->{'cid'})) { |
$r->print('<h1>Access Permission Denied</h1>'. |
$r->print('<h1>Access Permission Denied</h1>'. |
'</form></body></html>'); |
'</form></body></html>'); |
return OK; |
return OK; |
Line 2580 ENDSCRIPT
|
Line 2450 ENDSCRIPT
|
$r->print('<br />'. |
$r->print('<br />'. |
'<input type="submit" name="forcerecalc" '. |
'<input type="submit" name="forcerecalc" '. |
'value="Completely Recalculate Sheet"><p>'); |
'value="Completely Recalculate Sheet"><p>'); |
if ($asheetdata->{'sheettype'} eq 'assesscalc') { |
if ($sheetdata->{'sheettype'} eq 'assesscalc') { |
$r->print('<p><font size=+2>'. |
$r->print('<p><font size=+2>'. |
'<a href="/adm/studentcalc?'. |
'<a href="/adm/studentcalc?'. |
'uname='.$asheetdata->{'uname'}. |
'uname='.$sheetdata->{'uname'}. |
'&udom='.$asheetdata->{'udom'}.'">'. |
'&udom='.$sheetdata->{'udom'}.'">'. |
'Level up: Student Sheet</a></font><p>'); |
'Level up: Student Sheet</a></font><p>'); |
} |
} |
if (($asheetdata->{'sheettype'} eq 'studentcalc') && |
if (($sheetdata->{'sheettype'} eq 'studentcalc') && |
(&Apache::lonnet::allowed('vgr',$asheetdata->{'cid'}))) { |
(&Apache::lonnet::allowed('vgr',$sheetdata->{'cid'}))) { |
$r->print ('<p><font size=+2><a href="/adm/classcalc">'. |
$r->print ('<p><font size=+2><a href="/adm/classcalc">'. |
'Level up: Course Sheet</a></font><p>'); |
'Level up: Course Sheet</a></font><p>'); |
} |
} |
Line 2601 ENDSCRIPT
|
Line 2471 ENDSCRIPT
|
'<input type=text size=20 name=newfn value="'.$fname.'">'. |
'<input type=text size=20 name=newfn value="'.$fname.'">'. |
'make default: <input type=checkbox name="makedefufn"><p>'); |
'make default: <input type=checkbox name="makedefufn"><p>'); |
} |
} |
$r->print(&hiddenfield('ufn',&getfilename($asheet))); |
$r->print(&hiddenfield('ufn',$sheetdata->{'filename'})); |
# Load dialog |
# Load dialog |
if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) { |
if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) { |
$r->print('<p><input type=submit name=load value="Load ...">'. |
$r->print('<p><input type=submit name=load value="Load ...">'. |
'<select name="loadthissheet">'. |
'<select name="loadthissheet">'. |
'<option name="default">Default</option>'); |
'<option name="default">Default</option>'); |
foreach (&othersheets($asheet,$asheetdata->{'sheettype'})) { |
foreach (&othersheets($sheet,$sheetdata->{'sheettype'},$sheetdata)) { |
$r->print('<option name="'.$_.'"'); |
$r->print('<option name="'.$_.'"'); |
if ($ENV{'form.ufn'} eq $_) { |
if ($ENV{'form.ufn'} eq $_) { |
$r->print(' selected'); |
$r->print(' selected'); |
Line 2615 ENDSCRIPT
|
Line 2485 ENDSCRIPT
|
$r->print('>'.$_.'</option>'); |
$r->print('>'.$_.'</option>'); |
} |
} |
$r->print('</select><p>'); |
$r->print('</select><p>'); |
if ($asheetdata->{'sheettype'} eq 'studentcalc') { |
if ($sheetdata->{'sheettype'} eq 'studentcalc') { |
&setothersheets($asheet,&othersheets($asheet,'assesscalc')); |
&setothersheets($sheet, |
|
&othersheets($sheet,'assesscalc',$sheetdata)); |
} |
} |
} |
} |
# Cached sheets |
# Cached sheets |
&expirationdates(); |
&expirationdates(); |
undef %oldsheets; |
undef %oldsheets; |
undef %loadedcaches; |
undef %loadedcaches; |
if ($asheetdata->{'sheettype'} eq 'classcalc') { |
if ($sheetdata->{'sheettype'} eq 'classcalc') { |
$r->print("Loading previously calculated student sheets ...\n"); |
$r->print("Loading previously calculated student sheets ...\n"); |
$r->rflush(); |
$r->rflush(); |
&cachedcsheets(); |
&cachedcsheets(); |
} elsif ($asheetdata->{'sheettype'} eq 'studentcalc') { |
} elsif ($sheetdata->{'sheettype'} eq 'studentcalc') { |
$r->print("Loading previously calculated assessment sheets ...\n"); |
$r->print("Loading previously calculated assessment sheets ...\n"); |
$r->rflush(); |
$r->rflush(); |
&cachedssheets($asheetdata->{'uname'},$asheetdata->{'udom'}, |
&cachedssheets($sheetdata->{'uname'},$sheetdata->{'udom'}, |
$asheetdata->{'uhome'}); |
$sheetdata->{'uhome'}); |
} |
} |
# Update sheet, load rows |
# Update sheet, load rows |
$r->print("Loaded sheet(s), updating rows ...<br>\n"); |
$r->print("Loaded sheet(s), updating rows ...<br>\n"); |
$r->rflush(); |
$r->rflush(); |
# |
# |
&updatesheet($asheet,$asheetdata); |
&updatesheet($sheet,$sheetdata); |
$r->print("Updated rows, loading row data ...\n"); |
$r->print("Updated rows, loading row data ...\n"); |
$r->rflush(); |
$r->rflush(); |
# |
# |
&loadrows($asheet,$asheetdata,$r); |
&loadrows($sheet,$sheetdata,$r); |
$r->print("Loaded row data, calculating sheet ...<br>\n"); |
$r->print("Loaded row data, calculating sheet ...<br>\n"); |
$r->rflush(); |
$r->rflush(); |
# |
# |
my $calcoutput=&calcsheet($asheet); |
my $calcoutput=&calcsheet($sheet); |
$r->print('<h3><font color=red>'.$calcoutput.'</h3></font>'); |
$r->print('<h3><font color=red>'.$calcoutput.'</h3></font>'); |
# See if something to save |
# See if something to save |
if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) { |
if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) { |
Line 2653 ENDSCRIPT
|
Line 2524 ENDSCRIPT
|
if ($ENV{'form.saveas'} && ($fname=$ENV{'form.newfn'})) { |
if ($ENV{'form.saveas'} && ($fname=$ENV{'form.newfn'})) { |
$fname=~s/\W/\_/g; |
$fname=~s/\W/\_/g; |
if ($fname eq 'default') { $fname='course_default'; } |
if ($fname eq 'default') { $fname='course_default'; } |
$fname.='_'.$asheetdata->{'sheettype'}; |
$fname.='_'.$sheetdata->{'sheettype'}; |
&setfilename($asheet,$fname); |
$sheetdata->{'filename'}->$fname; |
$ENV{'form.ufn'}=$fname; |
$ENV{'form.ufn'}=$fname; |
$r->print('<p>Saving spreadsheet: '. |
$r->print('<p>Saving spreadsheet: '. |
&writesheet($asheet,$ENV{'form.makedefufn'}).'<p>'); |
&writesheet($sheet,$ENV{'form.makedefufn'},$sheetdata). |
|
'<p>'); |
} |
} |
} |
} |
# |
# |
#Write the modified worksheet |
# Write the modified worksheet |
$r->print('<b>Current sheet:</b> '.&getfilename($asheet).'<p>'); |
$r->print('<b>Current sheet:</b> '.$sheetdata->{'filename'}.'<p>'); |
&tmpwrite($asheet); |
&tmpwrite($sheet,$sheetdata); |
if ($asheetdata->{'sheettype'} eq 'studentcalc') { |
if ($sheetdata->{'sheettype'} eq 'studentcalc') { |
$r->print('<br>Show rows with empty A column: '); |
$r->print('<br>Show rows with empty A column: '); |
} else { |
} else { |
$r->print('<br>Show empty rows: '); |
$r->print('<br>Show empty rows: '); |
Line 2687 ENDSCRIPT
|
Line 2559 ENDSCRIPT
|
$r->print('>'); |
$r->print('>'); |
# |
# |
# CSV format checkbox (classcalc sheets only) |
# CSV format checkbox (classcalc sheets only) |
if ($asheetdata->{'sheettype'} eq 'classcalc') { |
if ($sheetdata->{'sheettype'} eq 'classcalc') { |
$r->print(' Output CSV format: <input type="checkbox" '. |
$r->print(' Output CSV format: <input type="checkbox" '. |
'name="showcsv" onClick="submit()"'); |
'name="showcsv" onClick="submit()"'); |
if ($ENV{'form.showcsv'}) { $r->print(' checked'); } |
if ($ENV{'form.showcsv'}) { $r->print(' checked'); } |
Line 2706 value='Insert Row Top'>
|
Line 2578 value='Insert Row Top'>
|
value='Insert Row Bottom'><br> |
value='Insert Row Bottom'><br> |
ENDINSERTBUTTONS |
ENDINSERTBUTTONS |
# Print out sheet |
# Print out sheet |
&outsheet($r,$asheet,$asheetdata); |
&outsheet($r,$sheet,$sheetdata); |
$r->print('</form></body></html>'); |
$r->print('</form></body></html>'); |
# Done |
# Done |
return OK; |
return OK; |