[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet studentcalc.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Sun, 26 Mar 2006 22:48:34 -0000
bowersj2 Sun Mar 26 17:48:34 2006 EDT
Modified files:
/loncom/interface/spreadsheet studentcalc.pm
Log:
Fix bug 3622, ability to change assessment spreadsheet for entire
sequence at once.
Index: loncom/interface/spreadsheet/studentcalc.pm
diff -u loncom/interface/spreadsheet/studentcalc.pm:1.35 loncom/interface/spreadsheet/studentcalc.pm:1.36
--- loncom/interface/spreadsheet/studentcalc.pm:1.35 Fri Aug 26 16:46:46 2005
+++ loncom/interface/spreadsheet/studentcalc.pm Sun Mar 26 17:48:34 2006
@@ -1,5 +1,5 @@
#
-# $Id: studentcalc.pm,v 1.35 2005/08/26 20:46:46 albertel Exp $
+# $Id: studentcalc.pm,v 1.36 2006/03/26 22:48:34 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -271,8 +271,17 @@
}
foreach my $Sequence (@Sequences) {
$r->print("<h3>".$Sequence->compTitle."</h3>\n");
+
+ my @resources = &get_resources($Sequence);
+ my $first_rownum =
+ $self->get_row_number_from_key($resources[0]->symb);
+ my $last_rownum =
+ $self->get_row_number_from_key($resources[-1]->symb);
+ $r->print(&assess_file_selector([$first_rownum, $last_rownum],
+ undef, \@AssessFileNames));
+
$r->print($tableheader);
- foreach my $resource (&get_resources($Sequence)) {
+ foreach my $resource (@resources) {
my $rownum = $self->get_row_number_from_key($resource->symb);
my $assess_filename = $self->{'row_source'}->{$rownum};
my $row_output = '<tr>';
@@ -328,12 +337,25 @@
return '';
}
return '' if (! &Apache::lonnet::allowed('mgr',$env{'request.course.id'}));
- my $element_name = 'FileSelect_'.$row;
+ my $element_name;
+ my $source_row = $row;
+ if (ref($row)) {
+ my ($first_rownum, $last_rownum) = @$row;
+ $element_name = "FileSelect_${first_rownum}_${last_rownum}";
+ $source_row = "${first_rownum}:${last_rownum}";
+ } else {
+ $element_name = 'FileSelect_'.$row;
+ }
my $load_dialog = '<select size="1" name="'.$element_name.'" '.
'onchange="'.
- "document.sheet.cell.value='source_$row';".
+ "document.sheet.cell.value='source_${source_row}';".
"document.sheet.newformula.value=document.sheet.$element_name\.value;".
'document.sheet.submit()" '.'>'."\n";
+ if (ref($row)) {
+ $load_dialog .= ' <option name="" value="">' .
+ &mt("Select spreadsheet for entire sequence")
+ . "</option>\n";
+ }
foreach my $file (@{$AssessFiles}) {
$load_dialog .= ' <option name="'.$file.'"';
$load_dialog .= ' selected' if ($default eq $file);
@@ -346,22 +368,36 @@
sub modify_cell {
my $self = shift;
my ($cell,$formula) = @_;
- if ($cell =~ /^source_(\d+)$/) {
- # Need to make sure $formula is a valid filename....
- my $row = $1;
- $cell = 'A'.$row;
+
+ my $set_row = sub {
+ my $row = shift;
+ my $formula = shift;
+ my $cell = 'A' . $row;
$self->{'row_source'}->{$row} = $formula;
my $original_source = $self->formula($cell);
if ($original_source =~ /__&&&__/) {
($original_source,undef) = split('__&&&__',$original_source);
}
$formula = $original_source.'__&&&__'.$formula;
+ $self->set_formula($cell,$formula);
+ };
+
+ if ($cell =~ /^source_(\d+):(\d+)$/) {
+ my $first_row = $1;
+ my $last_row = $2;
+ for my $row ($first_row..$last_row) {
+ $set_row->($row, $formula);
+ }
+ } elsif ($cell =~ /^source_(\d+)$/) {
+ # Need to make sure $formula is a valid filename....
+ my $row = $1;
+ $set_row->($row, $formula);
} elsif ($cell =~ /([A-z])\-/) {
$cell = 'template_'.$1;
+ $self->set_formula($cell,$formula);
} elsif ($cell !~ /^([A-z](\d+)|template_[A-z])$/) {
return;
}
- $self->set_formula($cell,$formula);
$self->rebuild_stats();
return;
}