How can I set autofocus on text input box for question and hit enter to move onto next question?

How can I set autofocus on text input box for question and hit enter to move onto next question?

par Nobuyuki Fujioka,
Nombre de réponses : 6

Moodle version 2.6.2

Quiz engine

How can I set auto-focus on text input box for question and hit enter to move onto next question?

I would like to build a speed maths quiz in my moodle website.

The problem I have at the moment is that, for each question, students need to move the cursor into the text input box to type in an answer with a mouse, then move the mouse again to Next Button to click, to move on to next question.  This takes too much time and effort for speed math quiz...

I would like to achieve something like Kahn academy's exercises or ixl maths exercises.

https://www.khanacademy.org/mission/math

http://uk.ixl.com/math/

How can I modify the moodle quiz engine to:

1) Auto-focus on the text input box for short-answer/numerical questions from the begining.

2) Hit Enter (without needing to click Next button) to move on to next question.

Your help is highly appreciated.

Kind regards,

Noby

Moyenne des évaluations  -
En réponse à Nobuyuki Fujioka

Re: How can I set autofocus on text input box for question and hit enter to move onto next question?

par Tim Hunt,
Avatar Core developers Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Peer reviewers Avatar Plugin developers

1. Would require adding some extra JavaScript to the page. Note that auto-focussing things can be bad for accessibility, which is why we don't do it.

2. Involved deleting some of the existing JavaScript. (https://github.com/moodle/moodle/blob/master/question/qengine.js#L155 ) This is done to prevent student getting graded wrong if they accidentally hit the enter key. I have been playing with Kahn academy, and have accidentally hit enter when I was aiming for backspace, and it is very annoying. 

En réponse à Tim Hunt

Re: How can I set autofocus on text input box for question and hit enter to move onto next question?

par Nobuyuki Fujioka,

Hi, Tim

Thank you for your comment.

But, I would love to have concrete solutions to my questions.

1. Could you tell me the extra JavaScript and where to add it?  I am not a programmer, but I can insert code into a file.
    I am not worried about accesibility at the moment.

2. Still, I would love to hit Enter.  Please tell me which bits I need to delete (without deleting the Next Button).

Thank you very much for your help.

 

Kind regards,

Noby

En réponse à Nobuyuki Fujioka

Re: How can I set autofocus on text input box for question and hit enter to move onto next question?

par Nobuyuki Fujioka,

Could anyone answer my questions above?

Thank you,

Noby

En réponse à Nobuyuki Fujioka

Re: How can I set autofocus on text input box for question and hit enter to move onto next question?

par Andrew Lyons,
Avatar Core developers Avatar Moodle HQ Avatar Particularly helpful Moodlers Avatar Peer reviewers Avatar Plugin developers Avatar Testers

As Tim says, this is a really bad idea. It's poor in terms of usability, and in terms of accessibility. I would strongly recommend against doing this.

It is also difficult to get right in a cross-browser manner. Typically, the <Return> key is used to submit the form so you'll have to add an event handler to the form and check for submission by use of the <Return> key, then prevent the default browser behaviour. I'm not sure whether the form submission information will reliably and consistently include information on the source of the submission or not which will make things very hard to get right.

You will also need to listen on the body for the return key and have it do the right thing with regards moving to the next form field (something you'll have to calculate too).

I'm afraid that I'm not going to go and write the code for this for you but hopefully the above will either prompt you to give us more information on your real requirements, or give you the appropriate pointers do make the changes.

Best wishes,

Andrew

En réponse à Andrew Lyons

Re: How can I set autofocus on text input box for question and hit enter to move onto next question?

par Nobuyuki Fujioka,

Hi, Andrew

 

I cannot believe that you think this is a bad idea.  Many maths website for kids do have auto focus and hit enter for maths exercises.

The point of this is make the operation as simple as possible for kids and gamify it.  But, the moodle is more geared up for university or secondary school students...?

The current quiz engine's usability is not good at all for young children because many young ones do not find easy to use mouse for every question, and even the Next button sometimes do not show up in the screen in the current moodle setting.

In terms of accessibility, I am creating some questions with some visual patterns, which cannot be read out with sound by computer.  So, accessibility for people with sight issue is not the main focus for these question types here.

I have actually asked one kid (7 year old) and he agreed with the points above after trying the moodle quiz engine and other maths websites for kids.

Do anybody agree with me on the above points? I hope Moodle community will listen to my requests and issues?

At the moment, I am having to ask a programmer to create a scorm package to solve this issue...so that I do not use the Moodle quiz engine.

Kind regards,

Noby

En réponse à Nobuyuki Fujioka

Re: How can I set autofocus on text input box for question and hit enter to move onto next question?

par Nobuyuki Fujioka,

Hi,

 

Can anyone help me out on this?  I do not mind paying if I can achieve this.

Your help is highly appreciated.

 

Kind regards,

Noby