[LON-CAPA-cvs] cvs: loncom(fixes_0_5) /interface lonspreadsheet.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Fri, 27 Sep 2002 18:43:10 -0000
matthew Fri Sep 27 14:43:10 2002 EDT
Modified files: (Branch: fixes_0_5)
/loncom/interface lonspreadsheet.pm
Log:
Backport of fix to disallow student editing of spreadsheet.
Pick up changes from 1.100.0.2 (caching bug fix, section = -1 misunderstanding)
because I chose the wrong revision to branch off of :(.
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.100 loncom/interface/lonspreadsheet.pm:1.100.4.1
--- loncom/interface/lonspreadsheet.pm:1.100 Fri Aug 16 14:25:24 2002
+++ loncom/interface/lonspreadsheet.pm Fri Sep 27 14:43:10 2002
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.100 2002/08/16 18:25:24 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.100.4.1 2002/09/27 18:43:10 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1187,9 +1187,14 @@
if ($vl eq '') {
$vl='<font size=+2 color='.$bgcolor.'>#</font>';
}
- $rowdata.=
- '<td bgcolor='.$bgcolor.'><a href="javascript:celledit('.$fm.');">'.$vl.
- '</a></td>';
+ $rowdata.='<td bgcolor='.$bgcolor.'>';
+ if ($ENV{'request.role'} =~ /^st\./) {
+ $rowdata.=$vl;
+ } else {
+ $rowdata.='<a href="javascript:celledit('.$fm.');">'.
+ $vl.'</a>';
+ }
+ $rowdata.='</td>';
} else {
$rowdata.='<td bgcolor='.$bgcolor.'> '.$vl.' </td>';
}
@@ -1667,15 +1672,15 @@
$name=&Apache::lonnet::unescape($name);
my ($sname,$sdom)=split(/\:/,$name);
my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
- if ($ssec==-1) {
- unless ($ENV{'form.showcsv'}) {
- $rowlabel='<font color=red>Data not available: '.$name.
- '</font>';
- } else {
- $rowlabel='ERROR","'.$name.
- '","Data not available","","","';
- }
- } else {
+# if ($ssec==-1) {
+# unless ($ENV{'form.showcsv'}) {
+# $rowlabel='<font color=red>Data not available: '.$name.
+# '</font>';
+# } else {
+# $rowlabel='ERROR","'.$name.
+# '","Data not available","","","';
+# }
+# } else {
my %reply=&Apache::lonnet::idrget($sdom,$sname);
my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname.
':environment:firstname&middlename&lastname&generation',
@@ -1698,7 +1703,7 @@
unless ($ncount==4) { $rowlabel.=',""'; }
$rowlabel=~s/\"$//;
}
- }
+# }
$currentlist{&Apache::lonnet::unescape($name)}=$rowlabel;
}
} # end of foreach (split(/\&/,$classlst))
@@ -1750,8 +1755,11 @@
my $safeeval=shift;
my %bighash;
my $stype=&gettype($safeeval);
+ my $uname=&getuname($safeeval);
+ my $udom =&getudom($safeeval);
my %current=();
- unless ($updatedata{$ENV{'request.course.fn'}.'_'.$stype}) {
+ unless ($updatedata{
+ $ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}) {
# -------------------------------------------------------------------- Tie hash
if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
&GDBM_READER(),0640)) {
@@ -1832,7 +1840,7 @@
} elsif ($stype eq 'studentcalc') {
%current=%allassess;
}
- $updatedata{$ENV{'request.course.fn'}.'_'.$stype}=
+ $updatedata{$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom}=
join('___;___',%current);
} else {
return 'Could not access course data';
@@ -1840,7 +1848,7 @@
# ------------------------------------------------------ Get current from cache
} else {
%current=split(/\_\_\_\;\_\_\_/,
- $updatedata{$ENV{'request.course.fn'}.'_'.$stype});
+ $updatedata{$ENV{'request.course.fn'}.'_'.$stype.'_'.$uname.'_'.$udom});
}
# -------------------- Find discrepancies between the course row table and this
#
@@ -2458,6 +2466,11 @@
return OK;
}
+ if ($ENV{'request.role'} =~ /^st\./) {
+ delete $ENV{'form.unewfield'} if (exists($ENV{'form.unewfield'}));
+ delete $ENV{'form.unewformula'} if (exists($ENV{'form.unewformula'}));
+ }
+
# ---------------------------------------------------- Global directory configs
$includedir=$r->dir_config('lonIncludes');
@@ -2503,7 +2516,8 @@
# --------------------------------------------------------------- Screen output
$r->print('<html><head><title>LON-CAPA Spreadsheet</title>');
- $r->print(<<ENDSCRIPT);
+ if ($ENV{'request.role'} !~ /^st\./) {
+ $r->print(<<ENDSCRIPT);
<script language="JavaScript">
function celledit(cn,cf) {
@@ -2529,6 +2543,7 @@
</script>
ENDSCRIPT
+ }
$r->print('</head><body bgcolor="#FFFFFF">'.
'<img align=right src=/adm/lonIcons/lonlogos.gif>'.
'<h1>LON-CAPA Spreadsheet</h1>'.
@@ -2584,12 +2599,12 @@
unless (&gettype($asheet) eq 'classcalc') {
$r->print('<p><b>User:</b> '.&getuname($asheet).
'<br><b>Domain:</b> '.&getudom($asheet));
- 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> '.&getcsec($asheet));
- }
+# }
if ($ENV{'form.usymb'}) {
$r->print('<br><b>Assessment:</b> <tt>'.$ENV{'form.usymb'}.'</tt>');
}