Skip to content

Commit

Permalink
Merge pull request #2253 from somiaj/test_show_template_id
Browse files Browse the repository at this point in the history
Show template problem ID in tests.
  • Loading branch information
Alex-Jordan authored Nov 16, 2023
2 parents 4f359b5 + 1d4c076 commit 5494343
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,11 @@ async sub pre_header_initialize ($c) {
push(@pg_results, $pg);
}

# Show the template problem ID if the problems are in random order
# or the template problem IDs are not in order starting at 1.
$c->{can}{showTemplateIds} = $c->{can}{showProblemGrader}
&& ($set->problem_randorder || $problems[-1]->problem_id != scalar(@problems));

# Wait for all problems to be rendered and replace the undefined entries
# in the pg_results array with the rendered result.
my @renderedPG = await Mojo::Promise->all(@renderPromises);
Expand Down
4 changes: 4 additions & 0 deletions templates/ContentGenerator/GatewayQuiz.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@
% # Output the problem header.
<h2><%= maketext('Problem [_1].', $i + 1) %></h2>
<span class="problem-sub-header">
% if ($c->{can}{showTemplateIds}) {
<%= '('
. maketext('Template ID: [_1]', $problems->[ $probOrder->[$i] ]->problem_id) . ')' %>
% }
% my $problemValue = $problems->[ $probOrder->[$i] ]->value;
% if (defined $problemValue) {
% my $points = $problemValue == 1 ? maketext('point') : maketext('points');
Expand Down

0 comments on commit 5494343

Please sign in to comment.