Welcome to the LimeSurvey Community Forum

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

Checking if a survey is opened via mobile device?

  • DanielVN
  • DanielVN's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 7 months ago #168703 by DanielVN
Awesome :) Thanks a lot to all of you.
The topic has been locked.
More
6 years 7 months ago #168704 by orvil
Hi,

simplest way:

A - decide which info is required

1.) create a new question (textarea)
2.) use the "Source" button in the Question editor
3.) copy and paste joffm's script (it gives you more information than mine) into the editor area
3) save the question an run it

You will see something like this:
Code:
 
OS: Windows 7
Browser: Chrome 66 (66.0.3359.170)
Mobile: false
Flash: no check
Cookies: true
Viewport width: 2691
Viewport heigth: 1612
Screen Size: 3072 x 1728
 
Full User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36

B - delete the output not necessary for you. E.g. if you only need the mobile flag, reduce the part of the script (at the end)
Code:
...
...
 
$(document).ready(function() {  
 
    // Hide this question (remove double slash below to hide)
    //$('#question{QID}').hide();
 
    // Load the question
    $('#question{QID} textarea').val(
    'OS: ' + jscd.os +' '+ jscd.osVersion + '\n' +
    'Browser: ' + jscd.browser +' '+ jscd.browserMajorVersion +
      ' (' + jscd.browserVersion + ')\n' + 
    'Mobile: ' + jscd.mobile + '\n' +
    'Flash: ' + jscd.flashVersion + '\n' +
    'Cookies: ' + jscd.cookies + '\n' +
    'Viewport width: ' + jscd.vieww + '\n' +
    'Viewport heigth: ' + jscd.viewh + '\n' +
    'Screen Size: ' + jscd.screen + '\n\n' +
    'Full User Agent: ' + navigator.userAgent
    );
    });

to:
Code:
...
...
$(document).ready(function() {  
 
    // Hide this question (remove double slash below to hide)
    //$('#question{QID}').hide();
 
    // Load the question
    $('#question{QID} textarea').val(
 
        jscd.mobile;
 
    );
    });
 

So the result is only if it's o mobile device or not:
Code:
false
And you can use this result as an switch for other questions / relevance equations.
Don't forget tho hide the question. Either by the attributes Display > Always hide this question, or by 'decommenting' the line
//$('#question{QID}').hide();
into
$('#question{QID}').hide();

Best regards/Beste Grüße,
O. Villani
The topic has been locked.
More
6 years 7 months ago #168705 by orvil
Hi Joffm,
thanks for this script. Gives a lot of useful information on top. Will try to extend it to get the dpi too :)

Best regards/Beste Grüße,
O. Villani
The topic has been locked.
More
6 years 7 months ago #168706 by orvil
Hi DenisChenu,
thanks for the hint! I'm waiting desperately for some 3.x updates for the great plugins you've wrote.

P.S. And beside still for a solution for an update save em_core_helper.php

Best regards/Beste Grüße,
O. Villani
The topic has been locked.
More
5 years 7 months ago #184111 by Gustavo_Kremer
Replied by Gustavo_Kremer on topic Checking if a survey is opened via mobile device?
Hi. In previous posts Joffm's script is mentioned, but I'm not seeing it anywhere in the thread (just the last part). How/where can I find it?
Many thanks!!!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #184115 by Joffm
Hi, Gustavo,
my post disappeared because somebody banned me for a few hours (probably by mistake).

But obviously all my posts are gone.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
5 years 7 months ago - 5 years 7 months ago #184117 by DenisChenu
Replied by DenisChenu on topic Checking if a survey is opened via mobile device?
Yes, it's MY mistake … i want to thank you, but click on bad button … Really sorry … really sorry :blush: :blush: :blush:
Issue reported : bugs.limesurvey.org/view.php?id=14860

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
Last edit: 5 years 7 months ago by DenisChenu.
The topic has been locked.
More
5 years 7 months ago #184135 by Gustavo_Kremer
Replied by Gustavo_Kremer on topic Checking if a survey is opened via mobile device?
Hey, now it's back! Many thanks!
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose