--- loncom/interface/Attic/lonspreadsheet.pm 2002/09/10 21:11:23 1.100.2.2 +++ loncom/interface/Attic/lonspreadsheet.pm 2003/03/03 22:00:03 1.173 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.100.2.2 2002/09/10 21:11:23 matthew Exp $ +# $Id: lonspreadsheet.pm,v 1.173 2003/03/03 22:00:03 albertel 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,49 +44,449 @@ not the grades of their peers. The spre 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 =cut + package Apache::lonspreadsheet; use strict; -use Safe; -use Safe::Hole; -use Opcode; -use Apache::lonnet; use Apache::Constants qw(:common :http); -use GDBM_File; -use HTML::TokeParser; +use Apache::lonnet; use Apache::lonhtmlcommon; -# -# Caches for previously calculated spreadsheets -# +use HTML::Entities(); + +# --------------------------------------------------------- Various form fields + +sub textfield { + my ($title,$name,$value)=@_; + return "\n
$title:
".
+ '';
+}
+
+sub hiddenfield {
+ my ($name,$value)=@_;
+ return "\n".'';
+}
+
+sub selectbox {
+ my ($title,$name,$value,%options)=@_;
+ my $selout="\n
$title:
".'';
+}
my %oldsheets;
my %loadedcaches;
-my %expiredates;
+# ================================================================ Main handler
+#
+# Interactive call to screen
#
-# Cache for stores of an individual user
#
+sub handler {
+ my $r=shift;
-my $cachedassess;
-my %cachedstores;
+ my ($sheettype) = ($r->uri=~/\/(\w+)$/);
+ if (! exists($ENV{'form.Status'})) {
+ $ENV{'form.Status'} = 'Active';
+ }
+ if ( ! exists($ENV{'form.output'}) ||
+ ($sheettype ne 'classcalc' &&
+ lc($ENV{'form.output'}) eq 'recursive excel')) {
+ $ENV{'form.output'} = 'HTML';
+ }
+ #
+ # Overload checking
+ #
+ # Check this server
+ my $loaderror=&Apache::lonnet::overloaderror($r);
+ if ($loaderror) { return $loaderror; }
+ # Check the course homeserver
+ $loaderror= &Apache::lonnet::overloaderror($r,
+ $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
+ if ($loaderror) { return $loaderror; }
+ #
+ # HTML Header
+ #
+ if ($r->header_only) {
+ $r->content_type('text/html');
+ $r->send_http_header;
+ return OK;
+ }
+ #
+ # Roles Checking
+ #
+ # Needs to be in a course
+ if (! $ENV{'request.course.fn'}) {
+ # Not in a course, or not allowed to modify parms
+ $ENV{'user.error.msg'}=
+ $r->uri.":opa:0:0:Cannot modify spreadsheet";
+ return HTTP_NOT_ACCEPTABLE;
+ }
+ #
+ # Get query string for limited number of parameters
+ #
+ &Apache::loncommon::get_unprocessed_cgi
+ ($ENV{'QUERY_STRING'},['uname','udom','usymb','ufn','mapid','resid']);
+ #
+ # Deal with restricted student permissions
+ #
+ if ($ENV{'request.role'} =~ /^st\./) {
+ delete $ENV{'form.unewfield'} if (exists($ENV{'form.unewfield'}));
+ delete $ENV{'form.unewformula'} if (exists($ENV{'form.unewformula'}));
+ }
+ #
+ # Look for special assessment spreadsheets - '_feedback', etc.
+ #
+ if (($ENV{'form.usymb'}=~/^\_(\w+)/) && (!$ENV{'form.ufn'} ||
+ $ENV{'form.ufn'} eq '' ||
+ $ENV{'form.ufn'} eq 'default')) {
+ $ENV{'form.ufn'}='default_'.$1;
+ }
+ if (!$ENV{'form.ufn'} || $ENV{'form.ufn'} eq 'default') {
+ $ENV{'form.ufn'}='course_default_'.$sheettype;
+ }
+ #
+ # Interactive loading of specific sheet?
+ #
+ if (($ENV{'form.load'}) && ($ENV{'form.loadthissheet'} ne 'Default')) {
+ $ENV{'form.ufn'}=$ENV{'form.loadthissheet'};
+ }
+ #
+ # Determine the user name and domain for the sheet.
+ my $aname;
+ my $adom;
+ unless ($ENV{'form.uname'}) {
+ $aname=$ENV{'user.name'};
+ $adom=$ENV{'user.domain'};
+ } else {
+ $aname=$ENV{'form.uname'};
+ $adom=$ENV{'form.udom'};
+ }
+ #
+ # Open page, try to prevent browser cache.
+ #
+ $r->content_type('text/html');
+ $r->header_out('Cache-control','no-cache');
+ $r->header_out('Pragma','no-cache');
+ $r->send_http_header;
+ #
+ # Header....
+ #
+ $r->print('