version 1.37, 2004/03/31 05:24:00
|
version 1.40, 2005/03/10 17:33:57
|
Line 86 sub new {
|
Line 86 sub new {
|
my ($stype) = ($class =~ /Apache::(.*)$/); |
my ($stype) = ($class =~ /Apache::(.*)$/); |
# |
# |
my ($name,$domain,$filename,$usymb)=@_; |
my ($name,$domain,$filename,$usymb)=@_; |
|
if (defined($usymb) && ref($usymb)) { |
|
$usymb = $usymb->symb; |
|
} |
if (! defined($name) || $name eq '') { |
if (! defined($name) || $name eq '') { |
$name = $ENV{'user.name'}; |
$name = $ENV{'user.name'}; |
} |
} |
Line 313 Returns the safe space required by a Spr
|
Line 316 Returns the safe space required by a Spr
|
|
|
sub initialize_safe_space { |
sub initialize_safe_space { |
my $self = shift; |
my $self = shift; |
|
my $usection = &Apache::lonnet::getsection($self->{'domain'}, |
|
$self->{'name'}, |
|
$ENV{'request.course.id'}); |
if (! defined($safeeval)) { |
if (! defined($safeeval)) { |
$safeeval = new Safe(shift); |
$safeeval = new Safe(shift); |
my $safehole = new Safe::Hole; |
my $safehole = new Safe::Hole; |
Line 320 sub initialize_safe_space {
|
Line 326 sub initialize_safe_space {
|
$safeeval->permit(":base_math"); |
$safeeval->permit(":base_math"); |
$safeeval->permit("sort"); |
$safeeval->permit("sort"); |
$safeeval->deny(":base_io"); |
$safeeval->deny(":base_io"); |
$safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT'); |
$safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&Apache::lonnet::EXT'); |
$safehole->wrap(\&mask,$safeeval,'&mask'); |
$safehole->wrap(\&mask,$safeeval,'&mask'); |
$safeeval->share('$@'); |
$safeeval->share('$@'); |
my $code=<<'ENDDEFS'; |
my $code=<<'ENDDEFS'; |
Line 379 $errormsg = '';
|
Line 385 $errormsg = '';
|
|
|
=pod |
=pod |
|
|
|
=item EXT(parameter) |
|
|
|
Calls the system EXT function to determine the value of the given parameter. |
|
|
|
=cut |
|
|
|
#------------------------------------------------------- |
|
sub EXT { |
|
my ($parameter) = @_; |
|
return '' if (! defined($parameter) || $parameter eq ''); |
|
$parameter =~ s/^parameter\./resource\./; |
|
my $value = &Apache::lonnet::EXT($parameter,$symb,$domain,$name,$usection); |
|
return $value; |
|
} |
|
|
|
#------------------------------------------------------- |
|
|
|
=pod |
|
|
=item NUM(range) |
=item NUM(range) |
|
|
returns the number of items in the range. |
returns the number of items in the range. |
Line 696 ENDDEFS
|
Line 721 ENDDEFS
|
# Place some of the %$self items into the safe space except the safe space |
# Place some of the %$self items into the safe space except the safe space |
# itself |
# itself |
my $initstring = ''; |
my $initstring = ''; |
foreach (qw/name domain type usymb cid csec coursefilename |
foreach (qw/name domain type symb cid csec coursefilename |
cnum cdom chome uhome/) { |
cnum cdom chome uhome/) { |
$initstring.= qq{\$$_="$self->{$_}";}; |
$initstring.= qq{\$$_="$self->{$_}";}; |
} |
} |
|
$initstring.=qq{\$usection="$usection";}; |
$self->{'safe'}->reval($initstring); |
$self->{'safe'}->reval($initstring); |
return $self; |
return $self; |
} |
} |
Line 1407 sub excel_output_row {
|
Line 1433 sub excel_output_row {
|
return; |
return; |
} |
} |
|
|
sub create_excel_spreadsheet { |
|
my $self = shift; |
|
my ($r) = @_; |
|
my $filename = '/prtspool/'. |
|
$ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. |
|
time.'_'.rand(1000000000).'.xls'; |
|
my $workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename); |
|
if (! defined($workbook)) { |
|
$r->log_error("Error creating excel spreadsheet $filename: $!"); |
|
$r->print(&mt("Problems creating new Excel file. ". |
|
"This error has been logged. ". |
|
"Please alert your LON-CAPA administrator")); |
|
return undef; |
|
} |
|
# |
|
# The excel spreadsheet stores temporary data in files, then put them |
|
# together. If needed we should be able to disable this (memory only). |
|
# The temporary directory must be specified before calling 'addworksheet'. |
|
# File::Temp is used to determine the temporary directory. |
|
$workbook->set_tempdir('/home/httpd/perl/tmp'); |
|
# |
|
# Determine the name to give the worksheet |
|
return ($workbook,$filename); |
|
} |
|
|
|
# |
# |
# This routine is just a stub |
# This routine is just a stub |
sub outsheet_htmlclasslist { |
sub outsheet_htmlclasslist { |
Line 1452 sub outsheet_excel {
|
Line 1453 sub outsheet_excel {
|
# |
# |
$r->print("<h2>".&mt('Preparing Excel Spreadsheet')."</h2>"); |
$r->print("<h2>".&mt('Preparing Excel Spreadsheet')."</h2>"); |
# |
# |
# Create excel worksheet |
# Create excel workbook |
my ($workbook,$filename) = $self->create_excel_spreadsheet($r); |
my ($workbook,$filename,$format)=&Apache::loncommon::create_workbook($r); |
return if (! defined($workbook)); |
return if (! defined($workbook)); |
# |
# |
# Create main worksheet |
# Create main worksheet |
Line 1464 sub outsheet_excel {
|
Line 1465 sub outsheet_excel {
|
# Write excel header |
# Write excel header |
foreach my $value ($self->get_title()) { |
foreach my $value ($self->get_title()) { |
$cols_output = 0; |
$cols_output = 0; |
$worksheet->write($rows_output++,$cols_output,$value); |
$worksheet->write($rows_output++,$cols_output,$value,$format->{'h1'}); |
} |
} |
$rows_output++; # skip a line |
$rows_output++; # skip a line |
# |
# |
# Write summary/export row |
# Write summary/export row |
$cols_output = 0; |
$cols_output = 0; |
$self->excel_output_row($worksheet,0,$rows_output++,'Summary'); |
$self->excel_output_row($worksheet,0,$rows_output++,'Summary', |
|
$format->{'b'}); |
$rows_output++; # skip a line |
$rows_output++; # skip a line |
# |
# |
$self->excel_rows($connection,$worksheet,$cols_output,$rows_output); |
$self->excel_rows($connection,$worksheet,$cols_output,$rows_output, |
|
$format); |
# |
# |
# |
# |
# Close the excel file |
# Close the excel file |