getCorrectData()); foreach ( $opts as $opt => $val ) { $right = $val[1]; $choices = $val[0]; if ( isset($_POST[$opt]) && isset($_POST[$opt.'_input']) ) { return json_encode(array()); } if ( isset($_POST[$opt]) || isset($_POST[$opt.'_input']) ) { if ( isset($_POST[$opt]) ) { if ($right == $_POST[$opt] ) { $res[$opt] = 1; } else { $res[$opt] = 0; } } else if ( isset($_POST[$opt.'_input']) ) { if ( !strcmp($choices[$right], $_POST[$opt.'_input']) ) { $res[$opt] = 1; } else { $res[$opt] = 0; } } } else { $res[$opt] = 0; } } if ( $asVar ) { return $res; } else { return json_encode($res); } } function collectInput($obj) { $res = array(); $opts = unserialize($obj->getCorrectData()); foreach ( $opts as $opt => $val ) { $right = $val[1]; $choices = $val[0]; if ( isset($_POST[$opt]) || isset($_POST[$opt.'_input']) ) { if ( isset($_POST[$opt]) ) { if ( $_POST[$opt] == -1 ) { $res[$opt] = "-1"; } else { $res[$opt] = $choices[$_POST[$opt]]; } } else if ( isset($_POST[$opt.'_input']) ) { $res[$opt] = $_POST[$opt.'_input']; } } else { $res[$opt] = ""; } } return $res; } ?>