Skip to content

Commit

Permalink
TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
drgrice1 committed Sep 19, 2023
1 parent 8cf57d3 commit b964c37
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
47 changes: 28 additions & 19 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ async sub pre_header_initialize ($c) {
{
$c->{submitAnswers} = 0;
$c->{resubmitDetected} = 1;
delete $formFields->{submitAnswers};
}

$c->{displayMode} = $displayMode;
Expand Down Expand Up @@ -581,6 +582,24 @@ async sub pre_header_initialize ($c) {
# Final values for options
my %will = map { $_ => $can{$_} && ($want{$_} || $must{$_}) } keys %must;

if ($prEnabled && $problem->{prCount} >= $rerandomizePeriod && !after($c->{set}->due_date, $c->submitTime)) {
$showMeAnother{active} = 0;
$must{requestNewSeed} = 1;
$can{requestNewSeed} = 1;
$want{requestNewSeed} = 1;
$will{requestNewSeed} = 1;
$c->{showCorrectOnRandomize} = $ce->{pg}{options}{showCorrectOnRandomize};
# If this happens, it means that the page was refreshed. So prevent the answers from
# being recorded and the number of attempts from being increased.
if ($problem->{prCount} > $rerandomizePeriod) {
$c->{resubmitDetected} = 1;
$must{recordAnswers} = 0;
$can{recordAnswers} = 0;
$want{recordAnswers} = 0;
$will{recordAnswers} = 0;
}
}

# Sticky answers
if (!($c->{submitAnswers} || $previewAnswers || $checkAnswers) && $will{showOldAnswers}) {
my %oldAnswers = decodeAnswers($problem->last_answer);
Expand Down Expand Up @@ -615,7 +634,15 @@ async sub pre_header_initialize ($c) {
useMathView => $will{useMathView},
forceScaffoldsOpen => 0,
isInstructor => $authz->hasPermissions($userID, 'view_answers'),
debuggingOptions => getTranslatorDebuggingOptions($authz, $userID)
debuggingOptions => getTranslatorDebuggingOptions($authz, $userID),
forceShowAttemptFeedback => $will{checkAnswers} || $will{showProblemGrader},
showAttemptAnswers => $ce->{pg}{options}{showEvaluatedAnswers},
showAttemptPreviews => 1,
showAttemptResults => 1,
showMessages => 1,
showCorrectAnswers => $c->{submitAnswers} ? ($c->{showCorrectOnRandomize} // $will{showCorrectAnswers})
: $will{checkAnswers} || $will{showProblemGrader} ? $will{showCorrectAnswers}
: 0
}
);

Expand All @@ -630,24 +657,6 @@ async sub pre_header_initialize ($c) {
id => 'num_attempts'
);

if ($prEnabled && $problem->{prCount} >= $rerandomizePeriod && !after($c->{set}->due_date, $c->submitTime)) {
$showMeAnother{active} = 0;
$must{requestNewSeed} = 1;
$can{requestNewSeed} = 1;
$want{requestNewSeed} = 1;
$will{requestNewSeed} = 1;
$c->{showCorrectOnRandomize} = $ce->{pg}{options}{showCorrectOnRandomize};
# If this happens, it means that the page was refreshed. So prevent the answers from
# being recorded and the number of attempts from being increased.
if ($problem->{prCount} > $rerandomizePeriod) {
$c->{resubmitDetected} = 1;
$must{recordAnswers} = 0;
$can{recordAnswers} = 0;
$want{recordAnswers} = 0;
$will{recordAnswers} = 0;
}
}

# Update and fix hint/solution options after PG processing
$can{showHints} &&= $pg->{flags}{hintExists};
$can{showSolutions} &&= $pg->{flags}{solutionExists};
Expand Down
8 changes: 8 additions & 0 deletions lib/WeBWorK/Utils/Rendering.pm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ sub constructPGOptions ($ce, $user, $set, $problem, $psvn, $formFields, $transla
$options{inputs_ref} = $formFields;
$options{processAnswers} = $translationOptions->{processAnswers};

# Attempt Results
$options{forceShowAttemptFeedback} = $translationOptions->{forceShowAttemptFeedback};
$options{showAttemptAnswers} = $translationOptions->{showAttemptAnswers};
$options{showAttemptPreviews} = $translationOptions->{showAttemptPreviews};
$options{showAttemptResults} = $translationOptions->{showAttemptResults};
$options{showMessages} = $translationOptions->{showMessages};
$options{showCorrectAnswers} = $translationOptions->{showCorrectAnswers};

# External Data
$options{external_data} = decode_json($set->{external_data} || '{}');

Expand Down

0 comments on commit b964c37

Please sign in to comment.