File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff 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). */ 
629632function  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. 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments