Skip to content

Commit 2e808bb

Browse files
Once it's all correct, asking for a hint verifies this
Signed-off-by: David A. Wheeler <[email protected]>
1 parent 72a9c54 commit 2e808bb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/labs/checker.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ function showHint(e) {
561561
// Get data-indexes value using e.target.dataset.indexes
562562
// alert(`Form id = ${e.target.form.id}`);
563563
let attempt = retrieveAttempt();
564+
565+
// Check if the answer's already correct. This shouldn't happen, since
566+
// it was already checked. This is just a little defensive programming.
564567
if (calcMatch(attempt, correctRe)) {
565568
alert(t('already_correct'));
566569
} else if (!hints) {
@@ -627,7 +630,16 @@ function maybeShowAnswer(e) {
627630

628631
/** Maybe show a hint to the user (depending on timer). */
629632
function maybeShowHint(e) {
633+
// If answer is correct, confirm it and don't cause a penalty.
634+
let attempt = retrieveAttempt();
635+
if (calcMatch(attempt, correctRe)) {
636+
alert(t('already_correct'));
637+
return;
638+
}
639+
640+
// Answer is not correct. Determine if delay time has passed.
630641
let elapsedTime = elapsedTimeSinceClue();
642+
631643
// Only enforce delay timer if changedInputSinceHint is true. That way,
632644
// people can re-see a previously-seen hint as long as they
633645
// have not changed anything since seeing the hint.

0 commit comments

Comments
 (0)