Thanks for sharing the result. Just relying on the question numbers (01 to 07 + group offset) is a nice simplification here. However, if you want a quick feedback regarding the code: Please note that the question order will change, if you have any question that requires being answered, and respondents do not answer the question. The page will then reload and reshuffle. If you wanted avoid this, change
$QuestionID = [1,2,3,4,5,6,7]; //variable with levels 1 to 7
shuffle($QuestionID); //shuffeling of the order of the questions
putList('IV01', $QuestionID);
to
if (!isset($QuestionID)) {
$QuestionID = [1,2,3,4,5,6,7]; //variable with levels 1 to 7
shuffle($QuestionID); //shuffeling of the order of the questions
putList('IV01', $QuestionID);
registerVariable($QuestionID);
}