Hi,
Let's say the first multiple question is Q1 with subquestion codes 1, 2, 3, ...
To do this I prefer to create a "container" to store interim results
1. Create a question of type "multiple short text" (I called it "RC" like "Result Container") with subquestions
RC_11
RC_12
RC_13
RC_21
RC_22
RC_23
RC_31
RC_32
RC_33
RC_99 (for the final result)
Three subquestions are needed for each element
2. Create a question of type "equation" and enter (only) the equations
First create the base:
{RC_11=join(if(Q1_1=="Y","A",""),if(Q1_2=="Y","B",""),if(Q1_3=="Y","C",""),if(Q1_4=="Y","D",""),if(Q1_5=="Y","E",""),if(Q1_6=="Y","F",""),if(Q1_7=="Y","G",""),if(Q1_8=="Y","H",""),if(Q1_9=="Y","I",""),if(Q1_10=="Y","J",""))}
We get something like "ADEGIJ"
Now the procedure I explained before
Random number from 1 to the length of this string
{RC_12=if(is_empty(RC_12),rand(1,strlen(RC_11)),RC_12)}
Capture the letter at this position
{RC_13=substr(RC_11,RC_12-1,1)}
Remove the letter at this position; this is the base for the next round
{RC_21=str_replace(RC_13,'',RC_11)}
{RC_22=if(is_empty(RC_22),rand(1,strlen(RC_21)),RC_22)}
{RC_23=substr(RC_21,RC_22-1,1)}
{RC_31=str_replace(RC_23,'',RC_21)}
{RC_32=if(is_empty(RC_32),rand(1,strlen(RC_31)),RC_32)}
{RC_33=substr(RC_31,RC_32-1,1)}
Now there are three letters (in RC_13, RC_23 and RC_33)
Joined with a '#' (important for the function "strpos(x,y)")
{RC_99=join('#',RC_13,RC_23,RC_33)}
Now the conditions of the subquestions in Q2 are (just ask: Does the final strinf contain the letter)
strpos(RC_99,"A")>0
strpos(RC_99,"B")>0
strpos(RC_99,"C")>0
...
And there is this javascript solution.
Create a question of type "short text"
in the default answer enter
{list(if(Q1_1=="Y","A",""),if(Q1_2=="Y","B",""),if(Q1_3=="Y","C",""),if(Q1_4=="Y","D",""),if(Q1_5=="Y","E",""),if(Q1_6=="Y","F",""),if(Q1_7=="Y","G",""),if(Q1_8=="Y","H",""),if(Q1_9=="Y","I",""),if(Q1_10=="Y","J",""))}
and this script
Code:
<script type="text/javascript" charset="utf-8">
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
$(document).on('ready pjax:scriptcomplete',function(){
// Fill the array
var str = $('#question{QID} input[type="text"]').val();
var arr=str.split(", ");
arr = shuffle(arr).slice(0,3).join('');
$('#question{QID} input[type="text"]').val('#' + arr);
});
</script>
Hide the question with css class "d-none"
and use the same subquestion conditions.
Joffm