How to collect response time with "Form_Text_Input" and Javascript?
Hello everyone,
I've been trying to measure "time_form_text_input" with Opensesame. The reason why I decided to use "form_text_input" is because the experiment that my professor and I are working on requires the participant to submit their responses in writing. They are required to submit an essay of sort, and we plan to time how long does it take to write their answers down. However, while the code works when I tested it on Opensesame (it recorded the "time_form_text_input"), it refused to work on JATOS, both local and remote. I am wondering if I missed something from my code.
Here I have uploaded the test version of the experiment. The experiment will have a similar structure to this one.
This how the items are arranged:
This is the code that I use for the "inline_javascript" that is before the "form_text_input":
This is the code that I use for the "inline_javascript" after the "form_text_input":
I have tried different versions of the code, and I've tried putting it in the "prepare" stage and the "run" stage, but none of them seems to work. I'm sure I'm missing something, but I'm not sure what goes wrong. Do you have any advices on what I should do? Any kind of help will be greatly appreciated.
Thank you so much in advance for your help.
Best Regards,
Joshua
Comments
Hi @Joshua_Gabriel ,
There are two issues here:
vars
object so that they are preserved across scripts and logged. (In OpenSesame 4.0/ OSWeb 2.0, variables will be persistent, but right now they are not yet, see also here.)However, OpenSesame also automatically keeps track of timestamps through
time_[item name]
variables. So you can probably already infer the response time from these! See also here.— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan
Thank you for your reply. I have tried fixing the code per your advice. I have moved the code to the Run phase, and I have tried to attach the start time and response time to the vars object. Here's what I came up with:
I have also put "time_[item name]" variables on the "logger". However, just like before, while it indeed worked while I tested it on Opensesame, it still doesn't work when I uploaded it to JATOS, both the local one and the one on Mindprobe.
Is it possible that there are some issues when the experiment is converted for JATOS?
Thank you for your attention.
Best Regards,
Joshua
Hi @Joshua_Gabriel ,
You're using the
var
keyword to declare a variable. However, you need to use properties of thevars
object. Specifically, before the form, you have a script that logs the start time:And after the form you have another script that logs the end time:
Hope this helps!
-- Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Dear @sebastiaan
Thank you for your help. I have tried the code you gave me. Unfortunately, like before, while the Javascript was able to detect the response time, the logger didn't log what had been detected by the Javascript.
To make it clearer, here is a screenshot from when I tested the experiment on Chrome, and inspected the elements:
As it can be seen, the Javascripts were able to detect the time, namely "5588", "7694", and "818714", for the respective "form_text_input" items. However the final results that were recorded by the logger remained to be "null" for all three "form_text_input" items. I think this is unusual, as I have included the "time_[item name]" in the logger, and as can be seen above, the "time_new_inline_javascript" items worked perfectly, while the "time_new_form_text_input" failed to work properly. I have consulted a friend of mine who is experienced in coding, and she too was baffled by it.
However, since the Javascript could detect the time properly, I am wondering if there is a way to circumvent this problem? For example, could we perhaps directly extract the data from the inline_Javascript items? Or do we have to totally rely on the logger to extract the relevant data?
If it will help to better illustrate the problem, here is the mock experiment that I have been using in order to solve this issue:
Thank you so much for your kind help.
Best Regards,
Joshua
Hi @Joshua_Gabriel ,
You're storing the response time in a variable called
response_time
; however, this variable is not included in thelogger
. In addition, you're using the same variable (response_time
) three times in a row, but logging it only once at the very end. This means that you will only log the last response time. To fix that, you need to:response_time1
,response_time2
,response_time3
) and log them all;Hope that clears things up!
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan
Thank you for your reply. Based on your advices, I have modified my questionnaires, and I believe my problems have been fixed.
Thank you for your assistance!
Best Regards,
Joshua