In short answer questions, hitting enter seems to go to the previous question.

Any thoughts on how to fix?

Thank you!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

michaelk’s picture

I am also running into this issue. Has anyone found a solution?

michaelk’s picture

Status: Active » Needs review
FileSize
2.57 KB

I was able to track down the cause of this issue and specific steps to reproduce it.

Steps to Reproduce:

  1. Create a new Quiz with Back navigation enabled
  2. Create several (at least 3) Short Answer questions on that quiz
  3. Take the Quiz
  4. Use the Enter key to submit your answers instead of clicking the submit buttons
  5. You will notice that the navigation action taken will always be the same as the first submit button displayed (except in IE 7 or 8 which doesn't navigate forward or backward at all due to another bug)

There are essentially 2 issues here:

  1. All recent browsers (IE9+, Chrome, Safari, Firefox) pick the first form submit button from the HTML source when the form is submitted with the Enter key, and when there is a Back button this is the first button and thus the one selected.
  2. IE 7 and 8 don't submit any button when Enter is pressed, so essentially no operation is passed through in POST which is not handled correctly by the module currently.

You can read more about all of these issues and various workarounds in these articles:

I have attached a patch which addresses both of these issues in a way that works for all browsers (tested in IE, Chrome, Safari, and Firefox) and does not require javascript to work. Essentially it just introduces a hidden submit button before all of the other navigation controls, so it is always the default. Also, it adds a hidden form element to detect the case of the form being submitted with the Enter key in IE 7 and 8.

tasetta’s picture

Awesome, I was just looking for this. I have never done a patch before however, could you tell me how I apply it?

michaelk’s picture

Sivaji_Ganesh_Jojodae’s picture

Component: Code - Short/long answer » Code - Quiz core
Status: Needs review » Needs work

@michaelk,

I'm not sure if an additional hidden field is needed for this.

Is it not possible to fix this by changing the weight of existing buttons in answering form (by placing them in order Submit, Back and Skip) and with CSS we could again make them appear in the same order as it is now. I remember fixing this in one of the client projects. I will see if i can get the fix.

michaelk’s picture

@sivaji

I looked into doing it with CSS first as it would have been cleaner, but I wasn't able to come up with CSS that positioned the buttons nicely in all of the different cases (with and without Back and Skip buttons).

Also, changing the order of the buttons will not address the issue with IE 7 and 8 where submitting the form using Enter does not even include a button value in POST and thus it doesn't navigate forward or backward.

mikran’s picture

Issue summary: View changes
Status: Needs work » Fixed

This is committed in d01f8b49 so marking as fixed altough it broke custom #validate functions from answering forms. Opening a new follow-up (#2216267: Custom form validate functions stopped working as a result of 'press Enter fix'.) with that.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

  • Commit d01f8b4 on 7.x-4.x, 7.x-5.x authored by michaelk, committed by paalj:
    Issue #1659400 by micahelk: Set Next/Finish as default submit button...

  • Commit d01f8b4 on 7.x-4.x, 7.x-5.x, quiz-pages authored by michaelk, committed by paalj:
    Issue #1659400 by micahelk: Set Next/Finish as default submit button...

  • Commit d01f8b4 on 7.x-4.x, 7.x-5.x, quiz-pages, 2269219 authored by michaelk, committed by paalj:
    Issue #1659400 by micahelk: Set Next/Finish as default submit button...

  • Commit d01f8b4 on 7.x-4.x, 7.x-5.x, 2269219 authored by michaelk, committed by paalj:
    Issue #1659400 by micahelk: Set Next/Finish as default submit button...
fuzzy76’s picture

Version: 7.x-4.0-alpha7 » 7.x-5.x-dev
Status: Closed (fixed) » Patch (to be ported)

This is happening in 7.x-5.x and I cannot find the code from the patch anywhere in the module.

fuzzy76’s picture

Any chance of getting this in?

djdevin’s picture

Status: Patch (to be ported) » Needs work
djdevin’s picture

Patch doesn't port at all, also since more browsers are now unsupported it might be a different approach.

fuzzy76’s picture

FWIW, this prevents any site running Quiz from being WCAG compatible.

djdevin’s picture

Status: Needs work » Needs review
FileSize
917 bytes

This might work?

  • djdevin committed 91cb79c on 7.x-5.x
    Issue #1659400 by michaelk, djdevin: Hitting "Enter" goes to previous...
djdevin’s picture

Status: Needs review » Fixed

I tested this in FF and Chrome and was able to submit a short answer question by typing it in and then pressing enter.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.