[system] / trunk / webwork2 / lib / WeBWorK / ContentGenerator / Instructor / Scoring.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/WeBWorK/ContentGenerator/Instructor/Scoring.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1387 Revision 1388
29 } 29 }
30 return @result; 30 return @result;
31} 31}
32 32
33sub writeCSV { 33sub writeCSV {
34 my ($self, @csv) = @_; 34 my ($self, $filename, @csv) = @_;
35 open my $fh, ">", $filename;
36 foreach my $column (@csv) {
37 my $maxLength = $self->maxLength($column);
38 print (join ",", map {$self->pad($_, $maxLength)} $@column);
39 print "\n";
40 }
41 close $fh;
35} 42}
36 43
37sub readStandardCSV { 44sub readStandardCSV {
38 my ($self, $filename) = @_; 45 my ($self, $filename) = @_;
39 my @result = (); 46 my @result = ();
43 } 50 }
44 return @result; 51 return @result;
45} 52}
46 53
47sub writeStandardCSV { 54sub writeStandardCSV {
48 55 my ($self, $filename, @csv) = @_;
56 open my $fh, ">", $filename;
57 foreach my $column (@csv) {
58 print (join ",", map {$self->quote} $@column);
59 print "\n";
60 }
61 close $fh;
49} 62}
50 63
51### 64###
52 65
53# This particular unquote method unquotes (optionally) quoted strings in the 66# This particular unquote method unquotes (optionally) quoted strings in the
99 $string =~ s/"/""/; 112 $string =~ s/"/""/;
100 $string =~ "\"$string\""; 113 $string =~ "\"$string\"";
101 return $string; 114 return $string;
102 } 115 }
103} 116}
117
118sub pad {
119 my ($self, $string, $padTo) = @_;
120 my $spaces = $padTo - length $string;
121 return $string . " "x$spaces;
122}
123
124sub maxLength {
125 my ($self, $arrayRef) = @_;
126 my $max = 0;
127 foreach my $cell (@$arrayRef) {
128 $max = length $cell unless length $cell < $max;
129 }
130 return $max;
131}

Legend:
Removed from v.1387  
changed lines
  Added in v.1388

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9