version 1.13, 2003/06/23 20:47:00
|
version 1.19, 2003/09/08 18:25:26
|
Line 45 studentcalc
|
Line 45 studentcalc
|
################################################### |
################################################### |
package Apache::studentcalc; |
package Apache::studentcalc; |
|
|
|
use warnings FATAL=>'all'; |
|
no warnings 'uninitialized'; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::lonnet; |
use Apache::lonnet; |
Line 98 sub initialize_sequence_cache {
|
Line 101 sub initialize_sequence_cache {
|
} |
} |
|
|
sub clear_package { |
sub clear_package { |
@Sequences = undef; |
undef(@Sequences); |
%Exportrows = undef; |
undef(%Exportrows); |
|
&Apache::assesscalc::clear_package(); |
} |
} |
|
|
sub get_title { |
sub get_title { |
Line 125 sub get_html_title {
|
Line 129 sub get_html_title {
|
my $title = '<h1>'.$name; |
my $title = '<h1>'.$name; |
if ($ENV{'user.name'} ne $self->{'name'} && |
if ($ENV{'user.name'} ne $self->{'name'} && |
$ENV{'user.domain'} ne $self->{'domain'}) { |
$ENV{'user.domain'} ne $self->{'domain'}) { |
$title .= &Apache::loncommon::aboutmewrapper |
$title .= ' '.&Apache::loncommon::aboutmewrapper |
($self->{'name'}.'@'.$self->{'domain'}, |
($self->{'name'}.'@'.$self->{'domain'}, |
$self->{'name'},$self->{'domain'}); |
$self->{'name'},$self->{'domain'}); |
} |
} |
Line 144 sub parent_link {
|
Line 148 sub parent_link {
|
return $link; |
return $link; |
} |
} |
|
|
|
sub convenience_links { |
|
my $self = shift; |
|
my ($resource) = @_; |
|
my $symb = &Apache::lonnet::escape($resource->{'symb'}); |
|
my $result = <<"END"; |
|
<a href="/adm/grades?symb=$symb&command=submission" target="LONcatInfo"> |
|
<img src="/adm/lonMisc/subm_button.gif" border=0 /> |
|
</a> |
|
<a href="/adm/grades?symb=$symb&command=gradingmenu" target="LONcatInfo"> |
|
<img src="/adm/lonMisc/pgrd_button.gif" border=0 /> |
|
</a> |
|
<a href="/adm/parmset?symb=$symb" target="LONcatInfo"> |
|
<img src="/adm/lonMisc/pprm_button.gif" border=0 /> |
|
</a> |
|
END |
|
return $result; |
|
} |
|
|
sub outsheet_html { |
sub outsheet_html { |
my $self = shift; |
my $self = shift; |
my ($r) = @_; |
my ($r) = @_; |
Line 208 END
|
Line 230 END
|
$tableheader =<<"END"; |
$tableheader =<<"END"; |
</p><p> |
</p><p> |
<table border="2"> |
<table border="2"> |
<tr><th>Row</th><th>Assessment</th> |
<tr><th>Row</th><th> </th><th>Assessment</th> |
END |
END |
} else { |
} else { |
$tableheader =<<"END"; |
$tableheader =<<"END"; |
Line 242 END
|
Line 264 END
|
my $row_output = '<tr>'; |
my $row_output = '<tr>'; |
if ($editing_is_allowed) { |
if ($editing_is_allowed) { |
$row_output .= '<td>'.$rownum.'</td>'; |
$row_output .= '<td>'.$rownum.'</td>'; |
|
$row_output .= '<td>'.$self->convenience_links($resource).'</td>'; |
$row_output .= '<td>'. |
$row_output .= '<td>'. |
'<a href="/adm/assesscalc?sname='.$self->{'name'}. |
'<a href="/adm/assesscalc?sname='.$self->{'name'}. |
'&sdomain='.$self->{'domain'}. |
'&sdomain='.$self->{'domain'}. |
Line 392 sub outsheet_recursive_excel {
|
Line 415 sub outsheet_recursive_excel {
|
|
|
sub compute { |
sub compute { |
my $self = shift; |
my $self = shift; |
$self->logthis('computing'); |
my ($r) = @_; |
|
my $connection = $r->connection(); |
|
if ($connection->aborted()) { $self->cleanup; return; } |
if (! defined($current_course) || |
if (! defined($current_course) || |
$current_course ne $ENV{'request.course.id'}) { |
$current_course ne $ENV{'request.course.id'}) { |
$current_course = $ENV{'request.course.id'}; |
$current_course = $ENV{'request.course.id'}; |
Line 419 sub compute {
|
Line 444 sub compute {
|
foreach my $seq (@sequences) { |
foreach my $seq (@sequences) { |
next if ($seq->{'num_assess'}<1); |
next if ($seq->{'num_assess'}<1); |
foreach my $resource (@{$seq->{'contents'}}) { |
foreach my $resource (@{$seq->{'contents'}}) { |
|
if ($connection->aborted()) { $self->cleanup(); return; } |
next if ($resource->{'type'} ne 'assessment'); |
next if ($resource->{'type'} ne 'assessment'); |
my $rownum = $self->get_row_number_from_key($resource->{'symb'}); |
my $rownum = $self->get_row_number_from_key($resource->{'symb'}); |
my $cell = 'A'.$rownum; |
my $cell = 'A'.$rownum; |
Line 429 sub compute {
|
Line 455 sub compute {
|
$self->{'row_source'}->{$rownum} = $assess_filename; |
$self->{'row_source'}->{$rownum} = $assess_filename; |
} |
} |
$f{$cell} = $resource->{'symb'}.'__&&&__'.$assess_filename; |
$f{$cell} = $resource->{'symb'}.'__&&&__'.$assess_filename; |
|
if ($connection->aborted()) { $self->cleanup(); return; } |
my $assessSheet = Apache::assesscalc->new($self->{'name'}, |
my $assessSheet = Apache::assesscalc->new($self->{'name'}, |
$self->{'domain'}, |
$self->{'domain'}, |
$assess_filename, |
$assess_filename, |
$resource->{'symb'}); |
$resource->{'symb'}); |
my @exportdata = $assessSheet->export_data(); |
my @exportdata = $assessSheet->export_data($r); |
|
if ($connection->aborted()) { $self->cleanup(); return; } |
if ($assessSheet->blackout()) { |
if ($assessSheet->blackout()) { |
$self->blackout(1); |
$self->blackout(1); |
$self->{'blackout_rows'}->{$rownum} = 1; |
$self->{'blackout_rows'}->{$rownum} = 1; |
Line 475 sub compute {
|
Line 503 sub compute {
|
sub set_row_sources { |
sub set_row_sources { |
my $self = shift; |
my $self = shift; |
while (my ($cell,$value) = each(%{$self->{'formulas'}})) { |
while (my ($cell,$value) = each(%{$self->{'formulas'}})) { |
next if ($cell !~ /^A(\d+)/ && $1 > 0); |
next if ($cell !~ /^A(\d+)$/ || $1 < 1); |
my $row = $1; |
my $row = $1; |
(undef,$value) = split('__&&&__',$value); |
(undef,$value) = split('__&&&__',$value); |
$value = 'Default' if (! defined($value)); |
$value = 'Default' if (! defined($value)); |
Line 492 sub set_row_numbers {
|
Line 520 sub set_row_numbers {
|
next if ($row == 0); |
next if ($row == 0); |
my ($symb,undef) = split('__&&&__',$formula); |
my ($symb,undef) = split('__&&&__',$formula); |
$self->{'row_numbers'}->{$symb} = $row; |
$self->{'row_numbers'}->{$symb} = $row; |
$self->{'maxrow'} = $1 if ($1 > $self->{'maxrow'}); |
$self->{'maxrow'} = $row if ($row > $self->{'maxrow'}); |
} |
} |
} |
} |
|
|
Line 522 These rows are saved in the courses dire
|
Line 550 These rows are saved in the courses dire
|
############################################# |
############################################# |
############################################# |
############################################# |
sub load_cached_export_rows { |
sub load_cached_export_rows { |
%Exportrows = undef; |
undef(%Exportrows); |
my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets', |
my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets', |
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
$ENV{'course.'.$ENV{'request.course.id'}.'.num'},undef); |
$ENV{'course.'.$ENV{'request.course.id'}.'.num'},undef); |
Line 570 sub save_export_data {
|
Line 598 sub save_export_data {
|
my $newstore = join('___;___', |
my $newstore = join('___;___', |
@{$Exportrows{$student}->{'data'}}); |
@{$Exportrows{$student}->{'data'}}); |
$newstore = '___=___'.$newstore; |
$newstore = '___=___'.$newstore; |
&Apache::lonnet::put('nohist_calculatedsheets', |
my $result= &Apache::lonnet::put('nohist_calculatedsheets', |
{ $key => $newstore, |
{ $key => $newstore, |
$timekey => $Exportrows{$student}->{'time'} }, |
$timekey => $Exportrows{$student}->{'time'} }, |
$self->{'cdom'}, |
$self->{'cdom'}, |
Line 594 spreadsheet only if necessary.
|
Line 622 spreadsheet only if necessary.
|
############################################# |
############################################# |
sub export_data { |
sub export_data { |
my $self = shift; |
my $self = shift; |
|
my ($r) = @_; |
|
my $connection = $r->connection(); |
my $student = $self->{'name'}.':'.$self->{'domain'}; |
my $student = $self->{'name'}.':'.$self->{'domain'}; |
if (! exists($Exportrows{$student}) || |
if (! exists($Exportrows{$student}) || |
|
! defined($Exportrows{$student}) || |
|
! exists($Exportrows{$student}->{'data'}) || |
|
! defined($Exportrows{$student}->{'data'}) || |
|
! exists($Exportrows{$student}->{'time'}) || |
|
! defined($Exportrows{$student}->{'time'}) || |
! $self->check_expiration_time($Exportrows{$student}->{'time'})) { |
! $self->check_expiration_time($Exportrows{$student}->{'time'})) { |
$self->compute(); |
$self->compute($r); |
} |
} |
|
if ($connection->aborted()) { $self->cleanup(); return; } |
my @Data = @{$Exportrows{$student}->{'data'}}; |
my @Data = @{$Exportrows{$student}->{'data'}}; |
for (my $i=0; $i<=$#Data;$i++) { |
for (my $i=0; $i<=$#Data;$i++) { |
$Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i])); |
$Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i])); |