| … | |
… | |
| 14 | |
14 | |
| 15 | use strict; |
15 | use strict; |
| 16 | use warnings; |
16 | use warnings; |
| 17 | use CGI qw(); |
17 | use CGI qw(); |
| 18 | use WeBWorK::Utils qw(readFile formatDateTime); |
18 | use WeBWorK::Utils qw(readFile formatDateTime); |
|
|
19 | use WeBWorK::DB::Utils qw(initializeUserProblem); |
| 19 | use WeBWorK::Timing; |
20 | use WeBWorK::Timing; |
| 20 | |
21 | |
| 21 | sub initialize { |
22 | sub 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") { |