protected function validate_mc_option_response($response)
 {
     $valid = false;
     // validate that this ID is attached to this question
     $question = new Enp_quiz_Question($response['question_id']);
     $question_mc_options = $question->get_mc_options();
     // see if the id of the mc option they submitted is actually IN that question's mc option ids
     if (in_array($response['question_response'], $question_mc_options)) {
         $valid = true;
     } else {
         // TODO Handle errors?
         // not a legit mc option response
         $valid = false;
     }
     return $valid;
 }
 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);
             }
         }
     }
 }
 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;
 }