Reputation: 57
I'm using the Personality Quiz add-on for Gravity Forms and would like to extend it's functionality. Currently it determines the "winner" of a multiple-choice quiz like this:
$scores = array_count_values( $quiz_questions );
$winners = array_keys( $scores, max( $scores ), true );
return $winners[0];
Rather than simply returning which option (A, B, or C) received the most clicks I'd like to use ranges of scores so that if "A" > 30 than $winners would be "Type 1", if "A">20 and "B">20 $winners would be "Type 2", if "B">20 and "C">20 $winners would be "Type 3", etc. I've been trying variations of this but not finding the error.
$scores = array_count_values( $quiz_questions );
$k_count_total = count($scores($quiz_questions, "Kilo"));
$v_count_total = count($scores($quiz_questions, "Victor"));
$p_count_total = count($scores($quiz_questions, "Papa"));
if ($v_count_total > 33) { $winners = "Victor"; }
elseif ($v_count_total > 17 && $p_count_total > 17) {$winners = "Victor-Papa";}
elseif ($v_count_total > 17 && $k_count_total > 17) {$winners = "Victor-Kilo";}
elseif ($p_count_total > 33) {$winners = "Papa";}
elseif ($p_count_total > 17 && $k_count_total > 17) {$winners = "Papa-Kilo";}
elseif ($k_count_total > 33) {$winners = "Kilo";}
elseif ($k_count_total > 15 && $v_count_total > 15 && $p_count_total > 15) {$winners = "VPK";}
return $winners[0];
Upvotes: 0
Views: 198
Reputation: 633
You may have figured this out already but on quick glance it looks like you have some syntax errors.
for example: $scoress($$quiz_questions, "Kilo") should be $scores($quiz_questions, "Kilo")
Upvotes: 1