Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show template problem ID in tests. #2253

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
Alex-Jordan marked this conversation as resolved.
Show resolved Hide resolved

# 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