- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
directly accessing database during survey
- seitz01
- Topic Author
- Offline
- New Member
Less
More
9 years 7 months ago #112200
by seitz01
directly accessing database during survey was created by seitz01
Hi. For my bachelor thesis I want to implement
achievements
in an online survey and analyze the respondents reactions.
LimeSurvey looks very promising, but I don't know what would be the best way to implement the achievements.
Background:
For my bachelor thesis I want to implement achievements in an online survey. Eg. the user answers 50% of the questions and gets the achievement "50% answered!". During the survey there should be an overview regarding his or her unlocked and locked achievements.
What would be the best way to achieve this?
My Idea:
When the page gets loaded, a javascript queries the database for unlocked achievements and displays them.
When a Questions gets answered, a javascript looksup in the data base how many questions have been answered. If 50% of the questions have been answered, it displays the achievement. It also sets a value in the database, that the achievement has been unlocked.
I know how to execute a javascript, when a question gets answered. But how would I directly access the database in script?
Or is it possible to modify the PHP-Code? And where would be the best location to do that?
Or is there another way to achieve the described functionality?
Thanks for any help!
LimeSurvey looks very promising, but I don't know what would be the best way to implement the achievements.
Background:
For my bachelor thesis I want to implement achievements in an online survey. Eg. the user answers 50% of the questions and gets the achievement "50% answered!". During the survey there should be an overview regarding his or her unlocked and locked achievements.
What would be the best way to achieve this?
My Idea:
When the page gets loaded, a javascript queries the database for unlocked achievements and displays them.
When a Questions gets answered, a javascript looksup in the data base how many questions have been answered. If 50% of the questions have been answered, it displays the achievement. It also sets a value in the database, that the achievement has been unlocked.
I know how to execute a javascript, when a question gets answered. But how would I directly access the database in script?
Or is it possible to modify the PHP-Code? And where would be the best location to do that?
Or is there another way to achieve the described functionality?
Thanks for any help!
The topic has been locked.
- seitz01
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
9 years 7 months ago #112203
by seitz01
Replied by seitz01 on topic directly accessing database during survey
Rethinking my approach it would definitely be better to modify the PHP-Code.
Does anyone know how to do that?
Does anyone know how to do that?
The topic has been locked.
- Bigred01
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 33
9 years 7 months ago #112220
by Bigred01
Replied by Bigred01 on topic directly accessing database during survey
You can do an ajax call via javascript to a php file that runs your query then json encode the data.
Pass back any unique identifier via the php file link (ex /myphpfile.php?token={TOKEN}), grab it then use mysqli or pdo to do your query. (Do not use a plain MySQL query if you are passing data back through the link because people could potentially inject sql and you will have a very bad day).
Be weary of your php files read write permissions as well.
Hope this helps you get started.
Pass back any unique identifier via the php file link (ex /myphpfile.php?token={TOKEN}), grab it then use mysqli or pdo to do your query. (Do not use a plain MySQL query if you are passing data back through the link because people could potentially inject sql and you will have a very bad day).
Be weary of your php files read write permissions as well.
Hope this helps you get started.
The following user(s) said Thank You: seitz01
The topic has been locked.