Have an idea?

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

Customized CBC Questions Using "Free Format"

Hello:

I created a customized CBC questions using free format.

I am attempting to use this code


[%CBCVERSION ()%] 
[%CBCCURRENTTASK()%]


to show the version and CBC task for the client but the version and task is not appearing in the free format question.

Please help.

Thank you in advance
asked Feb 20 by Sandy
Those functions can only be used in CBC tasks, but we can probably write some code that will achieve the same behavior in your free format tasks.  Fixed tasks will make things a bit trickier, if they exist - do you have fixed tasks in your exercise?
Hi Zach,

No fixed tasks

1 Answer

0 votes
You can use this script in place of calling CbcCurrentTask:

[% Begin Unverified Perl
my $qname = QUESTIONNAME();
$qname =~ /Random([0-9]+)$/;
return $1;
End Unverified %]


If your free format question is placed after the associated CBC task, you can use this script in place of calling CbcVersion:

[% Begin Unverified Perl
# Parameters
my $exercise = 'cbc';

# Run
my $qname = QUESTIONNAME();
$qname =~ /Random([0-9]+)$/;
return 'D - ' . GETVALUE('sys_CBCVersion_' . $exercise) . ', T - ' . $exercise . '_Random' . $1;
End Unverified %]


Line 3 will have to be updated with the name of your exercise.
answered Feb 21 by Zachary Platinum Sawtooth Software, Inc. (138,350 points)
Zach,

My ff question is placed after the associated CBC task, and I have added the syntax for calling the CbcVersion but the version is null.  I get  1 D -, T- cbc_Random1.  I checked the data and the version is being written out
Is the name of your exercise "cbc"?
Yes, but cbc is all in caps.  When I changed cbc to all in caps, it worked.  Thank you so much!
...