I would recommend a "random generator" for drawing the number. It's advantage is that you have the result automatically stored in the dataset.
Let's say your slider item (differentiation 1 to 7) hat the ID SL01_01 and the random generator (with 7 codes from 1 to 7) has the ID RG01. Here's the code to inform the respondents:
$num = value('RG01') - 4;
// Need a plus or minus
$numS = return sprintf("%+d",$num);
replace('%yourNumber%', $numS);
Of course, you have to use the placeholder in your text that is displayed to the respondent.
And here's the code to compare the numbers:
if (value('RG01') <= value('SL01_01')) {
setPageOrder('pageB', 'pageD');
} else {
setPageOrder('pageC', 'pageD');
}
Of course, it's probably better to display different contents on one combined page BC instead of using setPageOrder()
. Yet, both will work.