Skip to content
Open
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
31 changes: 17 additions & 14 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,16 @@ async sub pre_header_initialize ($c) {
# requiring another answer submission.
my $showReturningFeedback = 0;

# Sticky answers
if (!($c->{submitAnswers} || $previewAnswers || $checkAnswers) && $will{showOldAnswers}) {
# Reinsert sticky answers. Do this only if new answers are NOT being submitted,
# and a new problem version is NOT being opened.
if (!($prEnabled && !$problem->{prCount})
&& !($c->{submitAnswers} || $previewAnswers || $checkAnswers)
&& $will{showOldAnswers})
{
my %oldAnswers = decodeAnswers($problem->last_answer);
# Do this only if new answers are NOT being submitted
if ($prEnabled && !$problem->{prCount}) {
# Clear answers if this is a new problem version
delete $formFields->{$_} for keys %oldAnswers;
} else {
$formFields->{$_} = $oldAnswers{$_} for (keys %oldAnswers);
$showReturningFeedback = 1
if $ce->{pg}{options}{automaticAnswerFeedback} && $problem->num_correct + $problem->num_incorrect > 0;
}
$formFields->{$_} = $oldAnswers{$_} for (keys %oldAnswers);
$showReturningFeedback = 1
if $ce->{pg}{options}{automaticAnswerFeedback} && $problem->num_correct + $problem->num_incorrect > 0;
}

my $showOnlyCorrectAnswers = $c->param('showCorrectAnswers') && $will{showCorrectAnswers};
Expand All @@ -555,7 +553,9 @@ async sub pre_header_initialize ($c) {
$c->{set},
$problem,
$c->{set}->psvn,
$formFields,
$prEnabled
&& !$problem->{prCount}
&& !($c->{submitAnswers} || $previewAnswers || $checkAnswers) ? {} : $formFields,
{
displayMode => $displayMode,
showHints => $will{showHints},
Expand Down Expand Up @@ -588,8 +588,11 @@ async sub pre_header_initialize ($c) {
: 0
),
debuggingOptions => getTranslatorDebuggingOptions($authz, $userID),
$can{checkAnswers}
&& defined $formFields->{problem_data} ? (problemData => $formFields->{problem_data}) : ()
$prEnabled && !$problem->{prCount}
? (problemData => '{}')
: ($can{checkAnswers} && defined $formFields->{problem_data})
? (problemData => $formFields->{problem_data})
: ()
}
);

Expand Down
5 changes: 4 additions & 1 deletion lib/WeBWorK/ContentGenerator/ShowMeAnother.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async sub pre_header_initialize ($c) {
effectivePermissionLevel => $db->getPermissionLevel($c->{effectiveUserID})->permission,
useMathQuill => $c->{will}{useMathQuill},
useMathView => $c->{will}{useMathView},
problemData => '{}'
},
);

Expand Down Expand Up @@ -116,6 +117,7 @@ async sub pre_header_initialize ($c) {
effectivePermissionLevel => $db->getPermissionLevel($c->{effectiveUserID})->permission,
useMathQuill => $c->{will}{useMathQuill},
useMathView => $c->{will}{useMathView},
problemData => '{}'
},
);

Expand Down Expand Up @@ -206,7 +208,8 @@ async sub pre_header_initialize ($c) {
showMessages => !$showOnlyCorrectAnswers,
showCorrectAnswers => $showOnlyCorrectAnswers
|| ($c->{will}{checkAnswers} && $c->{will}{showCorrectAnswers}) ? 1 : 0,
debuggingOptions => getTranslatorDebuggingOptions($c->authz, $c->{userID})
debuggingOptions => getTranslatorDebuggingOptions($c->authz, $c->{userID}),
problemData => $c->{formFields}{problem_data} || '{}'
}
);

Expand Down