protected function is_mc_option_response_correct($response) { // see if it's right... $mc = new Enp_quiz_MC_option($response['question_response']); // will return 0 if wrong, 1 if right. We don't care if // it's right or not, just that we KNOW if it's right or not $response_correct = $mc->get_mc_option_correct(); // if somehow this has been called on an invalid item if ($response_correct !== '0' && $response_correct !== '1') { var_dump('invalid response'); } return $response_correct; }
<?php // set-up the mc option $mc_option = new Enp_quiz_MC_option($mc_option_id); ?> <li id="enp-mc-option--<?php echo $mc_option_id; ?> " class="enp-mc-option enp-mc-option--inputs<?php echo (int) $mc_option->get_mc_option_correct() === 1 ? ' enp-mc-option--correct' : ''; ?> "> <label for="enp-mc-option__<?php echo $question_i . '__' . $mc_option_i; ?> " class="enp-screen-reader-text">Multiple Choice Option</label> <input class="enp-mc-option-id" type="hidden" name="enp_question[<?php echo $question_i; ?> ][mc_option][<?php echo $mc_option_i; ?> ][mc_option_id]" value="<?php echo $mc_option_id; ?> " /> <input id="enp-mc-option__<?php echo $question_i . '__' . $mc_option_i; ?> " type="text" class="enp-input enp-mc-option__input" name="enp_question[<?php