Have an idea?

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

Ranking Question and Auto code

Dear All,

From Q1 to Q11 are Select questions with 4 scores.

The condition for the next question as below:

=> Q12 (Ranking question). Include only rate Score 1 from Q1 to Q11. If Only ONE question rated score 1 from Q1 to Q11, auto record '1' and move to next question. If No question rated score 1 from Q1 to Q11, skip to next question.

=> Q13 (Ranking question). Include only rate Score 2 from Q1 to Q11. If Only ONE question rated score 2 from Q1 to Q11, auto record '2' and move to next question. If No question rated score 2 from Q1 to Q11, skip to next question.

=> Q14 (Ranking question). Include only rate Score 3 from Q1 to Q11. If Only ONE question rated score 3 from Q1 to Q11, auto record '3' and move to next question. If No question rated score 3 from Q1 to Q11, skip to next question.

=> Q15 (Ranking question). Include only rate Score 4 from Q1 to Q11. If Only ONE question rated score 4 from Q1 to Q11, auto record '4' and move to next question. If No question rated score 4 from Q1 to Q11, skip to next question.

=> Q16 (Ranking question). AUTO RANK ALL 11 questions COMBINING THE SCORE FROM Q12 to Q15. I mean that Include the Rank which have been already ranked in Q12 next to each other. And then Include the Rank which have already been ranked in Q13 next to each other. And then Include the Rank which have already been ranked in Q14 next to each other. And then Include the Rank which have already ranked in Q15 next to each other.

Is this possible?
asked Jan 25 by Saroeun Bronze (1,630 points)

1 Answer

0 votes
Interesting problem, but I think I've got it.  My solution involves creating six lists and uses the assumption that the select questions and ranking questions are named with a simple base name with an incrementer (e.g., "SelectQ1," "SelectQ2," and "RankingQ1," "RankingQ2).

The first list should be a predefined list with one item for each select question.

Then create four constructed lists.  Each should use that predefined list for its parent and should have this code:

Begin Unverified Perl
# Parameters
my $parentList = 'list1';
my $selectQBaseName = 'SelectQ';

my $thisListRanking = 1;

# Run
my $items = LISTLENGTH($parentList);
for (my $i = 1; $i <= $items; $i++) {
    if (GETVALUE($selectQBaseName . $i) == $thisListRanking) {
        ADD($parentList, $i);
    }
}
End Unverified


Line 3 must be updated with the name of the predefined list, and line 4 must be updated with the base name of the select questions.  Line 6 should be updated with a different value for each of the four lists: 1, 2, 3, 4.  These lists can be used in your ranking questions.

Finally, one last constructed list to bring it all together.  Same parent list as the others, but now with this script:

Begin Unverified Perl
# Parameters
my $parentList = 'list1';
my $rankingQBaseName = 'RankingQ';
my $numberOfRankingQuestions = 4;

# Run
my $numberOfItems = LISTLENGTH($parentList);
for (my $r = 1; $r <= $numberOfRankingQuestions; $r++) {
    my %hash = ();
    for (my $i = 1; $i <= $numberOfItems; $i++) {
        my $val = GETVALUE($rankingQBaseName . $r . '_' . $i);
        if ($val) {
            $hash{$i} = $val;
        }
    }
    foreach my $item (sort { $hash{$a} <=> $hash{$b} } keys(%hash)) {
        ADD($parentList, $item);
    }
}
End Unverified


Line 3 and 4 must be updated.
answered Jan 25 by Zachary Platinum Sawtooth Software, Inc. (120,175 points)
Thanks Zachary, but these script not my queries.
Here what I done.

Select Question Q1 to Q11 use the same list. It's name "List1":
=> Predefine list (List1): |1|2|3|4|

Ranking Question Q12, I have created a new Predefine list name "List2":
=> Predefine list (List2): |Q1|Q2|Q3|Q4|Q5|Q6|Q7|Q8|Q9|Q10|Q11|
=> Constrution List of Q12 name "Q12ConList" and Parent list is "List2" with script below:
Begin Unverified Perl
if(VALUE("Q1")==1)
{
    ADD("List2",1);
}
if(VALUE("Q2")==1)
{
    ADD("List2",2);
}
......
......
if(VALUE("Q11")==1)
{
    ADD("List2",11);
}
End Unverified

Ranking Question Q13, use the same Parent List (List2)
=> Constrution List of Q13 name "Q13ConList" with script below:
Begin Unverified Perl
if(VALUE("Q1")==2)
{
    ADD("List2",1);
}
if(VALUE("Q2")==2)
{
    ADD("List2",2);
}
......
......
if(VALUE("Q11")==2)
{
    ADD("List2",11);
}
End Unverified

Ranking Question Q14, use the same Parent List (List2)
=> Constrution List of Q14 name "Q14ConList" with script below:
Begin Unverified Perl
if(VALUE("Q1")==3)
{
    ADD("List2",1);
}
if(VALUE("Q2")==3)
{
    ADD("List2",2);
}
......
......
if(VALUE("Q11")==3)
{
    ADD("List2",11);
}
End Unverified

Ranking Question Q15, use the same Parent List (List2)
=> Constrution List of Q15 name "Q15ConList" with script below:
Begin Unverified Perl
if(VALUE("Q1")==4)
{
    ADD("List2",1);
}
if(VALUE("Q2")==4)
{
    ADD("List2",2);
}
......
......
if(VALUE("Q11")==4)
{
    ADD("List2",11);
}
End Unverified


Ranking Question Q16, use the same Parent List (List2)
=> Constrution List of Q16 name "Q16ConList" and Parent list is "List2" with script below:
AIE(Q12,1)
AIE(Q12,2)
AIE(Q12,3)
AIE(Q12,4)
AIE(Q12,5)
AIE(Q12,6)
AIE(Q12,7)
AIE(Q12,8)
AIE(Q12,9)
AIE(Q12,10)
AIE(Q12,11)
AIE(Q13,1)
AIE(Q13,2)
AIE(Q13,3)
AIE(Q13,4)
AIE(Q13,5)
AIE(Q13,6)
AIE(Q13,7)
AIE(Q13,8)
AIE(Q13,9)
AIE(Q13,10)
AIE(Q13,11)
AIE(Q14,1)
AIE(Q14,2)
AIE(Q14,3)
AIE(Q14,4)
AIE(Q14,5)
AIE(Q14,6)
AIE(Q14,7)
AIE(Q14,8)
AIE(Q14,9)
AIE(Q14,10)
AIE(Q14,11)
AIE(Q15,1)
AIE(Q15,2)
AIE(Q15,3)
AIE(Q15,4)
AIE(Q15,5)
AIE(Q15,6)
AIE(Q15,7)
AIE(Q15,8)
AIE(Q15,9)
AIE(Q15,10)
AIE(Q15,11)

***** For Q16 I want to Auto Rank follow above script.

Is it possible? Hope you understand and help to fix.
Why do you actually need a ranking question if it's going to auto-fill and auto-submit?  My constructed list should have the information you want from the final ranking question without actually making the question.
Related to your script will work if we use the same list "list1" for SelectQ and RankingQ. But my queries use different list of SelectQ and RankingQ.

=> SelectQ use with "list1" have rate score 1,2,3,4.
=> RankingQ use with "list2" have 11 rows (code1=Q1, code2=Q2, code3=Q3,.....,code11=Q11).

Hope you understand.
My code does not require that the select questions and ranking questions use the same list.  The parent list of my constructed lists above should be the list of items to rank, namely "list2" per your comment.
...