示例#1
0
         $quiz->_updateExtraOption($key, $value);
     }
 }
 // end of tab=CONFIGURATION
 /**
  * ================================================
  * 		    QUESTIONS / ANSWERS PROCESS
  * ================================================
  */
 if ($activeTab == 'questions') {
     /**
      * Delete stuff for update
      */
     $deleteAnswers = array_filter(explode(',', $_POST['deleteAnswers']));
     foreach ($deleteAnswers as $answerId) {
         $answer = new WPVQAnswer();
         try {
             $answer->load(intval($answerId))->delete();
         } catch (Exception $e) {
         }
     }
     $deleteQuestions = array_filter(explode(',', $_POST['deleteQuestions']));
     foreach ($deleteQuestions as $questionId) {
         $question = new WPVQQuestion();
         try {
             $question->load(intval($questionId))->delete();
         } catch (Exception $e) {
         }
     }
     /**
      * Add question and answers
示例#2
0
 /**
  * Returns array of answers for this game
  * @return array of ::Answer
  */
 private function fetchAnswers($gameplayContext = false)
 {
     global $wpdb;
     // Fetch from DB
     $row = $wpdb->get_results($wpdb->prepare('SELECT ID FROM ' . WPViralQuiz::getTableName('answers') . ' WHERE questionId = %d', $this->id));
     // No answer
     if (empty($row)) {
         return array();
     }
     $answers = array();
     foreach ($row as $answer) {
         $ans = new WPVQAnswer();
         $ans->load($answer->ID);
         $answers[] = $ans;
     }
     // Shuffle answers
     if ($this->isRandomAnswers && $gameplayContext) {
         shuffle($answers);
     }
     return $answers;
 }