ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


How to stop the enter key from submitting a testsurvey


  • 2009-10-29 13:01:35

    How to stop the enter key from submitting a testsurvey

    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!

  • 2009-10-29 14:13:50

    Re: How to stop the

    Are all questions on the same page?

  • 2009-10-29 14:20:05

    Re: How to stop the

    Yes. They are.

  • 2009-10-30 13:57:32

    Re: How to stop the

    There's not a confirmation currently when submitting a test, but that would be a good feature. I've added it to the tracker:

    http://www.atutor.ca/atutor/mantis/view.php?id=3980

  • 2009-10-30 14:09:02

    Re: How to stop the

    Greg,

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

    Thank you.

  • 2009-10-30 14:20:29

    Re: How to stop the

    You'd need to replace it with a javascripted button.

    Google it. There'll be examples you can copy from.

  • 2009-10-30 17:56:25

    Re: How to stop the

    Solved.

    For those that are interested, here's what I did. Following the instructions at http://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>
    [/php]

    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)"
    [/php]

    into the <input> tag.

    Like this:

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



    Enjoy!