Have an idea?

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

Perl script works fine in SSI Web, but in Lighthouse studio it does not

Any idea why following script in screener 1-5 returns "---" as it supposed to be, but in screener 6 I see "brak" - the label dedicated to must have/ unacceptables?
The script works perfectly fine in SSI Web, but in Lighthouse studio it does not.

[%Begin Unverified Perl

if(QUESTIONNAME() eq "PRE01tv")
{
   return "nie";
}
elsif(QUESTIONNAME() eq "tel1_BYO")
{
   return "nie";
}
elsif(QUESTIONNAME() eq "tel1_MustHave1")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_MustHave2")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_MustHave3")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_MustHave4")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_MustHave5")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_MustHave6")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_MustHave7")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_Unacceptable1")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_Unacceptable2")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_Unacceptable3")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_Unacceptable4")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_Unacceptable5")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_Unacceptable6")
{
   return "brak";
}
elsif(QUESTIONNAME() eq "tel1_Unacceptable7")
{
   return "brak";
}
else
{
   return "---";
}

End Unverified%]

Best regards,

Rafał
asked Mar 18 by RafalNeska (450 points)
The script syntax actually looks fine. I just used a cut down version of the script in a simple test and got it working as it should.

I'd ensure the question names are defined exactly as they appear in the Perl Script. Perl is case sensitive remember.

If your question names are defined correctly, then I suspect screeners 1-5 do not match any of the questions in amongst your "if" statements and in screener 6, there is a match?
Hi Paul, thank you for your comment. The question name for 6th screener is: "tel1_Screener6" - I can see no reason, why the perl script returns "brak" which is dedicated only for must-have unacceptables.
I have tested a portion of your script and have it worked nicely at my end (using only a couple of elsif statements).

Are your question names defined exactly the same as they are in your Perl Script? They need to be exactly the same, taking into account case sensitivity.

It puzzles me as the syntax looks fine. I'm not seeing any HTML entity name issues either?

The only issue I can think of is if the question names were not correct?

I'll be interested to see what Sawtooth Software point out?
Thanks again.
The question names are exactly the same as in the script.
It puzzles me too.

1 Answer

0 votes
 
Best answer
I'm sorry you are having difficulty with your script.  Can you please try this alternative script and see if it suits your needs?

<span class="special_text"></span>

<script>
$('.question').each(function(){
    var text;
    if ($(this).is('#PRE01tv_div, .acbc_byo')) {
        text = 'nie';
    }
    else if ($(this).is('.acbc_musthave, .acbc_unacceptable')) {
        text = 'brak';
    }
    else {
        text = '---';
    }
    $(this).find('.special_text').text(text);
});
</script>
answered Mar 18 by Zachary Platinum Sawtooth Software, Inc. (127,275 points)
selected Mar 19 by RafalNeska
Zachary, was there anything obviously incorrect with the Perl script? Regards Paul.
There could be other variables at play, but I have seen the QuestionName function behave unexpectedly when used in an ACBC's list item.  My script just implements the intended behavior without the use of that function.
Thanks for confirming Zachary. Much appreciated buddy.
I just experienced the same problem as Rafal. I think this misbehaviour was introduced with v9.6.1 as with v9.5.3 the QuestionName function works fine (we have used it multiple times in many ACBC studies). Hope this helps to fix the error in future versions of Lighthouse because this use of the QuestionName function is even shown in the system help.
...