Jump to ContentJump to Navigation/Login
` ` ` ` ` `

[Register]

Occasional ATutor release updates


    (6 guests in past 15 min.)

    Access Understanding Web Accessibility to learn about accessibility, or Register to take the course for FREE.

    Support Forums

    ATutor Support

    How to stop the "enter" key from submitting a test/survey


    You must be signed-in to post.

    AuthorSubject
      Page: 1
    gtilflm
    Subject: How to stop the "enter" key from submitting a test/surveyQuote this post in your reply
    Hello. I've been noticing that when students are entering an answer to a text box and they press "Enter", it submits the test. Of course, they don't need to do that, but when they do it submits and incomplete test. Would there be a way to....

    1.) Disassociate the enter button and the submit action, or,
    2.) Have a pop-up appear that says, "Would you like to submit this test?" with a Yes/No option.


    Thank you!
    Posted: 2009-10-29 13:01:35
    harris

    Avatar for harris
    Subject: Re: How to stop theQuote this post in your reply
    Are all questions on the same page?
    Posted: 2009-10-29 14:13:50
    gtilflm
    Subject: Re: How to stop theQuote this post in your reply
    Yes. They are.
    Posted: 2009-10-29 14:20:05
    greg

    Avatar for greg
    Subject: Re: How to stop theQuote this post in your reply
    There's not a confirmation currently when submitting a test, but that would be a good feature. I've added it to the tracker:

    www.atutor.ca/atutor/mantis/view.php?id=3980
    Posted: 2009-10-30 13:57:32
    gtilflm
    Subject: Re: How to stop theQuote this post in your reply
    Greg,

    Ok. In the meantime, is there any way to turn off the "enter button = sumbit" behavior by code?

    Thank you.
    Posted: 2009-10-30 14:09:02
    greg

    Avatar for greg
    Subject: Re: How to stop theQuote this post in your reply
    You'd need to replace it with a javascripted button.

    Google it. There'll be examples you can copy from.
    Posted: 2009-10-30 14:20:29
    gtilflm
    Subject: Re: How to stop theQuote this post in your reply
    Solved.

    For those that are interested, here's what I did. Following the instructions at www.arraystudio.com/as-workshop/disable-form-submit-on-enter-keypress.html...

    1. Insert the following into ATutor/themes/your_theme/include/header.tmpl.php


    <?php
    <script language="JavaScript">
    function disableEnterKey(e)
    {
         var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox

         if(key == 13)
              return false;
         else
              return true;
    }
    </script>
    ?>




    2. Any question types with an input field in ATutor/your_theme/default/test_questions/question_type_with_text_input_area put:


    <?php
    "onKeyPress="return disableEnterKey(event)"
    ?>




    into the <input> tag.

    Like this:

    <input type="text" onKeyPress="return disableEnterKey(event)" name="answers[<?php echo $this->row['question_id']; ?>]" class="formfield" size="15" value="<?php echo htmlspecialchars($this->response); ?>" />



    Enjoy!
    Posted: 2009-10-30 17:56:25
     Page: 1

    You must be signed-in to post.