- Posts: 26
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
do not advance to next question until respondent allows to be geolocated
- suselko
- Topic Author
- Offline
- Junior Member
Less
More
4 years 1 week ago #195479
by suselko
do not advance to next question until respondent allows to be geolocated was created by suselko
I have a mobile phone-based survey with a hidden question that stores the respondent's geographical coordinates. A system window pops up asking the respondent if they allow to be geolocated. It works fine on iPhones as the respondent has to to 'allow' or 'disallow' before they can tap on LimeSurvey's 'Next' button. But it doesn't work well on Android phones as the respondent can just tap on the 'Next' button without doing anything to that pop-up window. When this is done, the survey proceeds to the next question and the pop-up window disappears. Any ideas how I could either (1) make the 'Next' button inactive until the respondent 'allows' or 'disallows' geolocation; or (2) force the pop-up window to stay on screen until 'allow' or 'disallow' is tapped (even if LimeSurvey has moved on to the subsequent questions). Basically anything that addresses the problem! The survey group file is attached. Many thanks.
Attachments:
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
4 years 1 week ago #195507
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 do not advance to next question until respondent allows to be geolocated
1 : can be done with javascript / jquery : see
stackoverflow.com/questions/6092400/is-t...ined-with-javascript
2 : it's a browser system i think, can not be updated.
2 : it's a browser system i think, can not be updated.
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.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
4 years 1 week ago - 4 years 1 week ago #195519
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 do not advance to next question until respondent allows to be geolocated
suselkois already using the error callback in the getCurrentPosition() function so maybe something like this.
Note that there may be a delay as the getCurrentPosition() function fires so you may want to incorporate a loading graphic of some sort.
Note that there may be a delay as the getCurrentPosition() function fires so you may want to incorporate a loading graphic of some sort.
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var q1ID = '{QID}'; var q1 = $('#question'+q1ID); // Disable the "Next" button $('#ls-button-submit').prop('disabled', true); function getGPS() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showGPS, gpsError); } else { $('input.text', q1).val('No GPS Functionality'); $('input:hidden[id^="answer"]', q1).val('No GPS Functionality'); } } function gpsError(error) { alert('GPS Error: '+error.code+', '+error.message); } function showGPS(position) { $('input.text', q1).val(position.coords.latitude+', '+position.coords.longitude); $('input:hidden[id^="answer"]', q1).val(position.coords.latitude+';'+position.coords.longitude); // Enable the "Next" button $('#ls-button-submit').prop('disabled', false); } getGPS(); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 1 week ago by tpartner.
The topic has been locked.
- suselko
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 26
- Thank you received: 0
4 years 1 week ago #195528
by suselko
Replied by suselko on topic do not advance to next question until respondent allows to be geolocated
Many thanks both, Tony's script solved the issue.
The topic has been locked.
- Andrewsss
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
3 years 11 months ago #196273
by Andrewsss
Replied by Andrewsss on topic do not advance to next question until respondent allows to be geolocated
Is it possible if user by accident click block location, add one more button with click and survey asking again user location?
The topic has been locked.