Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update answerHints to not produce hints in Preview mode #476

Merged
merged 2 commits into from
Oct 29, 2020

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented May 19, 2020

This PR adjusts the answerHints macro to not produce answer hints in preview mode unless a flag is set allowing that.

See #468.

@taniwallach
Copy link
Member

This seems to work as expected, including all the configuration/override switches, and that is a big improvement over the simple hack I had proposed in #468 .


I tested with the sample file from: #468 and then made some revisions to test with the switches.

As expected, by default - preview no longer shows the message.

Adding processPreview => 1 as below and a second message and third message (to test the various options):

   (-1 * $ans1) => [ "You seem to have a sign error", score =>0.50, processPreview => 1],
   (2 * $ans1) => [ "Your answer is double the correct answer", score =>0.25 ],
   (3 * $ans1) => [ "Your answer is double the correct answer", score =>0.10, processPreview => 0 ],

showed that processPreview overrode the new default behavior for a single message.

Adding answerHintsProcessPreview => 1 into the cmp() arguments changed the default, and quick testing was done also with answerHintsProcessPreview => 0.


Revised test file with use of switches:

DOCUMENT();
  
loadMacros(
   "PGstandard.pl",
   "MathObjects.pl",
   "answerHints.pl",
);

Context("Numeric");

$ans1 = Real(1);

Context()->texStrings;
BEGIN_TEXT
\( i^4 \) = \{ $ans1->ans_rule(3) \}
END_TEXT
Context()->normalStrings;

ANS( $ans1->cmp( answerHintsProcessPreview => 1 )->withPostFilter(AnswerHints(
   $ans1 => ["",replaceMessage=>0],
   (-1 * $ans1) => [ "You seem to have a sign error", score =>0.50, processPreview => 1],
   (2 * $ans1) => [ "Your answer is double the correct answer", score =>0.25 ],
   (3 * $ans1) => [ "Your answer is triple the correct answer", score =>0.10, processPreview => 0 ],

)));

ENDDOCUMENT();

@taniwallach taniwallach self-requested a review May 19, 2020 14:27
Copy link
Member

@taniwallach taniwallach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and working properly.

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as expected. I am just not sure what is going on with lines 126-130.

macros/answerHints.pl Show resolved Hide resolved
macros/answerHints.pl Show resolved Hide resolved
@taniwallach taniwallach added this to the PG-2.16 milestone Aug 24, 2020
@taniwallach
Copy link
Member

Merging and closing #379

@taniwallach taniwallach merged commit 91d00c8 into openwebwork:develop Oct 29, 2020
@dpvc dpvc deleted the answerHints-preview branch December 9, 2020 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants