[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 1447 Revision 1448
20 20
21sub initialize { 21sub initialize {
22 my ($self) = @_; 22 my ($self) = @_;
23 my $r = $self->{r}; 23 my $r = $self->{r};
24 my $ce = $self->{ce}; 24 my $ce = $self->{ce};
25 25 my $authz = $self->{authz};
26 my $scoringDir = $ce->{courseDirs}->{scoring}; 26 my $scoringDir = $ce->{courseDirs}->{scoring};
27 my $courseName = $ce->{courseName}; 27 my $courseName = $ce->{courseName};
28 my $user = $r->param('user');
29
30 unless ($authz->hasPermissions($user, "score_sets")) {
31 $self->{submitError} = "You aren't authorized to score problem sets";
32 return;
33 }
34
28 if (defined $r->param('scoreSelected')) { 35 if (defined $r->param('scoreSelected')) {
29 my @selected = $r->param('selectedSet'); 36 my @selected = $r->param('selectedSet');
30 my @totals = (); 37 my @totals = ();
31 foreach my $setID (@selected) { 38 foreach my $setID (@selected) {
32 my @everything = $self->scoreSet($setID, "everything"); 39 my @everything = $self->scoreSet($setID, "everything");
39 $self->writeCSV("$scoringDir/s${setID}scr.csv", @normal); 46 $self->writeCSV("$scoringDir/s${setID}scr.csv", @normal);
40 $self->writeCSV("$scoringDir/s${setID}ful.csv", @full); 47 $self->writeCSV("$scoringDir/s${setID}ful.csv", @full);
41 } 48 }
42 $self->writeCSV("$scoringDir/${courseName}_totals.csv", @totals); 49 $self->writeCSV("$scoringDir/${courseName}_totals.csv", @totals);
43 } 50 }
51}
52
53sub title {
54 "Scoring data for ".(shift)->{ce}->{courseName};
55}
56
57sub body {
58 my ($self) = @_;
59 my $r = $self->{r};
60 my $ce = $self->{ce};
61 my $authz = $self->{authz};
62 my $scoringDir = $ce->{courseDirs}->{scoring};
63 my $courseName = $ce->{courseName};
64 my $user = $r->param('user');
65
66 if ($authz->hasPermissions($user, "score_sets")) {
67 my @selected = $r->param('selectedSet');
68 print CGI::p("All of these files will also be made available for mail merge");
69 foreach my $setID (@selected) {
70 print CGI::h2("$setID");
71 foreach my $type ("scr", "ful") {
72 my $filename = "s$setID$type.csv";
73 my $path = "$scoringDir/$filename";
74 if (-f $path) {
75 print CGI::a({href=>"../scoringDownload/?getFile=${filename}&".$self->url_authen_args}, $filename);
76 print CGI::br();
77 }
78 }
79 print CGI::hr();
80 }
81 print CGI::h2("Totals");
82 print CGI::a({href=>"../scoringDownload/?getFile=${courseName}_totals.csv&".$self->url_authen_args}, "${courseName}_totals.csv");
83 }
84
85 return "";
44} 86}
45 87
46# If, some day, it becomes possible to assign a different number of problems to each student, this code 88# If, some day, it becomes possible to assign a different number of problems to each student, this code
47# will have to be rewritten some. 89# will have to be rewritten some.
48# $format can be any of "normal", "full", "everything", "info", or "totals". An undefined value defaults to "normal" 90# $format can be any of "normal", "full", "everything", "info", or "totals". An undefined value defaults to "normal"
185 my @newRow = (); 227 my @newRow = ();
186 push @newRow, @row[0..4]; 228 push @newRow, @row[0..4];
187 for (my $i = 5; $i < @row; $i+=3) { 229 for (my $i = 5; $i < @row; $i+=3) {
188 push @newRow, $row[$i]; 230 push @newRow, $row[$i];
189 } 231 }
190 push @newRow, $row[$#row]; 232 #push @newRow, $row[$#row];
191 push @result, [@newRow]; 233 push @result, [@newRow];
192 } 234 }
193 return @result; 235 return @result;
194} 236}
195 237
206 my ($self, @everything) = @_; 248 my ($self, @everything) = @_;
207 my @result = (); 249 my @result = ();
208 foreach my $row (@everything) { 250 foreach my $row (@everything) {
209 push @result, [${$row}[$#{$row}]]; 251 push @result, [${$row}[$#{$row}]];
210 } 252 }
253 return @result;
211} 254}
212 255
213sub appendColumns { 256sub appendColumns {
214 my ($self, $a1, $a2) = @_; 257 my ($self, $a1, $a2) = @_;
215 my @a1 = @$a1; 258 my @a1 = @$a1;
216 my @a2 = @$a2; 259 my @a2 = @$a2;
217 # FIXME you were here 260 for (my $i = 0; $i < @a1; $i++) {
261 push @{$a1[$i]}, @{$a2[$i]};
262 }
218} 263}
219 264
220# Reads a CSV file and returns an array of arrayrefs, each containing a 265# Reads a CSV file and returns an array of arrayrefs, each containing a
221# row of data: 266# row of data:
222# (["c1r1", "c1r2", "c1r3"], ["c2r1", "c2r2", "c2r3"]) 267# (["c1r1", "c1r2", "c1r3"], ["c2r1", "c2r2", "c2r3"])

Legend:
Removed from v.1447  
changed lines
  Added in v.1448

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9