public function __construct($slider_id) { // build the slider as a normal Enp_quiz_Slider to fill in the slider object parent::__construct($slider_id); // if it's not found, just return false if ($slider_id === false) { return false; } // get the results and add them to the object $this->get_slider_results($slider_id); }
/** * Checks if the response is valid or not * @param $response = submitted response * @return (mixed) 'invalid' if not valid, Enp_quiz_Slider object if valid */ protected function validate_slider_response($response) { // validate that this ID is attached to this question $question = new Enp_quiz_Question($response['question_id']); $slider_id = $question->get_slider(); $slider = new Enp_quiz_Slider($slider_id); // set it up for future use self::$slider = $slider; // see if their response is within the range $slider_response = (double) $response['question_response']; $slider_range_low = (double) $slider->get_slider_range_low(); $slider_range_high = (double) $slider->get_slider_range_high(); if ($slider_range_low <= $slider_response && $slider_response <= $slider_range_high) { // it's valid! $valid = true; } else { $valid = false; } return $valid; }