40 categories
You should make sure to have at least a dozen respondents per group before such a complex design makes sense. You may even result in experimetnal groups of very different size, if there are too few respondents per-group. So, if you have less than 480 respondents, please reconsider your plan.
For the actual code implementation I would need an urn (and internal variable) for all 40 categories - I think)
That is correct. You may, however, consider using random generators instead of the (older) groups. If you stay with the urns, use the same internal variable in each case:
if ((value('SD01') == 1) && (value('SD03') == 1) && (value('SD10') == 1)) {
urnDraw('testurn', 'IV01', 'end');
} else {
urnDraw('testurn2', 'IV01', 'end');
}
only a red error message
It is super-helpful to read and post the exact wording of the messages.
However, in you case I'm quite sure it tells that there is no IV01, because the variable name is IV01_01. Also do not use the switch, please. Try this:
if (value('IV01_01') == 1) {
html('<img src="pro://6.jpg" alt="Stimulus 1">');
} else {
html('<img src="pro://9.jpg" alt="Stimulus 2">');
}
General note on the use of AI tools: Your question indicates that you may have asked ChatGPT or another tool for a solution instead of reading the instructions. Know, that ChatGPT has not read the SoSci Survey manual, either. Therefore, ChatGPT is essentially just giving you hallucinations on how to use SoSci Survey. If you want to work with generative AI: Gemini at least knows the instructions for SoSci Survey. Please note, however, that even then the answers from generative AI are only correct with a chance of approx. 65%.