Skip to content

Commit

Permalink
Take the automatic feedback option a bit further.
Browse files Browse the repository at this point in the history
Now if the `$pg{options}{automaticAnswerFeedback}` option is true, then
feedback will also be automatically shown anytime a student returns to a
problem that has already been answered.
  • Loading branch information
drgrice1 committed Dec 12, 2023
1 parent beed394 commit 767fc94
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
19 changes: 10 additions & 9 deletions conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ $pg{options}{showCorrectOnRandomize} = 0;
###############################################################################
# automaticAnswerFeedback
################################################################################
# If set, then answer feedback is automatically shown after answers are
# available for the assignment. This is present in problems when a student opens
# the problem without the student needing to click the "Check Answers" button.
# If set to 1, then answer feedback is automatically shown when returning to an
# answered problem or after answers are available for the assignment. This is
# present in problems when a student opens the problem without the student
# needing to click the "Check Answers" button.
$pg{options}{automaticAnswerFeedback} = 1;

################################################################################
Expand Down Expand Up @@ -2055,15 +2056,15 @@ $ConfigValues = [
},
{
var => 'pg{options}{automaticAnswerFeedback}',
doc => x('Show automatic answer feedback when answers are available.'),
doc => x('Show automatic answer feedback'),
doc2 => x(
'Answer feedback will be available in problems after answers are available. Students will not even '
. 'need to click "Submit Answers" to make this feedback appear. Furthermore, the '
. '$showPartialCorrectAnswers variable set in some problems that prevents showing which of the '
. 'answers are correct is ignored.'
'Answer feedback will be available in problems when returning to a previously worked problem and '
. 'after answers are available. Students will not need to click "Submit Answers" to make this '
. 'feedback appear. Furthermore, the $showPartialCorrectAnswers variable set in some problems '
. 'that prevents showing which of the answers are correct is ignored after the answer date.'
),
type => 'boolean'
}
},
],
[
x('E-Mail'),
Expand Down
32 changes: 21 additions & 11 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,13 @@ sub warningMessage ($c) {
# hash of parameters from the input form that need to be passed to the translator, and $mergedProblem
# is what we'd expect.
async sub getProblemHTML ($c, $effectiveUser, $set, $formFields, $mergedProblem) {
my $showReturningFeedback =
!($c->{submitAnswers} || $c->{previewAnswers} || $c->{checkAnswers})
&& $c->{will}{showOldAnswers}
&& $c->ce->{pg}{options}{automaticAnswerFeedback}
&& $c->{can}{showProblemScores}
&& $mergedProblem->num_correct + $mergedProblem->num_incorrect > 0;

my $pg = await renderPG(
$c,
$effectiveUser,
Expand All @@ -1454,17 +1461,20 @@ async sub getProblemHTML ($c, $effectiveUser, $set, $formFields, $mergedProblem)
$set->psvn,
$formFields,
{
displayMode => $c->{displayMode},
showHints => $c->{will}{showHints},
showSolutions => $c->{will}{showSolutions},
refreshMath2img => $c->{will}{showHints} || $c->{will}{showSolutions},
processAnswers => 1,
QUIZ_PREFIX => 'Q' . sprintf('%04d', $mergedProblem->problem_id) . '_',
useMathQuill => $c->{will}{useMathQuill},
useMathView => $c->{will}{useMathView},
forceScaffoldsOpen => 1,
isInstructor => $c->authz->hasPermissions($c->{userID}, 'view_answers'),
showFeedback => $c->{submitAnswers} || $c->{previewAnswers} || $c->{will}{checkAnswers},
displayMode => $c->{displayMode},
showHints => $c->{will}{showHints},
showSolutions => $c->{will}{showSolutions},
refreshMath2img => $c->{will}{showHints} || $c->{will}{showSolutions},
processAnswers => 1,
QUIZ_PREFIX => 'Q' . sprintf('%04d', $mergedProblem->problem_id) . '_',
useMathQuill => $c->{will}{useMathQuill},
useMathView => $c->{will}{useMathView},
forceScaffoldsOpen => 1,
isInstructor => $c->authz->hasPermissions($c->{userID}, 'view_answers'),
showFeedback => $c->{submitAnswers}
|| $c->{previewAnswers}
|| $c->{will}{checkAnswers}
|| $showReturningFeedback,
showAttemptAnswers => $c->ce->{pg}{options}{showEvaluatedAnswers},
showAttemptPreviews => 1,
showAttemptResults => !$c->{previewAnswers} && $c->{can}{showProblemScores},
Expand Down
12 changes: 9 additions & 3 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ async sub pre_header_initialize ($c) {
}
}

# If this is set to 1 below, then feedback is shown when a student returns to a previously worked problem without
# requiring another answer submission.
my $showReturningFeedback = 0;

# Sticky answers
if (!($c->{submitAnswers} || $previewAnswers || $checkAnswers) && $will{showOldAnswers}) {
my %oldAnswers = decodeAnswers($problem->last_answer);
Expand All @@ -554,7 +558,9 @@ async sub pre_header_initialize ($c) {
# Clear answers if this is a new problem version
delete $formFields->{$_} for keys %oldAnswers;
} else {
$formFields->{$_} = $oldAnswers{$_} for keys %oldAnswers;
$formFields->{$_} = $oldAnswers{$_} for (keys %oldAnswers);
$showReturningFeedback = 1
if $ce->{pg}{options}{automaticAnswerFeedback} && $problem->num_correct + $problem->num_incorrect > 0;
}
}

Expand All @@ -580,10 +586,10 @@ async sub pre_header_initialize ($c) {
useMathView => $will{useMathView},
forceScaffoldsOpen => 0,
isInstructor => $authz->hasPermissions($userID, 'view_answers'),
showFeedback => $c->{submitAnswers} || $c->{previewAnswers},
showFeedback => $c->{submitAnswers} || $c->{previewAnswers} || $showReturningFeedback,
showAttemptAnswers => $ce->{pg}{options}{showEvaluatedAnswers},
showAttemptPreviews => 1,
showAttemptResults => $c->{submitAnswers},
showAttemptResults => $c->{submitAnswers} || $showReturningFeedback,
forceShowAttemptResults => $will{checkAnswers}
|| $will{showProblemGrader}
|| ($ce->{pg}{options}{automaticAnswerFeedback}
Expand Down

0 comments on commit 767fc94

Please sign in to comment.