Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

directly accessing database during survey

More
10 years 11 months ago #112200 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!
The topic has been locked.
More
10 years 11 months ago #112203 by seitz01
Rethinking my approach it would definitely be better to modify the PHP-Code.
Does anyone know how to do that?
The topic has been locked.
More
10 years 11 months ago #112220 by Bigred01
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
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose