Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Is there any code to write down, which version of the Questionnaire survey the respondents are filling out ?

Hi there,

I have 2 versions for the survey. I would like to do the following things:

I would like to know the code, to write down which version of the survey I am testing in the survey file itself (not in the .csv file version).

Is it possible to export both survey versions pdf format (not just the .csv file that shows the levels and attributes)?
asked Jan 12 by Ali
To clarify, are you referring to two versions of a CBC or other exercise type?  You want to get the current respondent's version within the survey?
Yes ... 2 versions of a CBC study.
Yes I need them within the survey.
There's a Sawtooth Script function "CBCVersion" that displays some data including the version number.  You could try that and see if it's useful for you.  If you need to trim the response of that function to just the version number itself, then we could do that with some custom code.
Yes, I need that custom code to appear in my survey!

Suggestions are highly appreciated.
Try just putting "[% CBCVersion() %]" in your CBC's footer and let's see where that gets us.  Is that good enough for your needs?
This gives : "D - 1, T - Scenario_Random1".

Is it possible to make it shorter by just saying: V-1, T-1?

1 Answer

0 votes
Best answer
Sure.  The CBCVersion function is a little bit weirder than other functions, but we can use JavaScript to format the data however we need it.  Try adding this to your CBC where you want "V-1, T-1" displayed:

<span class="cbcVersionAndTask"></span>

    var match = '[% CbcVersion() %]'.match(/^D - (\d+), T - .*_Random(\d+)$/);
    if (match) {
        var version = match[1];
        var task = match[2];
        var formatted = 'V-' + version + ', T-' + task;
answered Jan 12 by Zachary Platinum Sawtooth Software, Inc. (192,600 points)
Thanks, it worked!