[LON-CAPA-cvs] cvs: loncom /interface lonstatistics.pm /interface/statistics lonstathelpers.pm lonstudentassessment.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Mon, 21 Mar 2005 19:47:54 -0000
This is a MIME encoded message
--matthew1111434474
Content-Type: text/plain
matthew Mon Mar 21 14:47:54 2005 EDT
Modified files:
/loncom/interface lonstatistics.pm
/loncom/interface/statistics lonstathelpers.pm
lonstudentassessment.pm
Log:
lonstatistics.pm: Modified §ion_and_enrollment_description to take a 'mode'
lonstathelpers.pm: removed §ions_description
lonstudentassessment.pm: Use &Apache::loncommon::create_text_file and
&Apache::lonstatistics::section_and_enrollment_description.
--matthew1111434474
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20050321144754.txt"
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.121 loncom/interface/lonstatistics.pm:1.122
--- loncom/interface/lonstatistics.pm:1.121 Thu Mar 17 19:19:35 2005
+++ loncom/interface/lonstatistics.pm Mon Mar 21 14:47:53 2005
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstatistics.pm,v 1.121 2005/03/18 00:19:35 matthew Exp $
+# $Id: lonstatistics.pm,v 1.122 2005/03/21 19:47:53 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -359,24 +359,57 @@
=item §ion_and_enrollment_description
+Returns a string describing the currenly selected section(s) and
+enrollment status.
+
+Inputs: mode = 'plaintext' or 'localized' (defaults to 'localized')
+ 'plaintext' is used for example in Excel spreadsheets.
+Returns: scalar description string.
+
=cut
#######################################################
#######################################################
sub section_and_enrollment_description {
+ my ($mode) = @_;
+ if (! defined($mode)) { $mode = 'localized'; }
my @sections = &Apache::lonstatistics::get_selected_sections();
- my $description = &mt('Unable to determine section and enrollment');
+ my $description;
+ if ($mode eq 'localized') {
+ $description = &mt('Unable to determine section and enrollment');
+ } elsif ($mode eq 'plaintext') {
+ $description = 'Unable to determine section and enrollment';
+ } else {
+ $description = 'Bad parameter passed to lonstatistics::section_and_enrollment_description';
+ &Apache::lonnet::logthis($description);
+ }
if (scalar(@sections) == 1 && $sections[0] ne 'all') {
- $description = &mt('Section [_1]. [_2] enrollment status.',
- $sections[0],$ENV{'form.Status'});
+ if ($mode eq 'localized') {
+ $description = &mt('Section [_1]. [_2] enrollment status.',
+ $sections[0],$ENV{'form.Status'});
+ } elsif ($mode eq 'plaintext') {
+ $description = 'Section '.$sections[0].'. '.
+ $ENV{'form.Status'}.' enrollment status.';
+ }
} elsif (scalar(@sections) && $sections[0] eq 'all') {
- $description = &mt('All sections. [_1] enrollment status.',
- $ENV{'form.Status'});
+ if ($mode eq 'localized') {
+ $description = &mt('All sections. [_1] enrollment status.',
+ $ENV{'form.Status'});
+ } elsif ($mode eq 'plaintext') {
+ $description = 'All sections. '.
+ $ENV{'form.Status'}.' enrollment status.';
+ }
} elsif (scalar(@sections)) {
my $lastsection = pop(@sections);
- $description = &mt('Sections [_1] and [_2]. [_3] enrollment status.',
- join(', ',@sections),$lastsection,
- $ENV{'form.Status'});
+ if ($mode eq 'localized') {
+ $description = &mt('Sections [_1] and [_2]. [_3] enrollment status.',
+ join(', ',@sections),$lastsection,
+ $ENV{'form.Status'});
+ } elsif ($mode eq 'plaintext') {
+ $description =
+ 'Sections '.join(', ',@sections).' and '.$lastsection.'. '.
+ $ENV{'form.Status'}.' enrollment status.';
+ }
}
return $description;
}
Index: loncom/interface/statistics/lonstathelpers.pm
diff -u loncom/interface/statistics/lonstathelpers.pm:1.44 loncom/interface/statistics/lonstathelpers.pm:1.45
--- loncom/interface/statistics/lonstathelpers.pm:1.44 Mon Mar 14 15:28:22 2005
+++ loncom/interface/statistics/lonstathelpers.pm Mon Mar 21 14:47:54 2005
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstathelpers.pm,v 1.44 2005/03/14 20:28:22 matthew Exp $
+# $Id: lonstathelpers.pm,v 1.45 2005/03/21 19:47:54 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1281,43 +1281,6 @@
return ($starttime,$endtime);
}
-
-
-####################################################
-####################################################
-
-=pod
-
-=item sections_description
-
-Inputs: @Sections, an array of sections
-
-Returns: A plaintext description of the sections selected.
-
-=cut
-
-####################################################
-####################################################
-sub sections_description {
- my @Sections = @_;
- my $sectionstring = '';
- if (scalar(@Sections) > 1) {
- if (scalar(@Sections) > 2) {
- my $last = pop(@Sections);
- $sectionstring = "Sections ".join(', ',@Sections).', and '.$last;
- } else {
- $sectionstring = "Sections ".join(' and ',@Sections);
- }
- } else {
- if ($Sections[0] eq 'all') {
- $sectionstring = "All sections";
- } else {
- $sectionstring = "Section ".$Sections[0];
- }
- }
- return $sectionstring;
-}
-
####################################################
####################################################
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.119 loncom/interface/statistics/lonstudentassessment.pm:1.120
--- loncom/interface/statistics/lonstudentassessment.pm:1.119 Mon Mar 14 15:28:22 2005
+++ loncom/interface/statistics/lonstudentassessment.pm Mon Mar 21 14:47:54 2005
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstudentassessment.pm,v 1.119 2005/03/14 20:28:22 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.120 2005/03/21 19:47:54 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -353,7 +353,7 @@
&mt('Clear Caches').'" />';
$Str .= ' 'x5;
$Str .=
- &mt('Status[_1]',
+ &mt('Status [_1]',
'<input type="text" name="stats_status" size="60" value="" />');
$Str .= '<br />';
return $Str;
@@ -1052,23 +1052,9 @@
# Put a description of the sections listed
my $sectionstring = '';
my @Sections = &Apache::lonstatistics::get_selected_sections();
- if (scalar(@Sections) > 1) {
- if (scalar(@Sections) > 2) {
- my $last = pop(@Sections);
- $sectionstring = "Sections ".join(', ',@Sections).', and '.$last;
- } else {
- $sectionstring = "Sections ".join(' and ',@Sections);
- }
- } else {
- if ($Sections[0] eq 'all') {
- $sectionstring = "All sections";
- } else {
- $sectionstring = "Section ".$Sections[0];
- }
- }
- $excel_sheet->write($header_row,$cols_output++,$sectionstring,
+ $excel_sheet->write($header_row,$cols_output++,
+ &Apache::lonstatistics::section_and_enrollment_description('plain text'),
$format->{'h3'});
- $cols_output += scalar(@Sections);
#
# Put the date in there too
$excel_sheet->write($header_row,$cols_output++,
@@ -1559,22 +1545,18 @@
'inline',undef,'Statistics','stats_status');
#
# Open a file
- $filename = '/prtspool/'.
- $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
- time.'_'.rand(1000000000).'.csv';
- unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {
- $r->log_error("Couldn't open $filename for output $!");
- $r->print("Problems occured in writing the csv file. ".
- "This error has been logged. ".
- "Please alert your LON-CAPA administrator.");
- $outputfile = undef;
- }
+ ($outputfile,$filename) = &Apache::loncommon::create_text_file($r,'csv');
+ if (! defined($outputfile)) { return ''; }
#
# Datestamp
my $description = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
print $outputfile '"'.&Apache::loncommon::csv_translate($description).'",'.
'"'.&Apache::loncommon::csv_translate(scalar(localtime(time))).'"'.
"\n";
+ print $outputfile '"'.
+ &Apache::loncommon::csv_translate
+ (&Apache::lonstatistics::section_and_enrollment_description()).
+ '"'."\n";
foreach my $item ('shortdesc','non_html_notes') {
next if (! exists($chosen_output->{$item}));
print $outputfile
--matthew1111434474--