How To: Convert surveys From Windows To Android

Overview

Converting a survey from Windows to Android is pretty simple, although it has to be followed by a few steps in order to make it work.
However, this How-To will show you how either to convert your survey or to keep it a Cross-Platform survey, supported by Windows & Android.

For general information, Windows based devices support Both C# & JavaScript syntax and of course our built in functions.

Android based devices are supporting only JavaScript syntax and our built in functions, they do not support C#.

This ‘How To’ will cover the following:

1. How to actually switch between ‘Windows Based Surveys’ To ‘Android Based Surveys’

2. What is needed to change before switching and why?

3. Removing scripts, converting the survey and re-adding the scripts.

Let’s do it!

1. How to actually switch between ‘Windows Based Surveys’ To ‘Android Based Surveys’:

If you go to the survey’s advanced tab, you would see the two options at the bottom:

This choice will affect your survey’s scripts later on.
For example, if chosen ‘Windows Based Devices’, you would not be able to write any custom JavaScript Code.
However, if you haven’t programmed your survey to be Cross-Platform, you would get an error message while doing it, so you would need to go through the process described below.

2. What is needed to change before switching and why?

Basically, this is simpler than what it looks like.
There are 3 simple rules to follow:
a. Windows Based Surveys support C# and JavaScript.
b. Android Based Surveys support JavaScript only.
c. Do not forget rules ‘a’ and ‘b’ J.

If you are not a programmer and you are not familiar with C# or JavaScript, you should have no worries, as the built-in functions which you would be using, are Cross-Platform.

The common differences which usually cause converting problems from C# variables to JavaScript, are use of C# variables, such as:
int;

double;

float;

char;

etc’

Instead of JavaScript’s variable:
var;

Things that you would need to change:

  • Functions definitions you implemented in the ‘Advanced Scripts’.
    As you can see, my function wouldn’t validate as I wrote it in JavaScript and the survey is set to ‘Windows Based Surveys’.
    If this was a function in C#, and we were converting to ‘Android Based Surveys’ we would encounter with an error, and should have implement it in JavaScript instead.
  • A Questions ‘Start Scripts’ and ‘End Scripts’.
    Here for example, I used our built-in functions, which are Cross-Platform.
    Hence, it would work on both Android & Windows based surveys.
  • A Questions Rules, for example:
    You would need to verify that your rules do not use any problematic syntax:

3. Removing scripts, converting the survey and re-adding the scripts.

Ok, for the main and final step, here I will describe how we recommend doing do whole process of converting your survey.
Lets say for example, our survey is currently a ‘Windows Based Survey’ and we have lots of C# syntax all over it.
We wouldn’t be able to change the syntax to JavaScript, at the moment, as it will prompt with an error.
However, we also wouldn’t be able to switch the survey into ‘Android Based Survey’, seems like we are stuck?
Here is the process:

  1. Go over your survey (all of the locations I indicated in part 2 which include ‘Entrance Rules, Validation rules, Jump Rules, Start scripts, End scripts’), Cut & Paste, First of all, all of your non-cross-platform scripts which use C# syntax, besides the ‘Advanced Scripts’ , to windows notepad.
  2. After that, Cut & Paste all of the ‘Advanced Scripts’ to the same notepad.
    Soon we will paste them back to the survey, so you better write yourself some relevant info about it so you remember where to paste it back, for example:
    Here I just wrote to myself the number of the question, and the location I cut the script from (the script in yellow has no sense, it is just for the example)

    When you get lots of these it is much more comfortable to write some notes in order to prevent mistakes when pasting it back.
  3. Now, after you removed all of your scripts which contain C# elements (There is no need to remove STG’s Built-in Functions, as they are Cross-Platform),
    You should edit your code in the notepad, to be implemented with Java Script.
  4. After all code in the notepad is changed into JavaScript, Switch your survey into ‘Target Android Based Devices’ as I described in part 1.
    Paste your scripts back, first of all to the ‘Advanced Scripts’, then, to the rest of the survey in the correct places, and you should be good to go.

In Summary:

When having to do this on a large survey, this might be a bit frustrating going over all of it and looking for the problematic segments.
Therefore, we would recommend scripting your surveys in JavaScript and using our Built-In functions too.
Here is a link to our ‘Built-In Functions Hand Book’, it contains all functions in STG studio:
SurveyToGo – Built-In Functions Hand Book

That’s it!

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.