/** * Get an instance of this class. * * @return GFSurvey */ public static function get_instance() { if (self::$_instance == null) { self::$_instance = new GFSurvey(); } return self::$_instance; }
public function get_likert_score($field, $entry) { return is_callable(array('GFSurvey', 'get_field_score')) ? GFSurvey::get_field_score($field, $entry) : 0; }
public function results_data_add_labels($form, $fields) { // replace the values/ids with text labels foreach ($fields as $field_id => $choice_counts) { $field = GFFormsModel::get_field($form, $field_id); $type = GFFormsModel::get_input_type($field); if (is_array($choice_counts)) { $i = 0; foreach ($choice_counts as $choice_value => $choice_count) { if (class_exists("GFSurvey") && "likert" == $type && rgar($field, "gsurveyLikertEnableMultipleRows")) { $row_text = GFSurvey::get_likert_row_text($field, $i++); $counts_for_row = array(); foreach ($choice_count as $col_val => $col_count) { $text = GFSurvey::get_likert_column_text($field, $choice_value . ":" . $col_val); $counts_for_row[$col_val] = array("text" => $text, "data" => $col_count); } $counts_for_row[$choice_value]["data"] = $counts_for_row; $fields[$field_id][$choice_value] = array("text" => $row_text, "value" => "{$choice_value}", "count" => $counts_for_row); } else { $text = GFFormsModel::get_choice_text($field, $choice_value); $fields[$field_id][$choice_value] = array("text" => $text, "value" => "{$choice_value}", "count" => $choice_count); } } } } return $fields; }
public function results_data_add_labels($form, $fields) { // replace the values/ids with text labels foreach ($fields as $field_id => $choice_counts) { $field = GFFormsModel::get_field($form, $field_id); $type = $field->get_input_type(); if (is_array($choice_counts)) { $i = 0; foreach ($choice_counts as $choice_value => $choice_count) { if (class_exists('GFSurvey') && 'likert' == $type && rgar($field, 'gsurveyLikertEnableMultipleRows')) { $row_text = GFSurvey::get_likert_row_text($field, $i++); $counts_for_row = array(); foreach ($choice_count as $col_val => $col_count) { $text = GFSurvey::get_likert_column_text($field, $choice_value . ':' . $col_val); $counts_for_row[$col_val] = array('text' => $text, 'data' => $col_count); } $counts_for_row[$choice_value]['data'] = $counts_for_row; $fields[$field_id][$choice_value] = array('text' => $row_text, 'value' => "{$choice_value}", 'count' => $counts_for_row); } else { $text = GFFormsModel::get_choice_text($field, $choice_value); $fields[$field_id][$choice_value] = array('text' => $text, 'value' => "{$choice_value}", 'count' => $choice_count); } } } } return $fields; }
private static function get_the_likert($form, $lead, $field, $form_array) { $id = $field['id']; $multiple_rows = rgar($field, "gsurveyLikertEnableMultipleRows"); if (!$multiple_rows) { $results = $lead[$id]; } $likert = array(); /* store the column names */ foreach ($field['choices'] as $col) { $likert['col'][$col['value']] = $col['text']; } if (is_array($field['inputs']) && sizeof($field['inputs']) > 0) { /* do our multi-row likert */ foreach ($field['inputs'] as $row) { /* pad the array with the number of columns */ foreach ($likert['col'] as $col_id => $text) { /* * Results for multi row is stored with ID.ROW# (eg $lead['1.2']) * The number is stored in $row['id'] */ $results = $lead[$row['id']]; /* user data in the $lead comes in as ROW ID:COL ID */ $comparison = $row['name'] . ':' . $col_id; /* do our comparison and update the output */ $output = $comparison == $results ? 'selected' : ''; /* assign our results to the array */ $likert['rows'][$row['label']][$text] = $output; } } } else { /* do our single row likert */ foreach ($likert['col'] as $col_id => $text) { /* single row data comes in with col value */ /* do our comparison and update the output */ $output = $col_id == $results ? 'selected' : ''; $likert['row'][$text] = $output; } } /* * Check if scoring is enabled and calculate */ if ($field['gsurveyLikertEnableScoring'] && class_exists('GFSurvey')) { $survey = GFSurvey::get_instance(); $likert['score'] = $survey->get_field_score($field, $lead); } return $likert; }
function gf_survey() { return GFSurvey::get_instance(); }
public static function display_export_field_value($value, $form_id, $field_id, $lead) { $survey = GFSurvey::get_instance(); return $survey->display_entries_field_value($value, $form_id, $field_id, $lead); }
<?php /** * Display the Quiz field type * * @package GravityView * @subpackage GravityView/templates/fields */ // Make sure the CSS file is enqueued if (class_exists('GFSurvey') && is_callable(array('GFSurvey', 'get_instance'))) { wp_register_style('gsurvey_css', GFSurvey::get_instance()->get_base_url() . '/css/gsurvey.css'); wp_print_styles('gsurvey_css'); } echo GravityView_View::getInstance()->getCurrentField('display_value');