Ich möchte in Zusammenarbeit mit einem Panelbetreiber eine Stichprobe mit 3 Quoten Erheben: Alter, Geschlecht und Bundesland. Allerdings lande ich, egal was ich im Test ankreuze immer im redirect. Hier mein PHP-Code:
$quotaAge = [
1 => 66, // 66 persons in age group 2 (18-29 years)
2 => 62, // 62 persons in age group 3 (30-39 years)
3 => 59, // 59 persons in age group 4 (40-49 years)
4 => 78, // 78 persons in age group 4 (50-59 years)
5 => 61, // 61 persons in age group 4 (60-69 years)
6 => 72 // 72 persons in age group 4 (70 years and older)
];
$quotaGender = [
1 => 203, // 203 women (code 1)
2 => 197 // 197 men (code 2)
];
$quotaState = [
1 => 53, // Baden-Württemberg
2 => 63, // Bayern
3 => 18, // Berlin
4 => 12, // Brandenburg
5 => 3, // Bremen
6 => 9, // Hamburg
7 => 30, // Hessen
8 => 8, // Mecklenburg-Vorpommern
9 => 38, // Niedersachsen
10 => 85, // Nordrhein-Westfalen
11 => 20, // Rheinland-Pfalz
12 => 5, // Saarland
13 => 20, // Sachsen
14 => 11, // Sachsen-Anhalt
15 => 14, // Schleswig Holstein
16 => 10 // Thüringen
];
// Gender is read out directly
$gender = value('SD05');
// The age is recoded
$age = value('SD06_01');
if ($age <= 29) {
$ageGroup = 1;
} elseif ($age <= 39) {
$ageGroup = 2;
} elseif ($age <= 49) {
$ageGroup = 3;
} elseif ($age <= 59) {
$ageGroup = 4;
} elseif ($age <= 69) {
$ageGroup = 5;
} else {
$ageGroup = 6;
}
// The state is read out directly
$state = value('SD19');
// Retrieval of the available cases for this characteristic
$casesAge = statistic('count', 'SD50_01', $ageGroup);
$casesGender = statistic('count', 'SD50_02', $gender);
$casesstate = statistic('count', 'SD50_03', $state);
// Screenout
if (!array_key_exists($ageGroup, $quotaAge) || !array_key_exists($gender, $quotaGender) || !array_key_exists($state, $quotastate)) {
redirect('xxx');
}
// Reading the quota for the specified characteristics
$maxPerAge = $quotaAge [$ageGroup];
$maxPerGender = $quotaGender[$gender];
$maxPerstate = $quotastate[$state];
// quota stop
if (($casesAge >= $maxPerAge) || ($casesGender >= $maxPerGender)|| ($casesstate >= $maxPerstate)) {
redirect('xxx');
}
Über eine Hilfe meine Fehler zu finden, freue ich mich.