Is it possible to add timing to display logic? | XM Community
Solved

Is it possible to add timing to display logic?

  • 25 September 2020
  • 8 replies
  • 73 views

In a survey project that I am doing, I have a multiple choice question that brings up text questions using in page display logic. Clicking on different choices on the multiple choice question brings up a different text question within the same page. I need to know how long each text question is displayed.
I thought I could do this using a timing question, but the data recorded doesn't record how long each question was displayed, but rather the first and last clicks and when the user moved to the next page. I already tried using page breaks, but then it takes away the functionality of being able to access another one of the text questions through the multiple choice question, and it is important that user is able to select between the other options. And since there is no way to loop using survey flow, this was the solution I came up with.
So I am wondering if I am able to use Javascript (I don't have Javascript experience) or something that allows the survey to record how long each text question is displayed. Or at the very least allow me to figure it out, like perhaps recording the amount of time in between each selection or click.

icon

Best answer by npetrov937 30 September 2020, 00:12

View original

8 replies

Userlevel 4
Badge +4

Hi,
This is indeed possible and there are many ways to approach this.
Given the relatively few constraints you have suggested above, I attach a quick .qsf I put together for you. The key JS is in the MCQ question.
This will give you the total time (in seconds) each option was presented (recorded as embedded variables). Note that if a person switches between, say, option 1-option 2-option 1, this solution will add all times option 1 (ditto for any option) was on the screen to the total display time.
Note as well that this code is far from optimal but given your inexprience with javascript, it could be easy for you to get into it fairly quickly if you have at least a bit of coding experience in general. If you have more options, you will just need to copy-paste some of the blocks of code and swap numbers.
Hope this helps.
Is_it_possible_to_add_timing_to_display_logic.qsf

Thank you so much!! I will immediately get to adding this to my survey.

Hello npetrov937 I am doing a task where I would like to add timing to display logic. People are presented a message if they spend greater than 30 seconds on a text entry question. Are you able to work this out as well? I would really appreciate it : )

Userlevel 4
Badge +4

RahulPatel Sure - I'd suggest using HTML and JS for that.
Specifically, create a blank div element in your text entry question

 





Please enter your response here:

Then with your JS, simply change the content of that div element after desired time:

Qualtrics.SurveyEngine.addOnload(function()
{

let seconds_on_task = 5

// change message content by pointing to the class
function change_message_func() {
jQuery(".overtime_message").html('You have spent more than ' + seconds_on_task.toString() + ' seconds on this task')
}

setTimeout(change_message_func, seconds_on_task*1000) // multiplying by 1000 to convert to ms

});

Working .qsf attached.

Hope this helps.
add_timing_to_display_logic.qsf

Hi npetrov937 ,
I stumbled onto this page in search for a solution to a similar problem as the two above.
I have a series of text entry questions, and I'd like an error message to appear if the text entry box isn't clicked within x seconds (without necessarily typing in it or submitting an answer within that time). Is that possible?
Thanks for your help!±

Userlevel 4
Badge +4

https://community.qualtrics.com/discussion/comment/38543#Comment_38543Hi,
yes, that sounds possible. The idea would be similar to the above: create a blank div element to display the error message and start a timeout function. Make sure to save the id of the timer in a variable; using the above example that'd be something like
let timerID = setTimeout(change_message_func, seconds_on_task*1000)
Then, add an event listener to the your text entry box that would be looking for the kind of interaction you want. Point to the element using jQuery, i.e. jQuery('text-entry-field-selector'), and add an event listener that would clear the timeout (i.e. the message won't appear); something like this:
let timerID = setTimeout(change_message_func, seconds_on_task*1000)

jQuery('text-entry-field-select').bind("click keydown keyup", function() {
// check if defined in case a few events are triggered
if (typeof timerID !== 'undefined') {
clearTimeout(timerID)
}
});

Thank you!!

Hi npetrov937, I came across this question when working on a similar issue. When I load the .qsf file provided (Is_it_possible_to_add_timing_to_display_logic.qsf), I can get it to work initially. However, when I try to change minor things about the question (e.g., changing the format from Vertical to Horizontal response options), the timing no longer appeared to work. The display settings still work, but the display time always ended up being 0.
Do you know if there is something that changes in the underlying html or variable coding when that format setting changes that would invalidate the JavaScript that was written?
Thank you

Leave a Reply