Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions 07_teststrategie_tester.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#print_r ($responses);
#die;

# $test_strategie = 'radCAT'; // radikaler CAT
$test_strategie = 'radCAT'; // radikaler CAT
$test_strategie = 'classTest'; // klassischer Test
# $test_strategie = 'defCAT'; // Adaptive Test for Deficency
# $test_strategie = 'strenCAT'; // Adaptive Test for Strength
# $test_strategie = 'relScales'; // Adaptive Test for relevant Scales
$test_strategie = 'allScales'; // Adaptive Test for all Scales
# $test_strategie = 'allScales'; // Adaptive Test for all Scales

$pp_start = 0; #0.02;
$pp_start = 0.02;
Expand All @@ -29,10 +29,12 @@
# $se_min = 0.35;
$se_max = 0.5;
# $se_max = 1.5;
$N_total = 35;
$N_total = 250;

$N_total = 60;
$N_total = 250;

$N_max = 10;
$N_min = 3;
$N_min = 5;

if ($test_strategie === 'radCAT') {
$N_max = $N_total;
Expand Down Expand Up @@ -275,19 +277,37 @@
$item_temp = [];
$item_temp = array_filter($item_played, function($v, $k) use ($scale_temp) {return (substr($v['Scale'], 0, strlen($scale_temp)) === $scale_temp); }, ARRAY_FILTER_USE_BOTH);

// Lege auch glweich ein alternatives Modell des Testverlaufes an, indem id letzte Frage "geflippt" beantwortet wurde.
$item_alternate = $item_temp;
$item_alternate[array_key_last($item_alternate)]['k'] = abs( 1 - $item_alternate[array_key_last($item_alternate)]['k']);


$N_calc[$scale_temp] = count($item_temp);
if (($N_calc[$scale_temp] > 0) || ($scale_temp == $scale_root)) {
$pp_prev[$scale_temp] = $pp_calc[$scale_temp];
$pp_calc[$scale_temp] = pp_2pl_est($item_temp, ($pp_calc[$scale_temp] !== FALSE)?($pp_calc[$scale_temp]):($pp_parent), $pp_parent, $se_parent);
$se_calc[$scale_temp] = se_2pl($item_temp, $pp_calc[$scale_temp]);

$frac_temp = array_map(function ($v) { return $v['k']; } , $item_temp);
$frac_sum = array_sum($frac_temp);
$f_calc[$scale_temp] = $frac_sum / $N_calc[$scale_temp];

// Alternative Berechung im Falle, dass pp nur mittels EAP geschätzt werden konnte und 3 oder mehr Fragen auszuwerten sind:
if ((round($f_calc[$scale_temp], 0) == round($f_calc[$scale_temp], 6)) && ($N_calc[$scale_temp] > 2)) {

$pp_alternate = pp_2pl_est($item_alternate, ($pp_calc[$scale_temp] !== FALSE)?($pp_calc[$scale_temp]):($pp_parent), $pp_parent, $se_parent);

// Prüfe nun, welches von beiden Ergebnissen ferner vom pp_parent entfernt (in der selben Richtung!) liegt:
if (($pp_alternate <=> $pp_calc[$scale_temp]) == ($pp_calc[$scale_temp] <=> $pp_parent)) {
$pp_calc[$scale_temp] = $pp_alternate;
}
}

$se_calc[$scale_temp] = se_2pl($item_temp, $pp_calc[$scale_temp]);

$out_step_data_tmp = str_replace("{".$scale_temp."}", '"'.round($pp_calc[$scale_temp], 2)." (SE ".round($se_calc[$scale_temp], 2)." bei ".$N_calc[$scale_temp]." Fragen mit R/W-Rate ".round($f_calc[$scale_temp], 2).")".'"', $out_step_data_tmp);

if (round($f_calc[$scale_temp], 0) != round($f_calc[$scale_temp], 6) ) {
if (round($f_calc[$scale_temp], 0) != round($f_calc[$scale_temp], 6)) {

$pp_parent = $pp_calc[$scale_temp];
$se_parent = $se_calc[$scale_temp];

Expand All @@ -297,9 +317,21 @@
if (substr($scale_id, 0, strlen($scale_temp)) != $scale_temp) {continue;} // Skippe Skalen, die nicht unter $scale_temp liegen
if (substr($scale, 0, strlen($scale_id)) == $scale_id) {continue;} // Skippe Skalen, die innerhalb des Zweiges des aktuellen items liegen - diese werden ohnehin gleich berechnet.
if (round($f_calc[$scale_id], 0) != $f_calc[$scale_id]) {continue;} // Skippe alle untergeordneten Skalen mit echter Berechnung

$item_temp = array_filter($item_played, function($v, $k) { global $scale_id; return (substr($v['Scale'], 0, strlen($scale_id)) == $scale_id); }, ARRAY_FILTER_USE_BOTH);
$pp_calc[$scale_id] = pp_2pl_est($item_temp, $pp_calc[$scale_id], $pp_parent, $se_parent);

// compare to alternate universe
$item_alternate = $item_temp;
$item_alternate[array_key_last($item_alternate)]['k'] = abs( 1 - $item_alternate[array_key_last($item_alternate)]['k']);
$pp_alternate = pp_2pl_est($item_alternate, $pp_calc[$scale_id], $pp_parent, $se_parent);

if (($pp_alternate <=> $pp_calc[$scale_id]) == ($pp_calc[$scale_id] <=> $pp_parent)) {
$pp_calc[$scale_id] = $pp_alternate;
}

$se_calc[$scale_id] = se_2pl($item_temp, $pp_calc[$scale_id]);

# reestimate ($item_temp, $scale_temp, $pp_calc, $se_calc);
$out_step_data_tmp = str_replace("{".$scale_temp."}", '"'.round($pp_calc[$scale_temp], 2)." (SE ".round($se_calc[$scale_temp], 2)." bei ".$N_calc[$scale_temp]." Fragen mit R/W-Rate ".round($f_calc[$scale_temp], 2).")".'"', $out_step_data_tmp);
# echo "Nachberechnen: $scale_id: ".$pp_calc[$scale_id]." bei ".$N_calc[$scale_id]." Fragen mit ".$f_calc[$scale_id]." R/W-Rate<br>\n";
Expand Down
Binary file not shown.
Loading