コード例 #1
0
ファイル: shortcodes.php プロジェクト: arkonisus/Questions
 /**
  * Showing results of a question
  * @param array $atts Arguments which can be added to the shortcode
  * @return string $html HTML of results
  */
 public static function question_results($atts)
 {
     global $wpdb, $questions_global;
     $atts = shortcode_atts(array('id' => ''), $atts);
     if ('' == $atts['id']) {
         _e('Please enter a question id in the survey shortcode!', 'questions-locale');
         return;
     }
     $sql = $wpdb->prepare("SELECT questions_id FROM {$questions_global->tables->questions} WHERE id = %d", $atts['id']);
     $survey_id = $wpdb->get_var($sql);
     $survey = new Questions_Form($survey_id);
     $ordered_data = Questions_AbstractData::order_for_charting($survey->get_responses($atts['id'], FALSE));
     $html = '';
     foreach ($ordered_data['questions'] as $question_id => $question) {
         $html .= Questions_ChartCreator_Dimple::show_bars($question, $ordered_data['data'][$question_id]);
     }
     return $html;
 }