directly accessing database during survey

More
3 years 3 months ago #112200 by seitz01
seitz01 created the topic: directly accessing database during survey
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!

Please Log in to join the conversation.

More
3 years 3 months ago #112203 by seitz01
seitz01 replied the 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?

Please Log in to join the conversation.

More
3 years 3 months ago #112220 by Bigred01
Bigred01 replied the 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.
The following user(s) said Thank You: seitz01

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!