Skip to content

Commit

Permalink
Add a correct answer "reveal" option.
Browse files Browse the repository at this point in the history
This option makes it so that correct answers are not visible and the
"Reveal" button must be clicked to show them even after answers are
available for students.  This was requested by @dlglin.
  • Loading branch information
drgrice1 committed Dec 14, 2023
1 parent 767fc94 commit 4f26479
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
17 changes: 16 additions & 1 deletion conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,19 @@ $pg{options}{periodicRandomizationPeriod} = 5;
$pg{options}{showCorrectOnRandomize} = 0;

###############################################################################
# automaticAnswerFeedback
# answer feedback options
################################################################################

# 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;

# If set to 1, then a "Reveal" button must be clicked to reveal correct answers
# even after the answer date.
$pg{options}{correctRevealBtnAlways} = 0;

################################################################################
# Single Problem Grader
################################################################################
Expand Down Expand Up @@ -2065,6 +2070,16 @@ $ConfigValues = [
),
type => 'boolean'
},
{
var => 'pg{options}{correctRevealBtnAlways}',
doc => x('Show correct answer "Reveal" button always'),
doc2 => x(
'A "Reveal" button must be clicked to make a correct answer visible any time that correct answers for '
. ' a problem are shown. Note that this is always the case for instructors before answers are '
. ' available to students, and in "Show Me Another" problems.'
),
type => 'boolean'
}
],
[
x('E-Mail'),
Expand Down
6 changes: 3 additions & 3 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,9 @@ async sub getProblemHTML ($c, $effectiveUser, $set, $formFields, $mergedProblem)
&& $c->can_showCorrectAnswersForAll($set, $c->{problem}, $c->{tmplSet})),
showMessages => 1,
showCorrectAnswers => (
$c->{will}{showProblemGrader}
|| (!$c->{previewAnswers} && $c->can_showCorrectAnswersForAll($set, $c->{problem}, $c->{tmplSet}))
? 2
$c->{will}{showProblemGrader} ? 2
: !$c->{previewAnswers} && $c->can_showCorrectAnswersForAll($set, $c->{problem}, $c->{tmplSet})
? ($c->ce->{pg}{options}{correctRevealBtnAlways} ? 1 : 2)
: ($c->{submitAnswers} || $c->{will}{checkAnswers}) && $c->{will}{showCorrectAnswers} ? 1
: 0
),
Expand Down
6 changes: 3 additions & 3 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,9 @@ async sub pre_header_initialize ($c) {
&& after($c->{set}->answer_date, $c->submitTime)),
showMessages => 1,
showCorrectAnswers => (
$will{showProblemGrader}
|| (!$c->{previewAnswers} && after($c->{set}->answer_date, $c->submitTime))
|| ($c->{submitAnswers} && $c->{showCorrectOnRandomize}) ? 2
$will{showProblemGrader} || ($c->{submitAnswers} && $c->{showCorrectOnRandomize}) ? 2
: !$c->{previewAnswers} && after($c->{set}->answer_date, $c->submitTime)
? ($ce->{pg}{options}{correctRevealBtnAlways} ? 1 : 2)
: (($c->{submitAnswers} || $will{checkAnswers}) && $will{showCorrectAnswers}) ? 1
: 0
),
Expand Down

0 comments on commit 4f26479

Please sign in to comment.