Survey Solutions

Support portal and knowledge base

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Randomization and translation using macros?

David Plotner Oct 04, 2017 01:51PM EDT

If we want to randomize a block of questions, we were going to use a macro to randomly shuffle the text in an array. This works fine for one language:

-------------------
var r = Math.Log(1 + Math.Floor(Quest.IRnd()*1000000)/1000000);
var s = r.ToString("0.0000000000").Substring(2);
var items = new[]{
"Sample text 1",
"Sample text 2",
"Sample text 3",
"Sample text 4"};

for (var i = 0; i < items.Length; i++)
{
var n = Convert.ToInt32(s.Substring(i,1));
if (n >= items.Length) n = 0;
var t = items[i];
items[i] = items[n];
items[n] = t;
}

return items
-----------------------

What is the best way to apply this to multiple languages, so that the referenced text is language specific?

Thanks for any guidance on this one.

1 Community Answers

Best Answer
Sergiy Radyakin Oct 04, 2017 03:58PM EDT

David,

normally text substitutions should be kept invariant between translations, but in your case it is justifiable to also change the variable used for the substitution. So that you have two (three, more) variables, each evaluating content in the proper language e.g. monthNameEng, monthNameGrk, monthNameFre. And you refer to the proper one in the translated question text.

Best, Sergiy


This question has received the maximum number of answers.

support@mysurvey.solutions
http://assets1.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete