version 1.123, 2002/10/22 18:54:53
|
version 1.129, 2002/10/25 19:47:14
|
Line 122 my $tmpdir;
|
Line 122 my $tmpdir;
|
## |
## |
sub mask { |
sub mask { |
my ($lower,$upper)=@_; |
my ($lower,$upper)=@_; |
|
# |
$lower=~/([A-Za-z]|\*)(\d+|\*)/; |
my ($la,$ld) = ($lower=~/([A-Za-z]|\*)(\d+|\*)/); |
my $la=$1; |
my ($ua,$ud) = ($upper=~/([A-Za-z]|\*)(\d+|\*)/); |
my $ld=$2; |
# |
|
|
$upper=~/([A-Za-z]|\*)(\d+|\*)/; |
|
my $ua=$1; |
|
my $ud=$2; |
|
my $alpha=''; |
my $alpha=''; |
my $num=''; |
my $num=''; |
|
# |
if (($la eq '*') || ($ua eq '*')) { |
if (($la eq '*') || ($ua eq '*')) { |
$alpha='[A-Za-z]'; |
$alpha='[A-Za-z]'; |
} else { |
} else { |
|
|
if (($la=~/[A-Z]/) && ($ua=~/[A-Z]/) || |
if (($la=~/[A-Z]/) && ($ua=~/[A-Z]/) || |
($la=~/[a-z]/) && ($ua=~/[a-z]/)) { |
($la=~/[a-z]/) && ($ua=~/[a-z]/)) { |
$alpha='['.$la.'-'.$ua.']'; |
$alpha='['.$la.'-'.$ua.']'; |
Line 188 sub mask {
|
Line 185 sub mask {
|
} |
} |
$num.=')'; |
$num.=')'; |
} else { |
} else { |
if ($lda[$#lda]!=$uda[$#uda]) { |
if ($lda[-1]!=$uda[-1]) { |
$num.='['.$lda[$#lda].'-'.$uda[$#uda].']'; |
$num.='['.$lda[-1].'-'.$uda[-1].']'; |
} |
} |
} |
} |
} |
} |
Line 237 undef %c; # Holds the constants for a sh
|
Line 234 undef %c; # Holds the constants for a sh
|
# sheets, this is the A column. Used in &MINPARM, &MAXPARM, &expandnamed, |
# sheets, this is the A column. Used in &MINPARM, &MAXPARM, &expandnamed, |
# &sett, and &setconstants. There is no &getconstants. |
# &sett, and &setconstants. There is no &getconstants. |
# &setconstants is called by &loadstudent, &loadcourse, &load assessment, |
# &setconstants is called by &loadstudent, &loadcourse, &load assessment, |
undef %rowlabel; # Holds the 'prefix' for each row. Set by &setrowlabels. |
|
# &setrowlabels is called by &updateclasssheet, &updatestudentassesssheet, |
|
undef @os; # Holds the names of other spreadsheets - this is used to specify |
undef @os; # Holds the names of other spreadsheets - this is used to specify |
# the spreadsheets that are available for the assessment sheet. |
# the spreadsheets that are available for the assessment sheet. |
# Set by &setothersheets. &setothersheets is called by &handler. A |
# Set by &setothersheets. &setothersheets is called by &handler. A |
Line 754 parametername should be a string such as
|
Line 749 parametername should be a string such as
|
sub MINPARM { |
sub MINPARM { |
my ($expression) = @_; |
my ($expression) = @_; |
my $min = undef; |
my $min = undef; |
|
study($expression); |
foreach $parameter (keys(%c)) { |
foreach $parameter (keys(%c)) { |
next if ($parameter !~ /$expression/); |
next if ($parameter !~ /$expression/); |
if ((! defined($min)) || ($min > $c{$parameter})) { |
if ((! defined($min)) || ($min > $c{$parameter})) { |
Line 776 parametername should be a string such as
|
Line 772 parametername should be a string such as
|
sub MAXPARM { |
sub MAXPARM { |
my ($expression) = @_; |
my ($expression) = @_; |
my $max = undef; |
my $max = undef; |
|
study($expression); |
foreach $parameter (keys(%c)) { |
foreach $parameter (keys(%c)) { |
next if ($parameter !~ /$expression/); |
next if ($parameter !~ /$expression/); |
if ((! defined($min)) || ($max < $c{$parameter})) { |
if ((! defined($min)) || ($max < $c{$parameter})) { |
Line 827 sub expandnamed {
|
Line 824 sub expandnamed {
|
my $returnvalue = ''; |
my $returnvalue = ''; |
my @matches = (); |
my @matches = (); |
$#matches = -1; |
$#matches = -1; |
|
study $expression; |
foreach $parameter (keys(%c)) { |
foreach $parameter (keys(%c)) { |
push @matches,$parameter if ($parameter =~ /$expression/); |
push @matches,$parameter if ($parameter =~ /$expression/); |
} |
} |
if ($#matches == 0) { |
if (scalar(@matches) == 0) { |
|
$returnvalue = 'unmatched parameter: '.$parameter; |
|
} elsif (scalar(@matches) == 1) { |
$returnvalue = '$c{\''.$matches[0].'\'}'; |
$returnvalue = '$c{\''.$matches[0].'\'}'; |
} elsif ($#matches > 0) { |
} elsif (scalar(@matches) > 0) { |
# more than one match. Look for a concise one |
# more than one match. Look for a concise one |
$returnvalue = "'non-unique parameter name : $expression'"; |
$returnvalue = "'non-unique parameter name : $expression'"; |
foreach (@matches) { |
foreach (@matches) { |
Line 841 sub expandnamed {
|
Line 841 sub expandnamed {
|
} |
} |
} |
} |
} else { |
} else { |
$returnvalue = "'bad parameter name : $expression'"; |
# There was a negative number of matches, which indicates |
|
# something is wrong with reality. Better warn the user. |
|
$returnvalue = 'bizzare parameter: '.$parameter; |
} |
} |
return $returnvalue; |
return $returnvalue; |
} |
} |
Line 915 sub sett {
|
Line 917 sub sett {
|
$t{'A0'}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.&expandnamed($2)/ge; |
$t{'A0'}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.&expandnamed($2)/ge; |
} |
} |
|
|
|
sub calc { |
|
undef %sheet_values; |
|
&sett(); |
|
my $notfinished=1; |
|
my $lastcalc=''; |
|
my $depth=0; |
|
while ($notfinished) { |
|
$notfinished=0; |
|
foreach (keys(%t)) { |
|
my $old=$sheet_values{$_}; |
|
$sheet_values{$_}=eval $t{$_}; |
|
if ($@) { |
|
undef %sheet_values; |
|
return $_.': '.$@; |
|
} |
|
if ($sheet_values{$_} ne $old) { $notfinished=1; $lastcalc=$_; } |
|
} |
|
$depth++; |
|
if ($depth>100) { |
|
undef %sheet_values; |
|
return $lastcalc.': Maximum calculation depth exceeded'; |
|
} |
|
} |
|
return ''; |
|
} |
|
|
# ------------------------------------------- End of "Inside of the safe space" |
# ------------------------------------------- End of "Inside of the safe space" |
ENDDEFS |
ENDDEFS |
$safeeval->reval($code); |
$safeeval->reval($code); |
Line 922 ENDDEFS
|
Line 950 ENDDEFS
|
} |
} |
|
|
# |
# |
# This is actually used for the student spreadsheet, not the assessment sheet |
# |
# Do not be fooled by the name! |
|
# |
# |
sub templaterow { |
sub templaterow { |
my $sheet = shift; |
my $sheet = shift; |
Line 950 sub outrowassess {
|
Line 977 sub outrowassess {
|
if ($n) { |
if ($n) { |
my ($usy,$ufn)=split(/__&&&\__/,$sheet->{'f'}->{'A'.$n}); |
my ($usy,$ufn)=split(/__&&&\__/,$sheet->{'f'}->{'A'.$n}); |
if ($sheet->{'rowlabel'}->{$usy}) { |
if ($sheet->{'rowlabel'}->{$usy}) { |
$cols[0]=$sheet->{'rowlabel'}->{$usy}; |
$cols[0]=&format_rowlabel($sheet->{'rowlabel'}->{$usy}); |
if (! $csv) { |
if (! $csv) { |
$cols[0].='<br>'. |
$cols[0].='<br>'. |
'<select name="sel_'.$n.'" onChange="changesheet('.$n.')">'. |
'<select name="sel_'.$n.'" onChange="changesheet('.$n.')">'. |
Line 988 sub outrow {
|
Line 1015 sub outrow {
|
my $n=shift; |
my $n=shift; |
my @cols=(); |
my @cols=(); |
if ($n) { |
if ($n) { |
$cols[0]=$sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$n}}; |
$cols[0]=&format_rowlabel($sheet->{'rowlabel'}->{$sheet->{'f'}->{'A'.$n}}); |
} else { |
} else { |
$cols[0]='<b><font size=+1>Export</font></b>'; |
$cols[0]='<b><font size=+1>Export</font></b>'; |
} |
} |
Line 1004 sub outrow {
|
Line 1031 sub outrow {
|
} |
} |
|
|
# ------------------------------------------------ Add or change formula values |
# ------------------------------------------------ Add or change formula values |
sub update_values { |
|
my $sheet = shift; |
|
%{$sheet->{'safe'}->varglob('sheet_values')}=%{$sheet->{'values'}}; |
|
return undef; |
|
} |
|
|
|
sub setvalues { |
|
my $sheet=shift; |
|
my ($values) = @_; |
|
$values = {} if (! defined($values)); |
|
if (! ref($values)) { |
|
my %tmp = @_; |
|
$values = \%tmp; |
|
} |
|
$sheet->{'values'} = $values; |
|
%{$sheet->{'safe'}->varglob('sheet_values')}=%{$sheet->{'values'}}; |
|
return undef; |
|
} |
|
|
|
sub setformulas { |
sub setformulas { |
my $sheet=shift; |
my ($sheet)=shift; |
my ($formulas) = @_; |
|
$formulas = {} if (! defined($formulas)); |
|
if (! ref($formulas)) { |
|
my %tmp = @_; |
|
$formulas = \%tmp; |
|
} |
|
$sheet->{'f'} = $formulas; |
|
%{$sheet->{'safe'}->varglob('f')}=%{$sheet->{'f'}}; |
%{$sheet->{'safe'}->varglob('f')}=%{$sheet->{'f'}}; |
return undef; |
|
} |
} |
|
|
# ------------------------------------------------ Add or change formula values |
# ------------------------------------------------ Add or change formula values |
Line 1060 sub setothersheets {
|
Line 1060 sub setothersheets {
|
# ------------------------------------------------ Add or change formula values |
# ------------------------------------------------ Add or change formula values |
sub setrowlabels { |
sub setrowlabels { |
my $sheet=shift; |
my $sheet=shift; |
%{$sheet->{'safe'}->varglob('rowlabel')}=%{$sheet->{'rowlabel'}}; |
my ($rowlabel) = @_; |
|
if (! ref($rowlabel)) { |
|
my %tmp = @_; |
|
$rowlabel = \%tmp; |
|
} |
|
$sheet->{'rowlabel'}=$rowlabel; |
} |
} |
|
|
# ------------------------------------------------------- Calculate spreadsheet |
# ------------------------------------------------------- Calculate spreadsheet |
sub calcsheet { |
sub calcsheet { |
my $sheet=shift; |
my $sheet=shift; |
&setvalues($sheet,undef); |
my $result = $sheet->{'safe'}->reval('&calc();'); |
$sheet->{'safe'}->reval('&sett();'); |
%{$sheet->{'values'}} = %{$sheet->{'safe'}->varglob('sheet_values')}; |
my %t = %{$sheet->{'safe'}->varglob('t')}; |
return $result; |
my $notfinished=1; |
|
my $lastcalc=''; |
|
my $depth=0; |
|
while ($notfinished) { |
|
$notfinished=0; |
|
foreach (keys(%t)) { |
|
my $old=$sheet->{'values'}->{$_}; |
|
$sheet->{'values'}->{$_}=$sheet->{'safe'}->reval($t{$_}.';'); |
|
if ($@) { |
|
&setvalues($sheet,undef); |
|
return $_.': '.$@; |
|
} |
|
if ($sheet->{'values'}->{$_} ne $old) { |
|
$notfinished=1; |
|
$lastcalc=$_; |
|
} |
|
} |
|
if ($notfinished) { |
|
%{$sheet->{'safe'}->varglob('sheet_values')} = |
|
%{$sheet->{'values'}}; |
|
} |
|
|
|
$depth++; |
|
if ($depth>100) { |
|
&setvalues($sheet,undef); |
|
return $lastcalc.': Maximum calculation depth exceeded'; |
|
} |
|
} |
|
return ; |
|
} |
} |
|
|
# ---------------------------------------------------------------- Get formulas |
# ---------------------------------------------------------------- Get formulas |
Line 1259 sub outsheet {
|
Line 1235 sub outsheet {
|
# Prepare to output rows |
# Prepare to output rows |
my $row; |
my $row; |
# |
# |
|
# Sort the rows in some manner |
|
# |
my @sortby=(); |
my @sortby=(); |
my @sortidx=(); |
my @sortidx=(); |
for ($row=1;$row<=$sheet->{'maxrow'};$row++) { |
for ($row=1;$row<=$sheet->{'maxrow'};$row++) { |
Line 1381 sub readsheet {
|
Line 1359 sub readsheet {
|
my $fstring=''; |
my $fstring=''; |
if ($fstring=$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}) { |
if ($fstring=$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}) { |
my %tmp = split(/___;___/,$fstring); |
my %tmp = split(/___;___/,$fstring); |
&setformulas($sheet,\%tmp); |
$sheet->{'f'} = \%tmp; |
|
&setformulas($sheet); |
} else { |
} else { |
# Not cached, need to read |
# Not cached, need to read |
my %f=(); |
my %f=(); |
Line 1416 sub readsheet {
|
Line 1395 sub readsheet {
|
} |
} |
# Cache and set |
# Cache and set |
$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}=join('___;___',%f); |
$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}=join('___;___',%f); |
&setformulas($sheet,\%f); |
$sheet->{'f'}=\%f; |
|
&setformulas($sheet); |
} |
} |
} |
} |
|
|
Line 1547 sub tmpread {
|
Line 1527 sub tmpread {
|
} |
} |
} |
} |
if ($nform eq 'changesheet') { |
if ($nform eq 'changesheet') { |
$fo{'A'.$nfield}=(split(/\_\_\&\&\&\_\_/,$fo{'A'.$nfield}))[0]; |
$fo{'A'.$nfield}=(split(/__&&&\__/,$fo{'A'.$nfield}))[0]; |
unless ($ENV{'form.sel_'.$nfield} eq 'Default') { |
unless ($ENV{'form.sel_'.$nfield} eq 'Default') { |
$fo{'A'.$nfield}.='__&&&__'.$ENV{'form.sel_'.$nfield}; |
$fo{'A'.$nfield}.='__&&&__'.$ENV{'form.sel_'.$nfield}; |
} |
} |
Line 1562 sub tmpread {
|
Line 1542 sub tmpread {
|
} else { |
} else { |
if ($nfield) { $fo{$nfield}=$nform; } |
if ($nfield) { $fo{$nfield}=$nform; } |
} |
} |
&setformulas($sheet,\%fo); |
$sheet->{'f'}=\%fo; |
|
&setformulas($sheet); |
} |
} |
|
|
################################################## |
################################################## |
Line 1640 sub parmval {
|
Line 1621 sub parmval {
|
return &Apache::lonnet::metadata($fn,$rwhat.'.default'); |
return &Apache::lonnet::metadata($fn,$rwhat.'.default'); |
} |
} |
|
|
|
sub format_rowlabel { |
|
my $rowlabel = shift; |
|
my ($type,$labeldata) = split(':',$rowlabel,2); |
|
my $result = ''; |
|
if ($type eq 'symb') { |
|
my ($symb,$uname,$udom,$title) = split(':',$labeldata); |
|
$symb = &Apache::lonnet::unescape($symb); |
|
if ($ENV{'form.showcsv'}) { |
|
$result = $title; |
|
} else { |
|
$result = '<a href="/adm/assesscalc?usymb='.$symb. |
|
'&uname='.$uname.'&udom='.$udom.'">'.$title.'</a>'; |
|
} |
|
} elsif ($type eq 'student') { |
|
my ($sname,$sdom,$fullname,$section,$id) = split(':',$labeldata); |
|
if ($ENV{'form.showcsv'}) { |
|
$result = '"'. |
|
join('","',($sname,$sdom,$fullname,$section,$id).'"'); |
|
} else { |
|
$result ='<a href="/adm/studentcalc?uname='.$sname. |
|
'&udom='.$sdom.'">'; |
|
$result.=$section.' '.$id." ".$fullname.'</a>'; |
|
} |
|
} elsif ($type eq 'parameter') { |
|
if ($ENV{'form.showcsv'}) { |
|
$labeldata =~ s/<br>/ /g; |
|
} |
|
$result = $labeldata; |
|
} else { |
|
&Apache::lonnet::logthis("lonspreadsheet:bogus rowlabel type: $type"); |
|
} |
|
return $result; |
|
} |
|
|
# ---------------------------------------------- Update rows for course listing |
# ---------------------------------------------- Update rows for course listing |
sub updateclasssheet { |
sub updateclasssheet { |
my ($sheet) = @_; |
my ($sheet) = @_; |
Line 1662 sub updateclasssheet {
|
Line 1677 sub updateclasssheet {
|
my ($studentDomain,$studentName,$end,$start,$id,$studentSection, |
my ($studentDomain,$studentName,$end,$start,$id,$studentSection, |
$fullname,$status) = @{$classlist->{$student}}; |
$fullname,$status) = @{$classlist->{$student}}; |
if ($ENV{'form.Status'} eq $status || $ENV{'form.Status'} eq 'Any') { |
if ($ENV{'form.Status'} eq $status || $ENV{'form.Status'} eq 'Any') { |
my $rowlabel=''; |
$currentlist{$student}=join(':',('student',$studentName, |
if ($ENV{'form.showcsv'}) { |
$studentDomain,$fullname, |
$rowlabel= '"'.join('","',($studentName,$studentDomain, |
$studentSection,$id)); |
$fullname,$studentSection,$id).'"'); |
|
} else { |
|
$rowlabel='<a href="/adm/studentcalc?uname='.$studentName. |
|
'&udom='.$studentDomain.'">'; |
|
$rowlabel.=$studentSection.' '.$id." ".$fullname; |
|
$rowlabel.='</a>'; |
|
} |
|
$currentlist{$student}=$rowlabel; |
|
} |
} |
} |
} |
# |
# |
Line 1700 sub updateclasssheet {
|
Line 1707 sub updateclasssheet {
|
} |
} |
# |
# |
# New and unknown keys |
# New and unknown keys |
foreach (sort keys(%currentlist)) { |
foreach my $student (sort keys(%currentlist)) { |
unless ($existing{$_}) { |
unless ($existing{$student}) { |
$changed=1; |
$changed=1; |
$sheet->{'maxrow'}++; |
$sheet->{'maxrow'}++; |
$f{'A'.$sheet->{'maxrow'}}=$_; |
$f{'A'.$sheet->{'maxrow'}}=$student; |
} |
} |
} |
} |
if ($changed) { |
if ($changed) { |
&setformulas($sheet,\%f); |
$sheet->{'f'} = \%f; |
|
&setformulas($sheet,%f); |
} |
} |
# |
# |
$sheet->{'rowlabel'} = \%currentlist; |
&setrowlabels($sheet,\%currentlist); |
&setrowlabels($sheet); |
|
} |
} |
|
|
# ----------------------------------- Update rows for student and assess sheets |
# ----------------------------------- Update rows for student and assess sheets |
sub updatestudentassesssheet { |
sub updatestudentassesssheet { |
my ($sheet) = @_; |
my ($sheet) = @_; |
|
# |
my %bighash; |
my %bighash; |
my $stype=$sheet->{'sheettype'}; |
# |
my $uname=$sheet->{'uname'}; |
my $stype = $sheet->{'sheettype'}; |
my $udom =$sheet->{'udom'}; |
my $uname = $sheet->{'uname'}; |
|
my $udom = $sheet->{'udom'}; |
$sheet->{'rowlabel'} = {}; |
$sheet->{'rowlabel'} = {}; |
if ($updatedata |
my $identifier =$sheet->{'coursefilename'}.'_'.$stype.'_'.$uname.'_'.$udom; |
{$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}) { |
if ($updatedata{$identifier}) { |
%{$sheet->{'rowlabel'}}=split(/___;___/, |
%{$sheet->{'rowlabel'}}=split(/___;___/,$updatedata{$identifier}); |
$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',$sheet->{'coursefilename'}.'.db', |
&GDBM_READER(),0640); |
&GDBM_READER(),0640); |
if (! tied(%bighash)) { |
if (! tied(%bighash)) { |
return 'Could not access course data'; |
return 'Could not access course data'; |
} |
} |
# Get all assessments |
# Get all assessments |
my %allkeys=('timestamp' => |
# |
'Timestamp of Last Transaction<br>timestamp', |
# parameter_labels is used in the assessment sheets to provide labels |
'subnumber' => |
# for the parameters. |
'Number of Submissions<br>subnumber', |
my %parameter_labels= |
'tutornumber' => |
('timestamp' => |
'Number of Tutor Responses<br>tutornumber', |
'parameter:Timestamp of Last Transaction<br>timestamp', |
'totalpoints' => |
'subnumber' => |
'Total Points Granted<br>totalpoints'); |
'parameter:Number of Submissions<br>subnumber', |
my $adduserstr=''; |
'tutornumber' => |
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})){ |
'parameter:Number of Tutor Responses<br>tutornumber', |
$adduserstr='&uname='.$uname.'&udom='.$udom; |
'totalpoints' => |
} |
'parameter:Total Points Granted<br>totalpoints'); |
my %allassess; |
# |
if (! $ENV{'form.showcsv'}) { |
# assesslist holds the descriptions of all assessments |
%allassess = |
my %assesslist; |
('_feedback' =>'<a href="/adm/assesscalc?usymb=_feedback'. |
foreach ('Feedback','Evaluation','Tutoring','Discussion') { |
$adduserstr.'">Feedback</a>', |
my $symb = '_'.lc($_); |
'_evaluation' =>'<a href="/adm/assesscalc?usymb=_evaluation'. |
$assesslist{$symb} = join(':',('symb',$symb,$uname,$udom,$_)); |
$adduserstr.'">Evaluation</a>', |
|
'_tutoring' =>'<a href="/adm/assesscalc?usymb=_tutoring'. |
|
$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+)$/); |
Line 1778 sub updatestudentassesssheet {
|
Line 1772 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); |
if (! $ENV{'form.showcsv'}) { |
$assesslist{$symb}='symb:'.&Apache::lonnet::escape($symb).':' |
$allassess{$symb}= |
.$uname.':'.$udom.':'.$bighash{'title_'.$id}; |
'<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 1797 sub updatestudentassesssheet {
|
Line 1786 sub updatestudentassesssheet {
|
&Apache::lonnet::metadata($srcf,$key.'.name'); |
&Apache::lonnet::metadata($srcf,$key.'.name'); |
} |
} |
$display.='<br>'.$key; |
$display.='<br>'.$key; |
$allkeys{$key}=$display; |
$parameter_labels{$key}='parameter:'.$display; |
} # end of foreach |
} # end of foreach |
} |
} |
} # end of foreach (keys(%bighash)) |
} # end of foreach (keys(%bighash)) |
untie(%bighash); |
untie(%bighash); |
# |
# |
# %allkeys has a list of storage and parameter displays by unikey |
# %parameter_labels has a list of storage and parameter displays by |
# %allassess has a list of all resource displays by symb |
# unikey |
|
# %assesslist has a list of all resource, by symb |
# |
# |
if ($stype eq 'assesscalc') { |
if ($stype eq 'assesscalc') { |
$sheet->{'rowlabel'} = \%allkeys; |
$sheet->{'rowlabel'} = \%parameter_labels; |
} elsif ($stype eq 'studentcalc') { |
} elsif ($stype eq 'studentcalc') { |
$sheet->{'rowlabel'} = \%allassess; |
$sheet->{'rowlabel'} = \%assesslist; |
} |
} |
$updatedata{$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}= |
$updatedata{$sheet->{'coursefilename'}.'_'.$stype.'_' |
join('___;___',%{$sheet->{'rowlabel'}}); |
.$uname.'_'.$udom}= |
|
join('___;___',%{$sheet->{'rowlabel'}}); |
# Get current from cache |
# Get current from cache |
} |
} |
# Find discrepancies between the course row table and this |
# Find discrepancies between the course row table and this |
Line 1849 sub updatestudentassesssheet {
|
Line 1840 sub updatestudentassesssheet {
|
} |
} |
} |
} |
if ($changed) { |
if ($changed) { |
&setformulas($sheet,\%f); |
$sheet->{'f'} = \%f; |
|
&setformulas($sheet); |
} |
} |
&setrowlabels($sheet); |
|
# |
# |
undef %existing; |
undef %existing; |
} |
} |
Line 1879 sub loadstudent {
|
Line 1870 sub loadstudent {
|
my $row=$1; |
my $row=$1; |
next if (($f{$_}=~/^[\!\~\-]/) || ($row==0)); |
next if (($f{$_}=~/^[\!\~\-]/) || ($row==0)); |
my ($usy,$ufn)=split(/__&&&\__/,$f{$_}); |
my ($usy,$ufn)=split(/__&&&\__/,$f{$_}); |
@assessdata=&exportsheet($sheet->{'uname'}, |
@assessdata=&exportsheet($sheet,$sheet->{'uname'}, |
$sheet->{'udom'}, |
$sheet->{'udom'}, |
'assesscalc',$usy,$ufn); |
'assesscalc',$usy,$ufn); |
my $index=0; |
my $index=0; |
Line 1901 sub loadstudent {
|
Line 1892 sub loadstudent {
|
} |
} |
$cachedassess=''; |
$cachedassess=''; |
undef %cachedstores; |
undef %cachedstores; |
&setformulas($sheet,\%f); |
$sheet->{'f'} = \%f; |
|
&setformulas($sheet); |
&setconstants($sheet,\%c); |
&setconstants($sheet,\%c); |
} |
} |
|
|
Line 1935 ENDPOP
|
Line 1927 ENDPOP
|
next if ($_!~/^A(\d+)/); |
next if ($_!~/^A(\d+)/); |
my $row=$1; |
my $row=$1; |
next if (($f{$_}=~/^[\!\~\-]/) || ($row==0)); |
next if (($f{$_}=~/^[\!\~\-]/) || ($row==0)); |
my @studentdata=&exportsheet(split(/\:/,$f{$_}), |
my @studentdata=&exportsheet($sheet,split(/\:/,$f{$_}), |
'studentcalc'); |
'studentcalc'); |
undef %userrdatas; |
undef %userrdatas; |
$now++; |
$now++; |
Line 1961 ENDPOP
|
Line 1953 ENDPOP
|
} |
} |
} |
} |
} |
} |
&setformulas($sheet,\%f); |
$sheet->{'f'}=\%f; |
|
&setformulas($sheet); |
&setconstants($sheet,\%c); |
&setconstants($sheet,\%c); |
$r->print('<script>popwin.close()</script>'); |
$r->print('<script>popwin.close()</script>'); |
$r->rflush(); |
$r->rflush(); |
Line 2066 sub loadassessment {
|
Line 2059 sub loadassessment {
|
if (tie(%parmhash,'GDBM_File', |
if (tie(%parmhash,'GDBM_File', |
$sheet->{'coursefilename'}.'_parms.db',&GDBM_READER(),0640)) { |
$sheet->{'coursefilename'}.'_parms.db',&GDBM_READER(),0640)) { |
my %f=&getformulas($sheet); |
my %f=&getformulas($sheet); |
foreach (keys(%f)) { |
foreach my $cell (keys(%f)) { |
next if ($_!~/^A/); |
next if ($cell !~ /^A/); |
next if ($f{$_}=~/^[\!\~\-]/); |
next if ($f{$cell} =~/^[\!\~\-]/); |
if ($f{$_}=~/^parameter/) { |
if ($f{$cell}=~/^parameter/) { |
if ($thisassess{$f{$_}}) { |
if (defined($thisassess{$f{$cell}})) { |
my $val=&parmval($f{$_},$sheet); |
my $val = &parmval($f{$cell},$sheet); |
$c{$_}=$val; |
$c{$cell} = $val; |
$c{$f{$_}}=$val; |
$c{$f{$cell}} = $val; |
} |
} |
} else { |
} else { |
my $key=$f{$_}; |
my $key=$f{$cell}; |
my $ckey=$key; |
my $ckey=$key; |
$key=~s/^stores\_/resource\./; |
$key=~s/^stores\_/resource\./; |
$key=~s/\_/\./g; |
$key=~s/\_/\./g; |
$c{$_}=$returnhash{$key}; |
$c{$cell}=$returnhash{$key}; |
$c{$ckey}=$returnhash{$key}; |
$c{$ckey}=$returnhash{$key}; |
} |
} |
} |
} |
Line 2178 sub forcedrecalc {
|
Line 2171 sub forcedrecalc {
|
} |
} |
|
|
# ============================================================== Export handler |
# ============================================================== Export handler |
|
# exportsheet |
|
# returns the export row for a spreadsheet. |
|
# |
sub exportsheet { |
sub exportsheet { |
my ($uname,$udom,$stype,$usymb,$fn)=@_; |
my ($sheet,$uname,$udom,$stype,$usymb,$fn)=@_; |
|
$uname = $uname || $sheet->{'uname'}; |
|
$udom = $udom || $sheet->{'udom'}; |
|
$stype = $stype || $sheet->{'sheettype'}; |
my @exportarr=(); |
my @exportarr=(); |
if (defined($usymb) && ($usymb=~/^\_(\w+)/) && (!$fn)) { |
if (defined($usymb) && ($usymb=~/^\_(\w+)/) && (!$fn)) { |
$fn='default_'.$1; |
$fn='default_'.$1; |
Line 2198 sub exportsheet {
|
Line 2197 sub exportsheet {
|
} |
} |
} |
} |
unless ($found) { |
unless ($found) { |
&cachedssheets($uname,$udom,&Apache::lonnet::homeserver($uname,$udom)); |
&cachedssheets($sheet,$uname,$udom); |
if ($oldsheets{$key}) { |
if ($oldsheets{$key}) { |
foreach (split(/___&\___/,$oldsheets{$key})) { |
foreach (split(/___&\___/,$oldsheets{$key})) { |
my ($name,$value)=split(/___=___/,$_); |
my ($name,$value)=split(/___=___/,$_); |
Line 2226 sub exportsheet {
|
Line 2225 sub exportsheet {
|
# |
# |
# Not cached |
# Not cached |
# |
# |
my ($sheet)=&makenewsheet($uname,$udom,$stype,$usymb); |
my ($newsheet)=&makenewsheet($uname,$udom,$stype,$usymb); |
&readsheet($sheet,$fn); |
&readsheet($newsheet,$fn); |
&updatesheet($sheet); |
&updatesheet($newsheet); |
&loadrows($sheet); |
&loadrows($newsheet); |
&calcsheet($sheet); |
&calcsheet($newsheet); |
@exportarr=&exportdata($sheet); |
@exportarr=&exportdata($newsheet); |
# |
# |
# Store now |
# Store now |
# |
# |
my $cid=$ENV{'request.course.id'}; |
my $cid=$newsheet->{'cid'}; |
my $current=''; |
my $current=''; |
if ($stype eq 'studentcalc') { |
if ($stype eq 'studentcalc') { |
$current=&Apache::lonnet::reply('get:'. |
$current=&Apache::lonnet::reply('get:'.$sheet->{'cdom'}.':'. |
$ENV{'course.'.$cid.'.domain'}.':'. |
$sheet->{'cnum'}. |
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_calculatedsheets:'. |
':nohist_calculatedsheets:'. |
&Apache::lonnet::escape($key), |
&Apache::lonnet::escape($key), |
$ENV{'course.'.$cid.'.home'}); |
$sheet->{'chome'}); |
} else { |
} else { |
$current=&Apache::lonnet::reply('get:'.$sheet->{'udom'}.':'. |
$current=&Apache::lonnet::reply('get:'.$sheet->{'udom'}.':'. |
$sheet->{'uname'}. |
$sheet->{'uname'}. |
':nohist_calculatedsheets_'. |
':nohist_calculatedsheets_'. |
$ENV{'request.course.id'}.':'. |
$sheet->{'cid'}.':'. |
&Apache::lonnet::escape($key), |
&Apache::lonnet::escape($key), |
$sheet->{'uhome'}); |
$sheet->{'uhome'}); |
} |
} |
Line 2271 sub exportsheet {
|
Line 2269 sub exportsheet {
|
&Apache::lonnet::put('nohist_calculatedsheets', |
&Apache::lonnet::put('nohist_calculatedsheets', |
{ $key => $newstore, |
{ $key => $newstore, |
$key.time => $now }, |
$key.time => $now }, |
$ENV{'course.'.$cid.'.domain'}, |
$sheet->{'cid'},$sheet->{'cnum'}); |
$ENV{'course.'.$cid.'.num'}) |
|
} else { |
} else { |
&Apache::lonnet::put('nohist_calculatedsheets_'.$sheet->{'cid'}, |
&Apache::lonnet::put('nohist_calculatedsheets_'.$sheet->{'cid'}, |
{ $key => $newstore, |
{ $key => $newstore, |
Line 2290 sub exportsheet {
|
Line 2287 sub exportsheet {
|
sub expirationdates { |
sub expirationdates { |
undef %expiredates; |
undef %expiredates; |
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
my $reply=&Apache::lonnet::reply('dump:'. |
my @tmp = &Apache::lonnet::dump('nohist_expirationdates', |
$ENV{'course.'.$cid.'.domain'}.':'. |
$ENV{'course.'.$cid.'.domain'}, |
$ENV{'course.'.$cid.'.num'}. |
$ENV{'course.'.$cid.'.num'}); |
':nohist_expirationdates', |
if (lc($tmp[0])!~/^error/){ |
$ENV{'course.'.$cid.'.home'}); |
%expiredates = @tmp; |
unless ($reply=~/^error\:/) { |
|
foreach (split(/\&/,$reply)) { |
|
my ($name,$value)=split(/\=/,$_); |
|
$expiredates{&Apache::lonnet::unescape($name)} |
|
=&Apache::lonnet::unescape($value); |
|
} |
|
} |
} |
} |
} |
|
|
Line 2311 sub expirationdates {
|
Line 2302 sub expirationdates {
|
|
|
sub cachedcsheets { |
sub cachedcsheets { |
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
my $reply=&Apache::lonnet::reply('dump:'. |
my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets', |
$ENV{'course.'.$cid.'.domain'}.':'. |
$ENV{'course.'.$cid.'.domain'}, |
$ENV{'course.'.$cid.'.num'}. |
$ENV{'course.'.$cid.'.num'}); |
':nohist_calculatedsheets', |
if ($tmp[0] !~ /^error/) { |
$ENV{'course.'.$cid.'.home'}); |
my %StupidTempHash = @tmp; |
unless ($reply=~/^error\:/) { |
while (my ($key,$value) = each %StupidTempHash) { |
foreach ( split(/\&/,$reply)) { |
$oldsheets{$key} = $value; |
my ($name,$value)=split(/\=/,$_); |
|
$oldsheets{&Apache::lonnet::unescape($name)} |
|
=&Apache::lonnet::unescape($value); |
|
} |
} |
} |
} |
} |
} |
Line 2331 sub cachedcsheets {
|
Line 2319 sub cachedcsheets {
|
# |
# |
|
|
sub cachedssheets { |
sub cachedssheets { |
my ($sname,$sdom,$shome)=@_; |
my ($sheet,$uname,$udom) = @_; |
unless (($loadedcaches{$sname.'_'.$sdom}) || ($shome eq 'no_host')) { |
$uname = $uname || $sheet->{'uname'}; |
my $cid=$ENV{'request.course.id'}; |
$udom = $udom || $sheet->{'udom'}; |
my $reply=&Apache::lonnet::reply('dump:'.$sdom.':'.$sname. |
if (! $loadedcaches{$sheet->{'uname'}.'_'.$sheet->{'udom'}}) { |
':nohist_calculatedsheets_'. |
my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets', |
$ENV{'request.course.id'}, |
$sheet->{'udom'}, |
$shome); |
$sheet->{'uname'}); |
unless ($reply=~/^error\:/) { |
if ($tmp[0] !~ /^error/) { |
foreach ( split(/\&/,$reply)) { |
my %StupidTempHash = @tmp; |
my ($name,$value)=split(/\=/,$_); |
while (my ($key,$value) = each %StupidTempHash) { |
$oldsheets{&Apache::lonnet::unescape($name)} |
$oldsheets{$key} = $value; |
=&Apache::lonnet::unescape($value); |
} |
|
$loadedcaches{$sheet->{'uname'}.'_'.$sheet->{'udom'}}=1; |
} |
} |
} |
} |
$loadedcaches{$sname.'_'.$sdom}=1; |
|
} |
|
} |
} |
|
|
# ===================================================== Calculated sheets cache |
# ===================================================== Calculated sheets cache |
Line 2561 ENDSCRIPT
|
Line 2548 ENDSCRIPT
|
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
} elsif ($sheet->{'sheettype'} eq 'studentcalc') { |
$r->print("Loading previously calculated assessment sheets ...\n"); |
$r->print("Loading previously calculated assessment sheets ...\n"); |
$r->rflush(); |
$r->rflush(); |
&cachedssheets($sheet->{'uname'},$sheet->{'udom'},$sheet->{'uhome'}); |
&cachedssheets($sheet); |
} |
} |
# 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"); |
Line 2609 ENDSCRIPT
|
Line 2596 ENDSCRIPT
|
} else { |
} else { |
unless ($ENV{'form.userselhidden'}) { |
unless ($ENV{'form.userselhidden'}) { |
unless |
unless |
($ENV{'course.'.$ENV{'request.course.id'}.'.hideemptyrows'} eq 'yes') { |
($ENV{'course.'.$sheet->{'cid'}.'.hideemptyrows'} eq 'yes') { |
$r->print(' checked'); |
$r->print(' checked'); |
$ENV{'form.showall'}=1; |
$ENV{'form.showall'}=1; |
} |
} |