Skip to content

Commit

Permalink
check answers for determination of new version
Browse files Browse the repository at this point in the history
  • Loading branch information
drdrew42 committed Oct 6, 2023
1 parent fb25f23 commit b3d0464
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/WeBWorK/ContentGenerator/ShowMeAnother.pm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async sub pre_header_initialize ($c) {
showHints => 0,
showSolutions => 0,
refreshMath2img => 0,
processAnswers => 0,
processAnswers => 1,
permissionLevel => $db->getPermissionLevel($userName)->permission,
effectivePermissionLevel => $db->getPermissionLevel($effectiveUserName)->permission,
useMathQuill => $c->{will}{useMathQuill},
Expand Down Expand Up @@ -173,7 +173,7 @@ async sub pre_header_initialize ($c) {
showHints => 0,
showSolutions => 0,
refreshMath2img => 0,
processAnswers => 0,
processAnswers => 1,
permissionLevel => $db->getPermissionLevel($userName)->permission,
effectivePermissionLevel => $db->getPermissionLevel($effectiveUserName)->permission,
useMathQuill => $c->{will}{useMathQuill},
Expand All @@ -188,7 +188,9 @@ async sub pre_header_initialize ($c) {
}

# check to see if we've found a new version
if ($new_body_text ne $orig_body_text) {
if ($new_body_text ne $orig_body_text
|| have_different_answers($showMeAnotherNewPG, $showMeAnotherOriginalPG))
{
# if we've found a new version, then
# increment the counter detailing the number of times showMeAnother has been used
# unless we're trying to check answers from the showMeAnother screen
Expand Down Expand Up @@ -232,7 +234,7 @@ async sub pre_header_initialize ($c) {
showHints => 0,
showSolutions => 0,
refreshMath2img => 0,
processAnswers => 0,
processAnswers => 1,
permissionLevel => $db->getPermissionLevel($userName)->permission,
effectivePermissionLevel => $db->getPermissionLevel($effectiveUserName)->permission,
useMathQuill => $c->{will}{useMathQuill},
Expand Down Expand Up @@ -594,4 +596,16 @@ sub output_hidden_info ($c) {
return '';
}

# Checks the PG object for two different seeds of the same pg file
sub have_different_answers ($pg1, $pg2) {
my $different = 0;
for (keys %{ $pg1->{answers} }) {
if ($pg1->{answers}{$_} ne $pg2->{answers}{$_}) {
$different = 1;
last;
}
}
return $different;
}

1;

0 comments on commit b3d0464

Please sign in to comment.