--- loncom/interface/spreadsheet/studentcalc.pm 2003/05/16 20:55:11 1.1
+++ loncom/interface/spreadsheet/studentcalc.pm 2003/05/23 19:36:04 1.6
@@ -1,5 +1,5 @@
#
-# $Id: studentcalc.pm,v 1.1 2003/05/16 20:55:11 matthew Exp $
+# $Id: studentcalc.pm,v 1.6 2003/05/23 19:36:04 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -48,9 +48,11 @@ package Apache::studentcalc;
use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet;
+use Apache::loncommon();
+use Apache::loncoursedata();
use Apache::lonnavmaps;
-use Apache::Spreadsheet;
-use Apache::assesscalc;
+use Apache::Spreadsheet();
+use Apache::assesscalc();
use HTML::Entities();
use Spreadsheet::WriteExcel;
use Time::HiRes;
@@ -76,7 +78,7 @@ sub initialize_sequence_cache {
&Apache::loncoursedata::get_sequence_assessment_data();
if (! defined($top) || ! ref($top)) {
# There has been an error, better report it
- &Apache::lonnet::logthis('top is undefined');
+ &Apache::lonnet::logthis('top is undefined (studentcalc.pm)');
return;
}
@Sequences = @{$sequences} if (ref($sequences) eq 'ARRAY');
@@ -89,9 +91,34 @@ sub clear_package {
sub get_title {
my $self = shift;
- my $title = '';
- $title .= '
Spreadsheet for '.
- $self->{'name'}.'@'.$self->{'domain'}.'
';
+ my @title = ();
+ #
+ # Determine the students name
+ my %userenv = &Apache::loncoursedata::GetUserName($self->{'name'},
+ $self->{'domain'});
+ my $name = join(' ',
+ @userenv{'firstname','middlename','lastname','generation'});
+ $name =~ s/\s+$//;
+
+ push (@title,$name);
+ push (@title,$self->{'coursedesc'});
+ push (@title,scalar(localtime(time)));
+ return @title;
+}
+
+sub get_html_title {
+ my $self = shift;
+ my ($name,$desc,$time) = $self->get_title();
+ my $title = '
'.$name;
+ if ($ENV{'user.name'} ne $self->{'name'} &&
+ $ENV{'user.domain'} ne $self->{'domain'}) {
+ $title .= &Apache::loncommon::aboutmewrapper
+ ($self->{'name'}.'@'.$self->{'domain'},
+ $self->{'name'},$self->{'domain'});
+ }
+ $title .= "
\n";
+ $title .= '
'.$desc."
\n";
+ $title .= '
'.$time.'
';
return $title;
}
@@ -111,12 +138,15 @@ sub outsheet_html {
# Get the list of assessment files #
####################################
my @AssessFileNames = $self->othersheets('assesscalc');
+ my $editing_is_allowed = &Apache::lonnet::allowed('mgr',
+ $ENV{'request.course.id'});
####################################
# Determine table structure #
####################################
my $num_uneditable = 26;
my $num_left = 52-$num_uneditable;
my $tableheader =<<"END";
+
Student
@@ -137,23 +167,40 @@ END
$label_num++;
}
$tableheader .="
\n");
#
# Prepare to output rows
- $tableheader =<<"END";
+ if (exists($ENV{'request.role.adv'}) && $ENV{'request.role.adv'}) {
+ $tableheader =<<"END";
+
Row
Assessment
END
+ } else {
+ $tableheader =<<"END";
+
+
+
Assessment
+END
+ }
foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){
if ($label_num<$num_uneditable) {
$tableheader.='
';
@@ -176,22 +223,37 @@ END
next if ($resource->{'type'} ne 'assessment');
my $rownum = $self->get_row_number_from_key($resource->{'symb'});
my $assess_filename = $self->{'row_source'}->{$rownum};
- my $row_output = '