- Posts: 18
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How can I save additional data for each question retrieved from a JS library?
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
2 years 7 months ago #218643
by killmeplease
How can I save additional data for each question retrieved from a JS library? was created 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!
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!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
2 years 7 months ago #218648
by DenisChenu
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.
Replied by DenisChenu on topic How can I save additional data for each question retrieved from a JS library?
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
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.
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago #218654
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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.
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.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
2 years 7 months ago #218662
by DenisChenu
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.
Replied by DenisChenu on topic How can I save additional data for each question retrieved from a JS library?
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.
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.
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago #218664
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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!
I will be waiting if anyone else has any useful advice. Have a nice day!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
2 years 7 months ago - 2 years 7 months ago #218668
by DenisChenu
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.
Replied by DenisChenu on topic How can I save additional data for each question retrieved from a JS library?
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.
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: 2 years 7 months ago by DenisChenu.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
2 years 7 months ago #218685
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic How can I save additional data for each question retrieved from a JS library?
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.
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.
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago #218686
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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.
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.
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago #218687
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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.
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.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
2 years 7 months ago #218696
by tpartner
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.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How can I save additional data for each question retrieved from a JS library?
You cannot edit question themes directly, you would need to create a custom question theme.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.
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.
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.Also, what is a hidden text 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:And what do you mean by "writing output into a LimeSurvey question"?
Code:
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
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago #218702
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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!
I still have some doubts of course but this gave me a general idea on how to proceed so thank you again!
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago - 2 years 7 months ago #218889
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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: 2 years 7 months ago by killmeplease. Reason: the first pic and second pic got inverted
The topic has been locked.