- Posts: 11656
- Thank you received: 2742
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?
- holch
- Away
- LimeSurvey Community Team
Less
More
2 years 8 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 8 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 8 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: 10108
- Thank you received: 3593
2 years 8 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 8 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 8 months ago - 2 years 8 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 8 months ago by killmeplease. Reason: the first pic and second pic got inverted
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
2 years 8 months ago #218890
by tpartner
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?
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.
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago #219687
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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.
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.
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago #219688
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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.
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.
The topic has been locked.
- killmeplease
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 7 months ago #219689
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
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.
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.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
2 years 7 months ago #219690
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 see pjax : the pjax system is old, what is your limesurvey version ?
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 #219744
by killmeplease
Replied by killmeplease on topic How can I save additional data for each question retrieved from a JS library?
I'm editing on the online editor, so it should be the latest (I think)
The topic has been locked.