[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 1448 Revision 1449
14 14
15use strict; 15use strict;
16use warnings; 16use warnings;
17use CGI qw(); 17use CGI qw();
18use WeBWorK::Utils qw(readFile formatDateTime); 18use WeBWorK::Utils qw(readFile formatDateTime);
19use WeBWorK::DB::Utils qw(initializeUserProblem);
19use WeBWorK::Timing; 20use WeBWorK::Timing;
20 21
21sub initialize { 22sub initialize {
22 my ($self) = @_; 23 my ($self) = @_;
23 my $r = $self->{r}; 24 my $r = $self->{r};
101 $format = "normal" unless defined $format; 102 $format = "normal" unless defined $format;
102 $format = "normal" unless $format eq "full" or $format eq "everything" or $format eq "totals" or $format eq "info"; 103 $format = "normal" unless $format eq "full" or $format eq "everything" or $format eq "totals" or $format eq "info";
103 my $columnsPerProblem = ($format eq "full" or $format eq "everything") ? 3 : 1; 104 my $columnsPerProblem = ($format eq "full" or $format eq "everything") ? 3 : 1;
104 my $setRecord = $db->getGlobalSet($setID); 105 my $setRecord = $db->getGlobalSet($setID);
105 my %users; 106 my %users;
106 foreach my $userID ($db->listSetUsers($setID)) { 107 foreach my $userID ($db->listUsers()) {
107 my $userRecord = $db->getUser($userID); 108 my $userRecord = $db->getUser($userID);
108 # The key is what we'd like to sort by. 109 # The key is what we'd like to sort by.
109 $users{$userRecord->student_id} = $userRecord; 110 $users{$userRecord->student_id} = $userRecord;
110 } 111 }
111 my @problemIDs = $db->listGlobalProblems($setID); 112 my @problemIDs = $db->listGlobalProblems($setID);
176 } 177 }
177 } 178 }
178 $valueTotal += $globalProblem->value; 179 $valueTotal += $globalProblem->value;
179 for (my $user = 0; $user < @userKeys; $user++) { 180 for (my $user = 0; $user < @userKeys; $user++) {
180 my $userProblem = $db->getMergedProblem($users{$userKeys[$user]}->user_id, $setID, $problemIDs[$problem]); 181 my $userProblem = $db->getMergedProblem($users{$userKeys[$user]}->user_id, $setID, $problemIDs[$problem]);
182 unless (defined $userProblem) { # assume an empty problem record if the problem isn't assigned to this user
183 $userProblem = $db->newUserProblem;
184 $userProblem->status(0);
185 $userProblem->value(0);
186 $userProblem->num_correct(0);
187 $userProblem->num_incorrect(0);
188 }
181 $userStatusTotals{$user} = 0 unless exists $userStatusTotals{$user}; 189 $userStatusTotals{$user} = 0 unless exists $userStatusTotals{$user};
182 $userStatusTotals{$user} += $userProblem->status * $userProblem->value; 190 $userStatusTotals{$user} += $userProblem->status * $userProblem->value;
183 unless ($format eq "totals") { 191 unless ($format eq "totals") {
184 $scoringData[7 + $user][$column] = $userProblem->status; 192 $scoringData[7 + $user][$column] = $userProblem->status;
185 if ($format eq "full" or $format eq "everything") { 193 if ($format eq "full" or $format eq "everything") {

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9