Have an idea?

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

Pipe Maxdiff exercise question into Freeformat

I see the MaxdiffVersion function and it looks useful for determining the current exercise.   I am aiming at being lazy and not having to specify the question name every time like MXDF_1 in the below.  Instead I would return it.  That way when I copy it as many times as I need to I am done instead of having to change it every time.

[%RadioSelect(FFMXDF1_b, MaxDiffDesignValue(MXDF_1, 1))%]

MaxdiffVersion  seems to only work on the actual Maxdiff question.  It would seem the only possible way to get the data to the Freeformat would be with a "pass-in" variable.  I have not tried it and even if it works it feels overly cumbersome and that is before parsing the question out of the MaxdiffVersion return.
asked Jun 22, 2016 by JasonC (255 points)

1 Answer

+2 votes
You can accomplish this with unverified Perl.  Here's how I created the first "best" radio button in my free format:

[% Begin Unverified Perl
my $exerName = 'MXDF';
my $ffBaseName = 'FFMXDF';

my $qnum = QUESTIONNAME();
$qnum =~ s/$ffBaseName//;
my $thisBestWorst = $ffBaseName.$qnum.'_b';
my $thisMxdSet = $exerName.'_'.$qnum;

RADIOSELECT($thisBestWorst, MAXDIFFDESIGNVALUE($thisMxdSet, 1));
End Unverified %]


To create the second, third, fourth, and so on "best" radio buttons, simply replace the '1' in line 10 with '2', '3', '4', ...

To create the "worst" radio buttons, replace the '_b' with '_w' in line 7.

Once you've got the first free format question set up using this unverified Perl, I believe all copy-and-pasted free formats should have working radio buttons.
answered Jun 22, 2016 by Zachary Platinum Sawtooth Software, Inc. (90,900 points)
QUESTIONNAME - now I feel foolish for overlooking it... Many thanks.  It also looks like I need to get around to  reading up on perl regex.
...