[LON-CAPA-cvs] cvs: loncom /interface lonspreadsheet.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Tue, 10 Sep 2002 19:04:13 -0000
This is a MIME encoded message
--matthew1031684653
Content-Type: text/plain
matthew Tue Sep 10 15:04:13 2002 EDT
Modified files:
/loncom/interface lonspreadsheet.pm
Log:
A few changes.
changed $cfn to $coursefilename
commented out code that thought &Apache::lonnet::usection returned -1 if
the user was not in the course. It returns -1 if the user has no section
listed or if they are not in the course.
Minor reformatting where we get the user data, no code changes at all (yet).
A little more removing &gettype and other calls into ths safe space.
--matthew1031684653
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20020910150413.txt"
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.108 loncom/interface/lonspreadsheet.pm:1.109
--- loncom/interface/lonspreadsheet.pm:1.108 Mon Sep 9 13:18:33 2002
+++ loncom/interface/lonspreadsheet.pm Tue Sep 10 15:04:13 2002
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.108 2002/09/09 17:18:33 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.109 2002/09/10 19:04:13 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,16 +26,6 @@
# The LearningOnline Network with CAPA
# Spreadsheet/Grades Display Handler
#
-# 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,
-# 01/01/01,02/01,03/01,19/01,20/01,22/01,
-# 03/05,03/08,03/10,03/12,03/13,03/15,03/17,
-# 03/19,03/20,03/21,03/27,04/05,04/09,
-# 07/09,07/14,07/21,09/01,09/10,9/11,9/12,9/13,9/14,9/17,
-# 10/16,10/17,10/20,11/05,11/28,12/27 Gerd Kortemeyer
-# 01/14/02 Matthew
-# 02/04/02 Matthew
-
# POD required stuff:
=head1 NAME
@@ -54,7 +44,6 @@
offering the ability to use Perl code to manipulate data, as well as many
built-in functions.
-
=head2 Functions available to user of lonspreadsheet
=over 4
@@ -167,7 +156,7 @@
$cnum = '';
$cdom = '';
$cid = '';
-$cfn = '';
+$coursefilename = '';
# symb
@@ -1111,9 +1100,9 @@
# --------------------------------------------------------- Get course filename
-sub getcfn {
+sub getcoursefilename {
my $safeeval=shift;
- return $safeeval->reval('$cfn');
+ return $safeeval->reval('$coursefilename');
}
# ----------------------------------------------------------- Get course number
@@ -1393,7 +1382,6 @@
#
# -------------------------------------- Read spreadsheet formulas for a course
#
-
sub readsheet {
my ($safeeval,$sheetdata,$fn)=@_;
#
@@ -1465,7 +1453,6 @@
}
# -------------------------------------------------------- Make new spreadsheet
-
sub makenewsheet {
my ($uname,$udom,$stype,$usymb)=@_;
my %sheetdata=();
@@ -1476,7 +1463,7 @@
$sheetdata{'cid'} = $ENV{'request.course.id'};
$sheetdata{'csec'} = &Apache::lonnet::usection
($udom,$uname,$ENV{'request.course.id'});
- $sheetdata{'cfn'} = $ENV{'request.course.fn'};
+ $sheetdata{'coursefilename'} = $ENV{'request.course.fn'};
$sheetdata{'cnum'} = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
$sheetdata{'cdom'} = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
$sheetdata{'chome'} = $ENV{'course.'.$ENV{'request.course.id'}.'.home'};
@@ -1492,7 +1479,6 @@
}
# ------------------------------------------------------------ Save spreadsheet
-
sub writesheet {
my ($safeeval,$makedef)=@_;
my $cid=&getcid($safeeval);
@@ -1544,7 +1530,6 @@
# ----------------------------------------------- Make a temp copy of the sheet
# "Modified workcopy" - interactive only
#
-
sub tmpwrite {
my $safeeval=shift;
my $fn=$ENV{'user.name'}.'_'.
@@ -1559,7 +1544,6 @@
}
# ---------------------------------------------------------- Read the temp copy
-
sub tmpread {
my ($safeeval,$nfield,$nform)=@_;
my $fn=$ENV{'user.name'}.'_'.
@@ -1709,15 +1693,15 @@
my ($studentName,$studentDomain)=split(/\:/,$student);
my $studentSection=&Apache::lonnet::usection($studentDomain,
$studentName,$cid);
- if ($studentSection==-1) {
- unless ($ENV{'form.showcsv'}) {
- $rowlabel='<font color=red>Data not available: '.
- $studentName.'</font>';
- } else {
- $rowlabel='ERROR","'.$studentName.
- '","Data not available","","","';
- }
- } else {
+# if ($studentSection==-1) {
+# unless ($ENV{'form.showcsv'}) {
+# $rowlabel='<font color=red>Data not available: '.
+# $studentName.'</font>';
+# } else {
+# $rowlabel='ERROR","'.$studentName.
+# '","Data not available","","","';
+# }
+# } else {
my %reply=&Apache::lonnet::idrget($studentDomain,$studentName);
my %studentInformation=&Apache::lonnet::get
('environment',
@@ -1742,7 +1726,7 @@
$studentInformation{'generation'})
).'"';
}
- }
+ # }
$currentlist{$student}=$rowlabel;
} # end of if ($active)
} # end of foreach my $student (keys(%classlist))
@@ -1956,7 +1940,7 @@
}
# --------------------------------------------------- Load data for one student
-
+#
sub loadcourse {
my ($safeeval,$sheetdata,$r)=@_;
my %c=();
@@ -2018,7 +2002,7 @@
}
# ------------------------------------------------ Load data for one assessment
-
+#
sub loadassessment {
my ($safeeval,$sheetdata)=@_;
@@ -2050,26 +2034,20 @@
#
# restore individual
#
- my $answer=&Apache::lonnet::reply(
- "restore:$udom:$uname:".
- &Apache::lonnet::escape($namespace).":".
- &Apache::lonnet::escape($symb),$uhome);
- foreach (split(/\&/,$answer)) {
- my ($name,$value)=split(/\=/,$_);
- $returnhash{&Apache::lonnet::unescape($name)}=
- &Apache::lonnet::unescape($value);
- }
- my $version;
- for ($version=1;$version<=$returnhash{'version'};$version++) {
+ %returnhash = &Apache::lonnet::restore($symb,$namespace,$udom,$uname);
+ for (my $version=1;$version<=$returnhash{'version'};$version++) {
foreach (split(/\:/,$returnhash{$version.':keys'})) {
$returnhash{$_}=$returnhash{$version.':'.$_};
}
}
}
+ #
# returnhash now has all stores for this resource
# convert all "_" to "." to be able to use libraries, multiparts, etc
+ #
+ # This is dumb. It is also necessary :(
my @oldkeys=keys %returnhash;
-
+ #
foreach (@oldkeys) {
my $name=$_;
my $value=$returnhash{$_};
@@ -2099,15 +2077,14 @@
&Apache::lonnet::unescape($value);
}
# Get userdata (if present)
- unless
- ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) {
- my $reply=
- &Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome);
- if ($reply!~/^error\:/) {
- $userrdatas{$uname.'___'.$udom}=$reply;
- $userrdatas{$uname.'___'.$udom.'.last_cache'}=time;
- }
+ unless ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) {
+ my $reply=
+ &Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome);
+ if ($reply!~/^error\:/) {
+ $userrdatas{$uname.'___'.$udom}=$reply;
+ $userrdatas{$uname.'___'.$udom.'.last_cache'}=time;
}
+ }
foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) {
my ($name,$value)=split(/\=/,$_);
$useropt{$userprefix.&Apache::lonnet::unescape($name)}=
@@ -2129,7 +2106,7 @@
#
my %c=();
if (tie(%parmhash,'GDBM_File',
- &getcfn($safeeval).'_parms.db',&GDBM_READER(),0640)) {
+ &getcoursefilename($safeeval).'_parms.db',&GDBM_READER(),0640)) {
my %f=&getformulas($safeeval);
foreach (keys(%f)) {
next if ($_!~/^A/);
@@ -2549,12 +2526,12 @@
unless ($asheetdata->{'sheettype'} eq 'classcalc') {
$r->print('<p><b>User:</b> '.$asheetdata->{'uname'}.
'<br><b>Domain:</b> '.$asheetdata->{'udom'});
- if (&getcsec($asheet) eq '-1') {
- $r->print('<h3><font color=red>'.
- 'Not a student in this course</font></h3>');
- } else {
+# if (&getcsec($asheet) eq '-1') {
+# $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'}) {
$r->print('<br><b>Assessment:</b> <tt>'.
$ENV{'form.usymb'}.'</tt>');
@@ -2610,7 +2587,7 @@
$r->print('>'.$_.'</option>');
}
$r->print('</select><p>');
- if (&gettype($asheet) eq 'studentcalc') {
+ if ($asheetdata->{'sheettype'} eq 'studentcalc') {
&setothersheets($asheet,&othersheets($asheet,'assesscalc'));
}
}
--matthew1031684653--