version 1.22, 2000/12/30 21:33:11
|
version 1.23, 2001/01/01 16:16:08
|
Line 2
|
Line 2
|
# Spreadsheet/Grades Display Handler |
# Spreadsheet/Grades Display Handler |
# |
# |
# 11/11,11/15,11/27,12/04,12/05,12/06,12/07, |
# 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 Gerd Kortemeyer |
# 12/08,12/09,12/11,12/12,12/15,12/16,12/18,12/19,12/30, |
|
# 01/01/01 Gerd Kortemeyer |
|
|
package Apache::lonspreadsheet; |
package Apache::lonspreadsheet; |
|
|
Line 803 sub parmval {
|
Line 804 sub parmval {
|
|
|
} |
} |
|
|
|
# ---------------------------------------------- Update rows for course listing |
|
|
|
sub updatestudentrows { |
|
my $safeeval=shift; |
|
my $cid=$ENV{'request.course.id'}; |
|
my $classlst=&Apache::lonnet::reply |
|
('dump:'.$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}.':classlist', |
|
$ENV{'course.'.$cid.'.home'}); |
|
my %currentlist=(); |
|
my $now=time; |
|
unless ($classlst=~/^error\:/) { |
|
map { |
|
my ($name,$value)=split(/\=/,$_); |
|
my ($end,$start)=split(/\_/,&Apache::lonnet::unescape($value)); |
|
my $active=1; |
|
if (($end) && ($now>$end)) { $active=0; } |
|
if ($active) { |
|
$currentlist{&Apache::lonnet::unescape($name)}=1; |
|
} |
|
} split(/\&/,$classlst); |
|
# |
|
# -------------------- Find discrepancies between the course row table and this |
|
# |
|
my %f=&getformulas($safeeval); |
|
my $changed=0; |
|
|
|
my $maxrow=0; |
|
my %existing=(); |
|
|
|
# ----------------------------------------------------------- Now obsolete rows |
|
map { |
|
if ($_=~/^A(\d+)/) { |
|
$maxrow=($1>$maxrow)?$1:$maxrow; |
|
$existing{$f{$_}}=1; |
|
unless ((defined($currentlist{$f{$_}})) || (!$1)) { |
|
$f{$_}='!!! Obsolete'; |
|
$changed=1; |
|
} |
|
} |
|
} keys %f; |
|
|
|
# -------------------------------------------------------- New and unknown keys |
|
|
|
map { |
|
unless ($existing{$_}) { |
|
$changed=1; |
|
$maxrow++; |
|
$f{'A'.$maxrow}=$_; |
|
} |
|
} keys %currentlist; |
|
|
|
if ($changed) { &setformulas($safeeval,%f); } |
|
|
|
&setmaxrow($safeeval,$maxrow); |
|
&setrowlabels($safeeval,%currentlist); |
|
|
|
} else { |
|
return 'Could not access course data'; |
|
} |
|
} |
# ----------------------------------------------------------------- Update rows |
# ----------------------------------------------------------------- Update rows |
|
|
sub updaterows { |
sub updaterows { |
Line 1152 ENDSCRIPT
|
Line 1213 ENDSCRIPT
|
$ENV{'form.ufn'}=&getfilename($sheetone); |
$ENV{'form.ufn'}=&getfilename($sheetone); |
} |
} |
|
|
# --------------------------------------------- See if all import rows uptodate |
if (&gettype($sheetone) eq 'classcalc') { |
|
# ---------------------------------- For course view: get courselist and update |
|
&updatestudentrows($sheetone); |
|
} else { |
|
# ----------------- For assessment and student: See if all import rows uptodate |
|
|
if (tie(%parmhash,'GDBM_File', |
if (tie(%parmhash,'GDBM_File', |
$ENV{'request.course.fn'}.'_parms.db',&GDBM_READER,0640)) { |
$ENV{'request.course.fn'}.'_parms.db',&GDBM_READER,0640)) { |
Line 1167 ENDSCRIPT
|
Line 1232 ENDSCRIPT
|
$r->print('<h3><font color=red>'. |
$r->print('<h3><font color=red>'. |
'Could not initialize import fields (not in a course)</font></h3>'); |
'Could not initialize import fields (not in a course)</font></h3>'); |
} |
} |
|
} |
# ---------------------------------------------------- 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'})) { |
my $fname=''; |
my $fname=''; |
Line 1196 ENDSCRIPT
|
Line 1262 ENDSCRIPT
|
$r->print('<input type=submit name=saveas value="Save as ...">'. |
$r->print('<input type=submit name=saveas value="Save as ...">'. |
'<input type=text size=20 name=newfn value="'.$fname.'"><p>'); |
'<input type=text size=20 name=newfn value="'.$fname.'"><p>'); |
} |
} |
$r->print(&hiddenfield('ufn',$ENV{'form.ufn'}). |
$r->print(&hiddenfield('ufn',$ENV{'form.ufn'})); |
"<b>User '$uname' at domain '$udom' for '". |
unless (&gettype($sheetone) eq 'classcalc') { |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}."'"); |
$r->print('<br><b>User:</b> '.$uname.'<br><b>Domain:</b> '.$udom); |
|
} |
|
$r->print('<h1>'. |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.'</h1>'); |
if ($csec) { |
if ($csec) { |
$r->print(", group/section '$csec'"); |
$r->print('<h3>Group/Section: '.$csec.'</h3>'); |
} |
} |
$r->print("</b>\n"); |
|
} |
} |
# -------------------------------------------------------- Import and calculate |
# -------------------------------------------------------- Import and calculate |
|
|