Q2 can be of numeric type. In any way I managed to build a constraint as follows:
selected(${q1}, ‘1’) and (${q2} >= 1 and ${q2} <= 27) or selected(${q1}, ‘2’) and (${q2} >= 28 and ${q2} <= 65) or selected(${q1}, ‘3’) and (${q2} >= 135 and ${q2} <= 166)
Fine.
But you always need brackets to separate and from or constructs.
And it might be done a bit shorter
(${q1} = ‘1’ and . >= 1 and .< 27) or (… ). or (…)
You only need selected(…) for select_multiple. The current question/variable value can be referenced with . (i.e. dot).
Hint: Use the online validator to check your form during development and before deploymrent.