protected function reset_all_quiz_questions_data($question_ids)
 {
     if (!empty($question_ids)) {
         foreach ($question_ids as $question_id) {
             // soft delete responses
             $this->delete_question_responses($question_id);
             // reset stats
             $this->reset_question_data($question_id);
             // create the question object
             $question = new Enp_quiz_Question($question_id);
             // get the question type
             $question_type = $question->get_question_type();
             if ($question_type === 'mc') {
                 $mc_option_ids = $question->get_mc_options();
                 foreach ($mc_option_ids as $mc_option_id) {
                     // reset compiled mc option data
                     $this->reset_mc_option_data($mc_option_id);
                     // soft delete mc option response
                     $this->delete_mc_option_responses($mc_option_id);
                 }
             } elseif ($question_type === 'slider') {
                 // get the slider id
                 $slider_id = $question->get_slider();
                 // soft delete the responses
                 $this->delete_slider_responses($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;
 }
 public function quiz_object_to_array($quiz_obj)
 {
     $quiz_array = (array) $quiz_obj;
     $new_questions_array = array();
     if (!empty($quiz_array)) {
         $question_ids = $quiz_obj->get_questions();
         if (!empty($question_ids)) {
             foreach ($question_ids as $question_id) {
                 // generate the object
                 $question_obj = new Enp_quiz_Question($question_id);
                 // arrayify the question
                 $question_array = (array) $question_obj;
                 // check if mc or slider and add that object as an array
                 if ($question_obj->get_question_type() === 'mc') {
                     $mc_option_ids = $question_obj->get_mc_options();
                     if (!empty($mc_option_ids)) {
                         foreach ($question_obj->get_mc_options() as $mc_option_id) {
                             $mc_option_object = new Enp_quiz_MC_option($mc_option_id);
                             $mc_option_array = (array) $mc_option_object;
                             $question_array['mc_option'][] = $mc_option_array;
                         }
                     }
                 } elseif ($question_obj->get_question_type() === 'slider') {
                     // get the slider ID
                     $slider_id = $question_obj->get_slider();
                     // get the slider object
                     $slider_object = new Enp_quiz_Slider($slider_id);
                     // cast it to an array
                     $slider_array = (array) $slider_object;
                     // add it to the question
                     $question_array['slider'] = $slider_array;
                 }
                 // add it to our questions array
                 $quiz_array['question'][] = $question_array;
             }
         }
     }
     return $quiz_array;
 }