version 1.119, 2002/10/21 17:59:36
|
version 1.120, 2002/10/22 13:09:49
|
Line 951 sub calc {
|
Line 951 sub calc {
|
# |
# |
sub outrowassess { |
sub outrowassess { |
# $n is the current row number |
# $n is the current row number |
my $n=shift; |
my $n=shift; |
|
my $csv = shift; |
my @cols=(); |
my @cols=(); |
if ($n) { |
if ($n) { |
my ($usy,$ufn)=split(/__&&&\__/,$f{'A'.$n}); |
my ($usy,$ufn)=split(/__&&&\__/,$f{'A'.$n}); |
if ($rowlabel{$usy}) { |
if ($rowlabel{$usy}) { |
$cols[0]=$rowlabel{$usy}.'<br>'. |
$cols[0]=$rowlabel{$usy}; |
|
if (! $csv) { |
|
$cols[0].='<br>'. |
'<select name="sel_'.$n.'" onChange="changesheet('.$n.')">'. |
'<select name="sel_'.$n.'" onChange="changesheet('.$n.')">'. |
'<option name="default">Default</option>'; |
'<option name="default">Default</option>'; |
|
} |
} else { |
} else { |
$cols[0]=''; |
$cols[0]=''; |
} |
} |
foreach (@os) { |
if (! $csv) { |
$cols[0].='<option name="'.$_.'"'; |
foreach (@os) { |
if ($ufn eq $_) { |
$cols[0].='<option name="'.$_.'"'; |
$cols[0].=' selected'; |
if ($ufn eq $_) { |
|
$cols[0].=' selected'; |
|
} |
|
$cols[0].='>'.$_.'</option>'; |
} |
} |
$cols[0].='>'.$_.'</option>'; |
$cols[0].='</select>'; |
} |
} |
$cols[0].='</select>'; |
|
} else { |
} else { |
$cols[0]='<b><font size=+1>Export</font></b>'; |
$cols[0]='<b><font size=+1>Export</font></b>'; |
} |
} |
Line 1064 sub setrowlabels {
|
Line 1070 sub setrowlabels {
|
# ------------------------------------------------------- Calculate spreadsheet |
# ------------------------------------------------------- Calculate spreadsheet |
sub calcsheet { |
sub calcsheet { |
my $sheet=shift; |
my $sheet=shift; |
return $sheet->{'safe'}->reval('&calc();'); |
my $result = $sheet->{'safe'}->reval('&calc();'); |
|
%{$sheet->{'values'}} = %{$sheet->{'safe'}->varglob('sheet_values')}; |
|
return $result; |
} |
} |
|
|
# ---------------------------------------------------------------- Get formulas |
# ---------------------------------------------------------------- Get formulas |
Line 1131 sub rown {
|
Line 1139 sub rown {
|
$n=-1; |
$n=-1; |
$dataflag=1; |
$dataflag=1; |
} |
} |
foreach ($sheet->{'safe'}->reval($proc.'('.$n.')')) { |
foreach ($sheet->{'safe'}->reval($proc.'('.$n.','.$ENV{'form.showcsv'}.')')) { |
my $bgcolor=$defaultbg.((($showf-1)/5==int(($showf-1)/5))?'99':'DD'); |
my $bgcolor=$defaultbg.((($showf-1)/5==int(($showf-1)/5))?'99':'DD'); |
my ($fm,$vl)=split(/\_\_\_eq\_\_\_/,$_); |
my ($fm,$vl)=split(/\_\_\_eq\_\_\_/,$_); |
if ((($vl ne '') || ($vl eq '0')) && |
if ((($vl ne '') || ($vl eq '0')) && |
Line 1653 sub updateclasssheet {
|
Line 1661 sub updateclasssheet {
|
} |
} |
$existing{$f{$_}}=1; |
$existing{$f{$_}}=1; |
unless ((defined($currentlist{$f{$_}})) || (!$1) || |
unless ((defined($currentlist{$f{$_}})) || (!$1) || |
($f{$_}=~/^(\~\~\~|\-\-\-)/)) { |
($f{$_}=~/^(~~~|---)/)) { |
$f{$_}='!!! Obsolete'; |
$f{$_}='!!! Obsolete'; |
$changed=1; |
$changed=1; |
} |
} |
Line 1710 sub updatestudentassesssheet {
|
Line 1718 sub updatestudentassesssheet {
|
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})){ |
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})){ |
$adduserstr='&uname='.$uname.'&udom='.$udom; |
$adduserstr='&uname='.$uname.'&udom='.$udom; |
} |
} |
my %allassess = |
my %allassess; |
('_feedback' =>'<a href="/adm/assesscalc?usymb=_feedback'. |
if (! $ENV{'form.showcsv'}) { |
$adduserstr.'">Feedback</a>', |
%allassess = |
'_evaluation' =>'<a href="/adm/assesscalc?usymb=_evaluation'. |
('_feedback' =>'<a href="/adm/assesscalc?usymb=_feedback'. |
$adduserstr.'">Evaluation</a>', |
$adduserstr.'">Feedback</a>', |
'_tutoring' =>'<a href="/adm/assesscalc?usymb=_tutoring'. |
'_evaluation' =>'<a href="/adm/assesscalc?usymb=_evaluation'. |
$adduserstr.'">Tutoring</a>', |
$adduserstr.'">Evaluation</a>', |
'_discussion' =>'<a href="/adm/assesscalc?usymb=_discussion'. |
'_tutoring' =>'<a href="/adm/assesscalc?usymb=_tutoring'. |
$adduserstr.'">Discussion</a>' |
$adduserstr.'">Tutoring</a>', |
); |
'_discussion' =>'<a href="/adm/assesscalc?usymb=_discussion'. |
|
$adduserstr.'">Discussion</a>' |
|
); |
|
} else { |
|
%allassess = |
|
('_feedback' => "Feedback", |
|
'_evaluation' => "Evaluation", |
|
'_tutoring' => "Tutoring", |
|
'_discussion' => "Discussion", |
|
); |
|
} |
while (($_,undef) = each(%bighash)) { |
while (($_,undef) = each(%bighash)) { |
next if ($_!~/^src\_(\d+)\.(\d+)$/); |
next if ($_!~/^src\_(\d+)\.(\d+)$/); |
my $mapid=$1; |
my $mapid=$1; |
Line 1730 sub updatestudentassesssheet {
|
Line 1748 sub updatestudentassesssheet {
|
my $symb= |
my $symb= |
&Apache::lonnet::declutter($bighash{'map_id_'.$mapid}). |
&Apache::lonnet::declutter($bighash{'map_id_'.$mapid}). |
'___'.$resid.'___'.&Apache::lonnet::declutter($srcf); |
'___'.$resid.'___'.&Apache::lonnet::declutter($srcf); |
$allassess{$symb}= |
if (! $ENV{'form.showcsv'}) { |
'<a href="/adm/assesscalc?usymb='.$symb.$adduserstr.'">'. |
$allassess{$symb}= |
$bighash{'title_'.$id}.'</a>'; |
'<a href="/adm/assesscalc?usymb='.$symb.$adduserstr.'">'. |
|
$bighash{'title_'.$id}.'</a>'; |
|
} else { |
|
$allassess{$symb}=$bighash{'title_'.$id}; |
|
} |
next if ($stype ne 'assesscalc'); |
next if ($stype ne 'assesscalc'); |
foreach my $key (split(/\,/, |
foreach my $key (split(/\,/, |
&Apache::lonnet::metadata($srcf,'keys') |
&Apache::lonnet::metadata($srcf,'keys') |
Line 1780 sub updatestudentassesssheet {
|
Line 1802 sub updatestudentassesssheet {
|
$existing{$usy}=1; |
$existing{$usy}=1; |
unless ((exists($sheet->{'rowlabel'}->{$usy}) && |
unless ((exists($sheet->{'rowlabel'}->{$usy}) && |
(defined($sheet->{'rowlabel'}->{$usy})) || (!$1) || |
(defined($sheet->{'rowlabel'}->{$usy})) || (!$1) || |
($f{$_}=~/^(\~\~\~|\-\-\-)/))){ |
($f{$_}=~/^(~~~|---)/))){ |
$f{$_}='!!! Obsolete'; |
$f{$_}='!!! Obsolete'; |
$changed=1; |
$changed=1; |
} elsif ($ufn) { |
} elsif ($ufn) { |
Line 2113 sub forcedrecalc {
|
Line 2135 sub forcedrecalc {
|
if ($ENV{'form.forcerecalc'}) { return 1; } |
if ($ENV{'form.forcerecalc'}) { return 1; } |
unless ($time) { return 1; } |
unless ($time) { return 1; } |
if ($stype eq 'assesscalc') { |
if ($stype eq 'assesscalc') { |
my $map=(split(/\_\_\_/,$usymb))[0]; |
my $map=(split(/___/,$usymb))[0]; |
if (&checkthis('::assesscalc:',$time) || |
if (&checkthis('::assesscalc:',$time) || |
&checkthis('::assesscalc:'.$map,$time) || |
&checkthis('::assesscalc:'.$map,$time) || |
&checkthis('::assesscalc:'.$usymb,$time) || |
&checkthis('::assesscalc:'.$usymb,$time) || |
Line 2132 sub forcedrecalc {
|
Line 2154 sub forcedrecalc {
|
} |
} |
|
|
# ============================================================== Export handler |
# ============================================================== Export handler |
# |
|
# Non-interactive call from with program |
|
# |
|
|
|
sub exportsheet { |
sub exportsheet { |
my ($uname,$udom,$stype,$usymb,$fn)=@_; |
my ($uname,$udom,$stype,$usymb,$fn)=@_; |
my @exportarr=(); |
my @exportarr=(); |
if (($usymb=~/^\_(\w+)/) && (!$fn)) { |
if (defined($usymb) && ($usymb=~/^\_(\w+)/) && (!$fn)) { |
$fn='default_'.$1; |
$fn='default_'.$1; |
} |
} |
# |
# |
Line 2148 sub exportsheet {
|
Line 2166 sub exportsheet {
|
my $key=$uname.':'.$udom.':'.$stype.':'.$usymb; |
my $key=$uname.':'.$udom.':'.$stype.':'.$usymb; |
my $found=''; |
my $found=''; |
if ($oldsheets{$key}) { |
if ($oldsheets{$key}) { |
foreach (split(/\_\_\_\&\_\_\_/,$oldsheets{$key})) { |
foreach (split(/___&\___/,$oldsheets{$key})) { |
my ($name,$value)=split(/\_\_\_\=\_\_\_/,$_); |
my ($name,$value)=split(/___=___/,$_); |
if ($name eq $fn) { |
if ($name eq $fn) { |
$found=$value; |
$found=$value; |
} |
} |
Line 2158 sub exportsheet {
|
Line 2176 sub exportsheet {
|
unless ($found) { |
unless ($found) { |
&cachedssheets($uname,$udom,&Apache::lonnet::homeserver($uname,$udom)); |
&cachedssheets($uname,$udom,&Apache::lonnet::homeserver($uname,$udom)); |
if ($oldsheets{$key}) { |
if ($oldsheets{$key}) { |
foreach (split(/\_\_\_\&\_\_\_/,$oldsheets{$key})) { |
foreach (split(/___&\___/,$oldsheets{$key})) { |
my ($name,$value)=split(/\_\_\_\=\_\_\_/,$_); |
my ($name,$value)=split(/___=___/,$_); |
if ($name eq $fn) { |
if ($name eq $fn) { |
$found=$value; |
$found=$value; |
} |
} |
Line 2178 sub exportsheet {
|
Line 2196 sub exportsheet {
|
# |
# |
# Return what was cached |
# Return what was cached |
# |
# |
@exportarr=split(/\_\_\_\;\_\_\_/,$found); |
@exportarr=split(/___;___/,$found); |
|
return @exportarr; |
|
} |
|
# |
|
# Not cached |
|
# |
|
my ($sheet)=&makenewsheet($uname,$udom,$stype,$usymb); |
|
&readsheet($sheet,$fn); |
|
&updatesheet($sheet); |
|
&loadrows($sheet); |
|
&calcsheet($sheet); |
|
@exportarr=&exportdata($sheet); |
|
# |
|
# Store now |
|
# |
|
my $cid=$ENV{'request.course.id'}; |
|
my $current=''; |
|
if ($stype eq 'studentcalc') { |
|
$current=&Apache::lonnet::reply('get:'. |
|
$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_calculatedsheets:'. |
|
&Apache::lonnet::escape($key), |
|
$ENV{'course.'.$cid.'.home'}); |
} else { |
} else { |
# |
$current=&Apache::lonnet::reply('get:'.$sheet->{'udom'}.':'. |
# Not cached |
$sheet->{'uname'}. |
# |
':nohist_calculatedsheets_'. |
my ($sheet)=&makenewsheet($uname,$udom,$stype,$usymb); |
$ENV{'request.course.id'}.':'. |
&readsheet($sheet,$fn); |
&Apache::lonnet::escape($key), |
&updatesheet($sheet); |
$sheet->{'uhome'}); |
&loadrows($sheet); |
} |
&calcsheet($sheet); |
my %currentlystored=(); |
@exportarr=&exportdata($sheet); |
unless ($current=~/^error\:/) { |
# |
foreach (split(/___&\___/,&Apache::lonnet::unescape($current))) { |
# Store now |
my ($name,$value)=split(/___=___/,$_); |
# |
$currentlystored{$name}=$value; |
my $cid=$ENV{'request.course.id'}; |
} |
my $current=''; |
} |
if ($stype eq 'studentcalc') { |
$currentlystored{$fn}=join('___;___',@exportarr); |
$current=&Apache::lonnet::reply('get:'. |
# |
$ENV{'course.'.$cid.'.domain'}.':'. |
my $newstore=''; |
$ENV{'course.'.$cid.'.num'}. |
foreach (keys(%currentlystored)) { |
':nohist_calculatedsheets:'. |
if ($newstore) { $newstore.='___&___'; } |
&Apache::lonnet::escape($key), |
$newstore.=$_.'___=___'.$currentlystored{$_}; |
$ENV{'course.'.$cid.'.home'}); |
} |
} else { |
my $now=time; |
$current=&Apache::lonnet::reply('get:'.$sheet->{'udom'}.':'. |
if ($stype eq 'studentcalc') { |
$sheet->{'uname'}. |
&Apache::lonnet::put('nohist_calculatedsheets', |
':nohist_calculatedsheets_'. |
{ $key => $newstore, |
$ENV{'request.course.id'}.':'. |
$key.time => $now }, |
&Apache::lonnet::escape($key), |
$ENV{'course.'.$cid.'.domain'}, |
$sheet->{'uhome'}); |
$ENV{'course.'.$cid.'.num'}) |
} |
} else { |
my %currentlystored=(); |
&Apache::lonnet::put('nohist_calculatedsheets_'.$sheet->{'cid'}, |
unless ($current=~/^error\:/) { |
{ $key => $newstore, |
foreach (split(/___&\___/,&Apache::lonnet::unescape($current))) { |
$key.time => $now }, |
my ($name,$value)=split(/___=___/,$_); |
$sheet->{'udom'}, |
$currentlystored{$name}=$value; |
$sheet->{'uname'}) |
} |
|
} |
|
$currentlystored{$fn}=join('___;___',@exportarr); |
|
# |
|
my $newstore=''; |
|
foreach (keys(%currentlystored)) { |
|
if ($newstore) { $newstore.='___&___'; } |
|
$newstore.=$_.'___=___'.$currentlystored{$_}; |
|
} |
|
my $now=time; |
|
if ($stype eq 'studentcalc') { |
|
&Apache::lonnet::reply('put:'. |
|
$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_calculatedsheets:'. |
|
&Apache::lonnet::escape($key).'='. |
|
&Apache::lonnet::escape($newstore).'&'. |
|
&Apache::lonnet::escape($key).'.time='.$now, |
|
$ENV{'course.'.$cid.'.home'}); |
|
} else { |
|
&Apache::lonnet::reply('put:'. |
|
$sheet->{'udom'}.':'. |
|
$sheet->{'uname'}. |
|
':nohist_calculatedsheets_'. |
|
$ENV{'request.course.id'}.':'. |
|
&Apache::lonnet::escape($key).'='. |
|
&Apache::lonnet::escape($newstore).'&'. |
|
&Apache::lonnet::escape($key).'.time='.$now, |
|
$sheet->{'uhome'}); |
|
} |
|
} |
} |
return @exportarr; |
return @exportarr; |
} |
} |
Line 2451 ENDSCRIPT
|
Line 2462 ENDSCRIPT
|
&readsheet($sheet,$ENV{'form.ufn'}); |
&readsheet($sheet,$ENV{'form.ufn'}); |
} |
} |
# Print out user information |
# Print out user information |
unless ($sheet->{'sheettype'} eq 'classcalc') { |
if ($sheet->{'sheettype'} ne 'classcalc') { |
$r->print('<p><b>User:</b> '.$sheet->{'uname'}. |
$r->print('<p><b>User:</b> '.$sheet->{'uname'}. |
'<br><b>Domain:</b> '.$sheet->{'udom'}); |
'<br><b>Domain:</b> '.$sheet->{'udom'}); |
$r->print('<br><b>Section/Group:</b> '.$sheet->{'csec'}); |
$r->print('<br><b>Section/Group:</b> '.$sheet->{'csec'}); |
Line 2564 ENDSCRIPT
|
Line 2575 ENDSCRIPT
|
$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: '); |
} |
} |
# |
# |
$r->print(&hiddenfield('userselhidden','true'). |
$r->print(&hiddenfield('userselhidden','true'). |
'<input type="checkbox" name="showall" onClick="submit()"'); |
'<input type="checkbox" name="showall" onClick="submit()"'); |
Line 2581 ENDSCRIPT
|
Line 2592 ENDSCRIPT
|
} |
} |
} |
} |
$r->print('>'); |
$r->print('>'); |
|
# |
|
# CSV format checkbox (classcalc sheets only) |
|
$r->print(' Output CSV format: <input type="checkbox" '. |
|
'name="showcsv" onClick="submit()"'); |
|
$r->print(' checked') if ($ENV{'form.showcsv'}); |
|
$r->print('>'); |
if ($sheet->{'sheettype'} eq 'classcalc') { |
if ($sheet->{'sheettype'} eq 'classcalc') { |
# |
|
# CSV format checkbox (classcalc sheets only) |
|
$r->print(' Output CSV format: <input type="checkbox" '. |
|
'name="showcsv" onClick="submit()"'); |
|
if ($ENV{'form.showcsv'}) { $r->print(' checked'); } |
|
$r->print('>'); |
|
# |
|
# Buttons to insert rows |
|
$r->print(' Student Status: '. |
$r->print(' Student Status: '. |
&Apache::lonhtmlcommon::StatusOptions |
&Apache::lonhtmlcommon::StatusOptions |
($ENV{'form.Status'},'sheet')); |
($ENV{'form.Status'},'sheet')); |
} |
} |
|
# |
|
# Buttons to insert rows |
$r->print(<<ENDINSERTBUTTONS); |
$r->print(<<ENDINSERTBUTTONS); |
<br> |
<br> |
<input type='button' onClick='insertrow("top");' |
<input type='button' onClick='insertrow("top");' |