How can I save additional data for each question retrieved from a JS library?

More
1 month 3 weeks ago #218643 by killmeplease
Hello everybody,
I would like to integrate this JS library webgazer.cs.brown.edu/ into the fruity theme. The library is for eye-tracking what the person taking the survey is looking at.
In the end I need to be able to see what the person that took the survey looked at for each question but separately (or the eye-tracking data will be a bit messy if it's saved for the questions of the whole survey all together). 
Adding the library into the head of the template as a source doesn't seem particularly hard to do (at least I hope), my struggle is that I need to save the data for each question separately.
I already extended the fruity theme and now I'm trying by editing it but I think that for what I have to do it's not enough, I may have to edit the question theme but right now LS doesn't allow me to (or maybe I didn't find the right option?). How can I do it?
I don't know how to save data like that and also I don't know how to access it later, I don't know how to proceed and I'm a bit stuck. If anyone could help me with some advice or ideas I would really appreciate, thanks in advance!
 

Please Log in to join the conversation.

More
1 month 2 weeks ago #218648 by DenisChenu
2 solution :

1. Learn development
2. Hire a developer : www.limesurvey.com/customization

Here, in my opinion : it's clearly something out of free help except if you shown what you try, ask some specific question.

See stackoverflow.com/help/how-to-ask

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago #218654 by killmeplease
Hello, thanks for your answer.
For reasons that I will not write here, I have to do this on my own and that's why I asked for some advice on how to proceed as I have no clue of where to start. I am trying to learn developement.
As I clearly wrote in my forum post, the question theme editor is not editable yet from LimeSurvey's website, so that's why I asked for some advice on how I could do that since: editing the question theme is the only thing that came to my mind; but if anyone has a better method I didn't find, I'd gladly listen to them.

Please Log in to join the conversation.

More
1 month 2 weeks ago #218662 by DenisChenu
I already give you bunch of plugin code for example.
Then : you know where you can start.

Else
gitlab.com/SondagesPro/coreAndTools/autoSaveAndQuit : add JS + check POST value
gitlab.com/SondagesPro/coreAndTools/reloadAnyResponse save something oin another DB each time respondent update response.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago #218664 by killmeplease
You didn't "give" me anything but it's okay, thanks anyway I guess.
I will be waiting if anyone else has any useful advice. Have a nice day!

Please Log in to join the conversation.

More
1 month 2 weeks ago - 1 month 2 weeks ago #218668 by DenisChenu
Sorry : you'rte right : near same questions before : forums.limesurvey.org/forum/development/...ta-for-each-question

I think it's you.

Else : Hour of coding and it's nothing … thousand of code line and it's nothing.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.
Last edit: 1 month 2 weeks ago by DenisChenu.

Please Log in to join the conversation.

More
1 month 2 weeks ago #218685 by holch
This has very little to do with Limesurvey, but rather Javascript. You will need to learn on how to implement Javascript library in Limessurvey, this should be fairly easy through a modified survey theme.

Then you need to tell this Javascript library on where to save the data it is generating. This should be possible to write into a hidden text question.

However, this is nothing that can be simply taught in the Limesurvey forum. You will need to learn the basics on how to use this library and how to define where to write the output of this library.

I don't think anyone will be willing to code this for you. You will have to do this on your own or hire someone (which you excluded already, ok, so your path is learning how this JS library works and how and where you can write the generated data. This has nothing to with Limesurvey. For Limesurvey you need only two things, I think (not a coding expert though):
1. How to implement the library into a survey theme
2. How to write the output into a Limesurvey question (in my opinion you probably won't need to modify the LS questions, you just need to choose the right question type and write the data in there. My guess would be that probably a normal huge text question would be the way to go. I have seen examples where a Javascript wrote data (e.g. about the browser, screen size, etc into a hidden text question. I don't see why this should not work for your eyetracking data. I assume you will analyze in an external application anyway.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago #218686 by killmeplease
Thank you for your kind answer!
I'd like to to clarify that I am not asking for help in "doing it", especially for the JavaScript part, I just asked what part of the survey theme/template is the one that has to be edited to do what I said I need to do in my post.
I am still not sure on the best way to proceed: if I should edit just the head of the survey theme or the question theme. If it's the second case, where can I do it? Because I haven't managed to find any page that allowed me to edit the question theme (I think this one is a LimeSurvey related question)
Also, what is a hidden text question? And what do you mean by "writing output into a LimeSurvey question"? Sorry for asking too many questions in case.

I may have phrased my post in an unclear way but I really just wanted to know what approach was best for saving the data of each question separately; but if you tell me that it's something doable only on the JS side then it's fine, I just needed to know that things were like that to stop being stuck on the "how do i proceed" part. Really, thank you again in advance.

Please Log in to join the conversation.

More
1 month 2 weeks ago #218687 by killmeplease
Yes, it's me. I phrased my post bad so it was hard to understand what I was asking but unfortunately I did not find a way to delete the post.
By the way I didn't understand the "else" part but I'm assuming it's better like this for both of us. Thanks anyway for taking your time to write here I guess.

Please Log in to join the conversation.

More
1 month 2 weeks ago #218696 by tpartner

I am still not sure on the best way to proceed: if I should edit just the head of the survey theme or the question theme.

You cannot edit question themes directly, you would need to create a custom question theme.

Having said that, you should be able to do what you want in a custom survey theme. You can include the WebGazer.js library in custom_header.twig.

Also, what is a hidden text question?

Create a long-text question and give it a CSS class "hidden. This will hide the question from the respondent but allow you to manipulate it with JavaScript. For testing, of course, you will want to leave the question visible.

And what do you mean by "writing output into a LimeSurvey question"?

I'm not going to dig into the WebGazer.js library but it seems to me that it should be something like this in the source of that hidden question:

webgazer.setGazeListener(function(data, elapsedTime) {
    if (data == null) {
        return;
    }
    var xprediction = data.x; //these x coordinates are relative to the viewport
    var yprediction = data.y; //these y coordinates are relative to the viewport
 
    $('#question{QID} textarea').val(data); // Load the data into this question
}).begin();

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: killmeplease

Please Log in to join the conversation.

More
1 month 2 weeks ago #218702 by killmeplease
Your answer was really helpful and kind, so thank you dearly.
I still have some doubts of course but this gave me a general idea on how to proceed so thank you again!

Please Log in to join the conversation.

More
1 month 1 week ago - 1 month 1 week ago #218889 by killmeplease
Hi, I am once again facing a bit of a problem and I thought it would be better to answer on this post rather than making a new one? If it's better to just write a new one let me know, it's no problem.Basically I'm still working on the "phase" before having to save the data and all, I simply imported the library as the script source and I'm trying to make it work but I'm getting some errors (second pic, the wider one) that I don't know how to solve. I tried importing the library on another website (w3schools) and hosting it on a local server and it worked fine, so I think it might be a LimeSurvey problem.I am currently working on Google Chrome, I also tried opening the same page on Edge and, weirdly enough, there the webcam for the eye-tracking didn't even show but in general the errors were similiar (first pic). Any idea why or how I could make it work? Thanks in advance! 
Attachments:
Last edit: 1 month 1 week ago by killmeplease. Reason: the first pic and second pic got inverted

Please Log in to join the conversation.

More
1 month 1 week ago #218890 by tpartner
It looks like the platform isn't loading before you call functions (or at all). Did you look for it in the page source?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
1 week 3 days ago #219687 by killmeplease
Yes, it seems to me too but in the page source I just find the same error in the library code, it's weird because the function is actually defined and on a local server (without using LS) it works. So I don't know how to fix.
But no worries, I switched to another library now! Unfortunately it's not open source and easy to use like webgazer but I'll see what I can do.

Please Log in to join the conversation.

More
1 week 3 days ago #219688 by killmeplease
Yes, it seems to me too but in the page source I just find the same error in the library code, it's weird because the function is actually defined and on a local server (without using LS) it works. So I don't know how to fix.
But no worries, I switched to another library now! Unfortunately it's not open source and easy to use like webgazer but I'll see what I can do.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now