From 1d4c0764135147a4e1fbb4ffc7ccb9b31c4769d2 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Tue, 14 Nov 2023 07:20:05 -0700 Subject: [PATCH] Show template problem ID in tests. For users who can see the single problem grader, also show the template problem ID if the problems are in random order or not enumerated from 1 to N. This way instructors can see what the real problem ID is in the case it is different from the problem number. --- lib/WeBWorK/ContentGenerator/GatewayQuiz.pm | 5 +++++ templates/ContentGenerator/GatewayQuiz.html.ep | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm index 092a7a4f90..c45488af7e 100644 --- a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm +++ b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm @@ -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); diff --git a/templates/ContentGenerator/GatewayQuiz.html.ep b/templates/ContentGenerator/GatewayQuiz.html.ep index 0934437597..123691f58d 100644 --- a/templates/ContentGenerator/GatewayQuiz.html.ep +++ b/templates/ContentGenerator/GatewayQuiz.html.ep @@ -522,6 +522,10 @@ % # Output the problem header.

<%= maketext('Problem [_1].', $i + 1) %>

+ % 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');