Skip to content

Commit 5838bad

Browse files
committed
Make sure to account for an undefined ANSWER_ENTRY_ORDER in the single problem grader.
Previously the problem grader could only be made visible when the problem successfully rendered. Now that it is always visible, a little more care is needed. The `ANSWER_ENTRY_ORDER` array in the PG flags will not be defined if the problem does not successfully render. This fixes issue openwebwork#3194.
1 parent 4ff31e6 commit 5838bad

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

templates/HTML/SingleProblemGrader/grader.html.ep

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
% my $rawCurrentScore = 0;
1818
%
1919
% # Subscores for each answer in the problem.
20-
% if (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1) {
20+
% if (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} // [] } > 1) {
2121
% # Determine the scores and weights for each part of the problem.
2222
% my $total = 0;
2323
% my (@scores, @weights);
@@ -77,7 +77,7 @@
7777
</div>
7878
% }
7979
% $currentScore = wwRound(0, $rawCurrentScore);
80-
% } elsif (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} }) {
80+
% } elsif (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} // [] }) {
8181
% $rawCurrentScore = $grader->{pg}{answers}{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER}[0] }{score} * 100;
8282
% $currentScore = wwRound(0, $rawCurrentScore);
8383
<%= hidden_field
@@ -111,7 +111,7 @@
111111
)
112112
)
113113
. (
114-
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1 ? tag(
114+
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} // [] } > 1 ? tag(
115115
'p',
116116
class => 'mt-2 mb-0',
117117
maketext(
@@ -185,7 +185,7 @@
185185
maketext('The initial value is the currently saved score for this student.')
186186
)
187187
. (
188-
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1 ? tag(
188+
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} // [] } > 1 ? tag(
189189
'p',
190190
class => 'mt-2 mb-0',
191191
maketext(

0 commit comments

Comments
 (0)