Skip to content

Commit 59998c6

Browse files
authored
Merge pull request #2274 from drgrice1/add-seed-to-past-answer
Add problem seed to past answers.
2 parents 8a23597 + 630db8a commit 59998c6

File tree

7 files changed

+28
-18
lines changed

7 files changed

+28
-18
lines changed

lib/WeBWorK/ContentGenerator/GatewayQuiz.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,7 @@ async sub pre_header_initialize ($c) {
10911091
$pastAnswer->scores($scores);
10921092
$pastAnswer->answer_string($past_answers_string);
10931093
$pastAnswer->source_file($problem->source_file);
1094+
$pastAnswer->problem_seed($problem->problem_seed);
10941095
$db->addPastAnswer($pastAnswer);
10951096
}
10961097
}

lib/WeBWorK/ContentGenerator/Instructor/ShowAnswers.pm

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,12 @@ async sub initialize ($c) {
173173
}
174174

175175
for my $pastAnswer (@pastAnswers) {
176-
my $answerID = $pastAnswer->answer_id;
177-
my $answers = $pastAnswer->answer_string;
178-
my $scores = $pastAnswer->scores;
179-
my $time = $pastAnswer->timestamp;
180-
my @scores = split(//, $scores);
181-
my @answers = split(/\t/, $answers);
182-
183-
$records{$studentUser}{$setName}{$problemNumber}{$answerID} = {
184-
time => $time,
185-
answers => [@answers],
176+
$records{$studentUser}{$setName}{$problemNumber}{ $pastAnswer->answer_id } = {
177+
time => $pastAnswer->timestamp,
178+
seed => $pastAnswer->problem_seed,
179+
answers => [ split(/\t/, $pastAnswer->answer_string) ],
186180
answerTypes => \@answerTypes,
187-
scores => [@scores],
181+
scores => [ split(//, $pastAnswer->scores) ],
188182
comment => $pastAnswer->comment_string // ''
189183
};
190184
}

lib/WeBWorK/DB/Record/PastAnswer.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use warnings;
2727

2828
BEGIN {
2929
__PACKAGE__->_fields(
30-
3130
answer_id => { type => "INT AUTO_INCREMENT", key => 1 },
3231
user_id => { type => "VARCHAR(100) NOT NULL", key => 1 },
3332
set_id => { type => "VARCHAR(100) NOT NULL", key => 1 },
@@ -37,7 +36,7 @@ BEGIN {
3736
scores => { type => "TINYTEXT" },
3837
answer_string => { type => "VARCHAR(5012)" },
3938
comment_string => { type => "VARCHAR(5012)" },
40-
39+
problem_seed => { type => "INT" },
4140
);
4241
}
4342

lib/WeBWorK/DB/Record/PermissionLevel.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ BEGIN {
3030
__PACKAGE__->_fields(
3131
user_id => { type => "VARCHAR(100) NOT NULL", key => 1 },
3232
permission => { type => "INT" },
33-
3433
);
3534
}
3635

lib/WeBWorK/Utils/ProblemProcessing.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ async sub process_and_log_answer ($c) {
122122
$pastAnswer->scores($scores2);
123123
$pastAnswer->answer_string($past_answers_string);
124124
$pastAnswer->source_file($problem->source_file);
125+
$pastAnswer->problem_seed($problem->problem_seed);
125126
$db->addPastAnswer($pastAnswer);
126127
}
127128
}

lib/WebworkWebservice/ProblemActions.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ sub putPastAnswer {
109109

110110
$pastAnswer->{user_id} = $params->{user_id} if $params->{user_id};
111111

112-
for ('set_id', 'problem_id', 'source_file', 'timestamp', 'scores', 'answer_string', 'comment_string') {
112+
for (
113+
'set_id', 'problem_id', 'source_file', 'timestamp',
114+
'scores', 'answer_string', 'comment_string', 'problem_seed'
115+
)
116+
{
113117
$pastAnswer->{$_} = $params->{$_} if defined($params->{$_});
114118
}
115119

templates/ContentGenerator/Instructor/ShowAnswers/past-answers-table.html.ep

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
% for my $problemNumber (sort { $a <=> $b } keys %{ $records->{$studentUser}{$setName} }) {
99
% my @pastAnswerIDs = sort { $a <=> $b } keys %{ $records->{$studentUser}{$setName}{$problemNumber} };
1010
% my $prettyProblemNumber = stash->{prettyProblemNumbers}{$setName}{$problemNumber};
11-
<h3>
11+
<h2 class="fs-3">
1212
<%== maketext('Past Answers for [_1], set [_2], problem [_3]',
1313
$studentUser, tag('span', dir => 'ltr', format_set_name_display($setName)), $prettyProblemNumber
1414
) =%>
15-
</h3>
15+
</h2>
1616
<div class="table-responsive">
1717
<table class="past-answer-table table table-striped" dir="ltr">
1818
% my $previousTime = -1;
@@ -27,8 +27,20 @@
2727
%
2828
<tr <%== $record{time} - $previousTime > $ce->{sessionKeyTimeout}
2929
? 'class="table-rule"' : '' %>>
30+
% # Show the problem seed for instructors.
31+
% if ($isInstructor) {
32+
<td class="px-3">
33+
<small>
34+
<%= maketext(
35+
'Seed: [_1]',
36+
defined $record{seed} && $record{seed} ne ''
37+
? $record{seed} : maketext('unknown')
38+
) %>
39+
</small>
40+
</td>
41+
% }
3042
<td class="px-3"><small><%= $c->formatDateTime($record{time}) %></small></td>
31-
% for (my $i = 0; $i <= $upper_limit; $i++) {
43+
% for (my $i = 0; $i <= $upper_limit; ++$i) {
3244
% my $answer = $answers[$i] // '';
3345
% my $answerType = $record{answerTypes}[$i] // '';
3446
% my $score = shift(@scores);

0 commit comments

Comments
 (0)