Skip to content

Commit dd18db4

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 d3269e3 commit dd18db4

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
@@ -14,7 +14,7 @@
1414
% my $rawCurrentScore = 0;
1515
%
1616
% # Subscores for each answer in the problem.
17-
% if (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1) {
17+
% if (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} // [] } > 1) {
1818
% # Determine the scores and weights for each part of the problem.
1919
% my $total = 0;
2020
% my (@scores, @weights);
@@ -73,7 +73,7 @@
7373
</div>
7474
% }
7575
% $currentScore = wwRound(0, $rawCurrentScore);
76-
% } elsif (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} }) {
76+
% } elsif (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} // [] }) {
7777
% $rawCurrentScore = $grader->{pg}{answers}{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER}[0] }{score} * 100;
7878
% $currentScore = wwRound(0, $rawCurrentScore);
7979
<%= hidden_field 'answer-part-score' => $currentScore, class => 'answer-part-score',
@@ -106,7 +106,7 @@
106106
)
107107
)
108108
. (
109-
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1 ? tag(
109+
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} // [] } > 1 ? tag(
110110
'p',
111111
class => 'mt-2 mb-0',
112112
maketext(
@@ -175,7 +175,7 @@
175175
maketext('The initial value is the currently saved score for this student.')
176176
)
177177
. (
178-
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1 ? tag(
178+
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} // [] } > 1 ? tag(
179179
'p',
180180
class => 'mt-2 mb-0',
181181
maketext(

0 commit comments

Comments
 (0)