version 1.127, 2002/10/24 15:34:10
|
version 1.130, 2002/10/29 16:04:13
|
Line 828 sub expandnamed {
|
Line 828 sub expandnamed {
|
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 839 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 946 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 1092 sub exportdata {
|
Line 1095 sub exportdata {
|
my @exportarray=(); |
my @exportarray=(); |
foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M', |
foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M', |
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') { |
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') { |
push(@exportarray,$sheet->{'values'}->{$_.'0'}); |
if (exists($sheet->{'values'}->{$_.'0'})) { |
|
push(@exportarray,$sheet->{'values'}->{$_.'0'}); |
|
} else { |
|
push(@exportarray,''); |
|
} |
} |
} |
return @exportarray; |
return @exportarray; |
} |
} |
Line 1232 sub outsheet {
|
Line 1239 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 1522 sub tmpread {
|
Line 1531 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 1702 sub updateclasssheet {
|
Line 1711 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) { |
Line 1720 sub updateclasssheet {
|
Line 1729 sub updateclasssheet {
|
# ----------------------------------- 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 |
# |
# |
# allkeys is used in the assessment sheets to provide labels |
# parameter_labels is used in the assessment sheets to provide labels |
# for the parameters. |
# for the parameters. |
my %allkeys=('timestamp' => |
my %parameter_labels= |
'parameter:Timestamp of Last Transaction<br>timestamp', |
('timestamp' => |
'subnumber' => |
'parameter:Timestamp of Last Transaction<br>timestamp', |
'parameter:Number of Submissions<br>subnumber', |
'subnumber' => |
'tutornumber' => |
'parameter:Number of Submissions<br>subnumber', |
'parameter:Number of Tutor Responses<br>tutornumber', |
'tutornumber' => |
'totalpoints' => |
'parameter:Number of Tutor Responses<br>tutornumber', |
'parameter:Total Points Granted<br>totalpoints'); |
'totalpoints' => |
my $adduserstr=''; |
'parameter:Total Points Granted<br>totalpoints'); |
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})){ |
|
$adduserstr='&uname='.$uname.'&udom='.$udom; |
|
} |
|
# |
# |
# allassess holds the descriptions of all assessments |
# assesslist holds the descriptions of all assessments |
my %allassess; |
my %assesslist; |
foreach ('Feedback','Evaluation','Tutoring','Discussion') { |
foreach ('Feedback','Evaluation','Tutoring','Discussion') { |
my $symb = '_'.lc($_); |
my $symb = '_'.lc($_); |
$allassess{$symb} = join(':',('symb',$symb,$uname,$udom,$_)); |
$assesslist{$symb} = join(':',('symb',$symb,$uname,$udom,$_)); |
} |
} |
while (($_,undef) = each(%bighash)) { |
while (($_,undef) = each(%bighash)) { |
next if ($_!~/^src\_(\d+)\.(\d+)$/); |
next if ($_!~/^src\_(\d+)\.(\d+)$/); |
Line 1770 sub updatestudentassesssheet {
|
Line 1776 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}='symb:'.&Apache::lonnet::escape($symb).':' |
$assesslist{$symb}='symb:'.&Apache::lonnet::escape($symb).':' |
.$uname.':'.$udom.':'.$bighash{'title_'.$id}; |
.$uname.':'.$udom.':'.$bighash{'title_'.$id}; |
next if ($stype ne 'assesscalc'); |
next if ($stype ne 'assesscalc'); |
foreach my $key (split(/\,/, |
foreach my $key (split(/\,/, |
Line 1784 sub updatestudentassesssheet {
|
Line 1790 sub updatestudentassesssheet {
|
&Apache::lonnet::metadata($srcf,$key.'.name'); |
&Apache::lonnet::metadata($srcf,$key.'.name'); |
} |
} |
$display.='<br>'.$key; |
$display.='<br>'.$key; |
$allkeys{$key}='parameter:'.$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 1866 sub loadstudent {
|
Line 1874 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 1923 ENDPOP
|
Line 1931 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 ($sname,$sdom) = split(':',$f{$_}); |
'studentcalc'); |
my @studentdata=&exportsheet($sheet,$sname,$sdom,'studentcalc'); |
undef %userrdatas; |
undef %userrdatas; |
$now++; |
$now++; |
$r->print('<script>popwin.document.popremain.remaining.value="'. |
$r->print('<script>popwin.document.popremain.remaining.value="'. |
Line 1935 ENDPOP
|
Line 1943 ENDPOP
|
my $index=0; |
my $index=0; |
foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M', |
foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M', |
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') { |
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') { |
if ($studentdata[$index]) { |
if (defined($studentdata[$index++])) { |
my $col=$_; |
my $col=$_; |
if ($studentdata[$index]=~/\D/) { |
if ($studentdata[$index]=~/\D/) { |
$c{$col.$row}="'".$studentdata[$index]."'"; |
$c{$col.$row}="'".$studentdata[$index]."'"; |
Line 1945 ENDPOP
|
Line 1953 ENDPOP
|
unless ($col eq 'A') { |
unless ($col eq 'A') { |
$f{$col.$row}='import'; |
$f{$col.$row}='import'; |
} |
} |
$index++; |
|
} |
} |
} |
} |
} |
} |
Line 2167 sub forcedrecalc {
|
Line 2174 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 2187 sub exportsheet {
|
Line 2200 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 2215 sub exportsheet {
|
Line 2228 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 2260 sub exportsheet {
|
Line 2272 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 2279 sub exportsheet {
|
Line 2290 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 2300 sub expirationdates {
|
Line 2305 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 2320 sub cachedcsheets {
|
Line 2322 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 2550 ENDSCRIPT
|
Line 2551 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 2598 ENDSCRIPT
|
Line 2599 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; |
} |
} |