Log Message:
-----------
1. Don't put any spaces before any numerical data in .csv output. Excel
doesn't have a problem with this but other spreadsheets do according to Mike.
2. Keep backups of all totals files and never overwrite a backup. The File
Manager can be used to delete any unwanted backups.
Arnie
Modified Files:
--------------
webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor:
Scoring.pm
Revision Data
-------------
Index: Scoring.pm
===================================================================
RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/Scoring.pm,v
retrieving revision 1.42
retrieving revision 1.43
diff -Llib/WeBWorK/ContentGenerator/Instructor/Scoring.pm -Llib/WeBWorK/ContentGenerator/Instructor/Scoring.pm -u -r1.42 -r1.43
--- lib/WeBWorK/ContentGenerator/Instructor/Scoring.pm
+++ lib/WeBWorK/ContentGenerator/Instructor/Scoring.pm
@@ -465,8 +465,8 @@
$scoringData[6][$totalsColumn+1] = "index" ;
}
for (my $user = 0; $user < @sortedUserIDs; $user++) {
- $scoringData[7+$user][$totalsColumn] = sprintf("%4.1f",$userStatusTotals{$user});
- $scoringData[7+$user][$totalsColumn+1] = sprintf("%4.0f",100*$userSuccessIndex{$user}) if $scoringItems->{successIndex};
+ $scoringData[7+$user][$totalsColumn] = sprintf("%.1f",$userStatusTotals{$user});
+ $scoringData[7+$user][$totalsColumn+1] = sprintf("%.0f",100*$userSuccessIndex{$user}) if $scoringItems->{successIndex};
}
}
$WeBWorK::timer->continue("End set $setID") if defined($WeBWorK::timer);
@@ -502,8 +502,8 @@
$studentTotal += ($score =~/^\s*[\d\.]+\s*$/)? $score : 0;
}
- $scoringData[$i][0] =sprintf("%4.1f",$studentTotal);
- $scoringData[$i][1] =($totalPoints) ?sprintf("%4.1f",100*$studentTotal/$totalPoints) : 0;
+ $scoringData[$i][0] =sprintf("%.1f",$studentTotal);
+ $scoringData[$i][1] =($totalPoints) ?sprintf("%.1f",100*$studentTotal/$totalPoints) : 0;
}
$scoringData[0] = ['',''];
$scoringData[1] = ['summary', '%score'];
@@ -595,6 +595,18 @@
}
}
+ # Before writing a new totals file, we back up an existing totals file keeping any previous backups.
+ # We do not backup any other type of scoring files (e.g. ful or scr).
+
+ if (($filename =~ m|(.*)/(.*_totals)\.csv$|) and (-e $filename)) {
+ my $scoringDir = $1;
+ my $short_filename = $2;
+ my $i=1;
+ while(-e "${scoringDir}/${short_filename}_bak$i.csv") {$i++;} #don't overwrite existing backups
+ my $bakFileName ="${scoringDir}/${short_filename}_bak$i.csv";
+ rename $filename, $bakFileName or warn "Unable to rename $filename to $bakFileName";
+ }
+
open my $fh, ">", $filename or warn "Unable to open $filename for writing";
foreach my $row (@csv) {
my @rowPadded = ();
|