Skip to content

Commit

Permalink
Merge pull request openwebwork#2226 from drdrew42/feature/answer-base…
Browse files Browse the repository at this point in the history
…d-sma-check

SMA compare answers and problem text
  • Loading branch information
drgrice1 authored Oct 9, 2023
2 parents ad1c5ba + bd92323 commit 6343757
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 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,12 @@ 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) {
for (keys %{ $pg1->{answers} }) {
return 1 if ($pg1->{answers}{$_}{correct_ans} ne $pg2->{answers}{$_}{correct_ans});
}
return 0;
}

1;

0 comments on commit 6343757

Please sign in to comment.