Plugin Directory

Changeset 1131329


Ignore:
Timestamp:
04/09/2015 04:35:42 PM (11 years ago)
Author:
awesome-ug
Message:

Fixed problems with charts

Location:
questions
Files:
79 added
5 edited

Legend:

Unmodified
Added
Removed
  • questions/trunk/README.txt

    r1131247 r1131329  
    6666== Changelog ==
    6767
     68= 1.0.0 beta 6 =
     69* Fixed result charts bug
     70* Fixed some translation fails
     71
    6872= 1.0.0 beta 5 =
    6973* Added Questions Shortcode for embedding surveys
  • questions/trunk/components/admin/admin.php

    r1131247 r1131329  
    453453           
    454454            $question_id = $survey_question['id'];
    455             $question = $survey_question['question'];
     455            $question = '';
    456456            $sort = $survey_question['sort'];
    457457            $type = $survey_question['type'];
     458           
     459            if( array_key_exists( 'question', $survey_question ) )
     460                $question = $survey_question['question'];
    458461           
    459462            $answers = array();
  • questions/trunk/components/charts/data-abstraction.php

    r1128186 r1131329  
    4747        global $wpdb, $questions_global;
    4848       
    49         $lines = self::lines( $response_array );
    50        
    5149        $ordered_data = array();
    5250       
    53         // Getting Labels
    54         foreach( $lines[ 0 ] AS $key => $line ):
    55             if( $key != '_user_id' ):
    56                 $ordered_data[ 'questions' ][ $key ] = $line;
    57             endif;
    58         endforeach;
    59        
    60         unset ( $lines[0] ); // Throw away headlines
    61        
     51        $ordered_data[ 'questions' ] = array();
    6252        $ordered_data[ 'data' ] = array();
    6353       
    6454        // Getting every entery of one
    65         foreach( $ordered_data[ 'questions' ] AS $key => $line ):
     55        foreach( $response_array AS $key => $line ):
    6656            $merged_data = array();
    6757           
    68             foreach( $lines AS $response_id => $line ):
    69                 if( !isset( $merged_data[ $line[ $key ] ] ) ) $merged_data[ $line[ $key ] ] = 0;
    70                 $merged_data[ $line[ $key ] ]++;               
    71             endforeach;
     58            $sql = $wpdb->prepare( "SELECT type FROM {$questions_global->tables->questions} WHERE id = %s", $key );
     59            $result = $wpdb->get_row( $sql );
     60           
     61            $element_class = 'Questions_SurveyElement_' . $result->type;
     62           
     63            if( !class_exists( $element_class ) )
     64                continue;
     65           
     66            $element = new $element_class( $key );
     67           
     68            if( !$element->is_displayable )
     69                continue;
     70           
     71            $ordered_data[ 'questions' ][ $key ] = $line[ 'question' ];
    7272           
    7373            // Fill up missed answers with 0
     
    7777            $voted_answers = array_keys( $merged_data );
    7878            foreach( $results AS $result ):
    79                 if( !in_array( $result->answer, $voted_answers ) )
    80                     $merged_data[ $result->answer ] = 0;
     79                $merged_data[ $result->answer ] = 0;
     80            endforeach;
     81           
     82            // Adding voted data
     83            $responses = $response_array[ $key ][ 'responses' ];
     84           
     85            foreach( $responses AS $response ):
     86                if( !$element->answer_is_multiple ):
     87                    $merged_data[ $response ] += 1;
     88                else:
     89                    foreach( $response AS $answer_option => $answer ):
     90                        if( $answer == __( 'Yes', 'questions-locale' ) )
     91                            $merged_data[ $answer_option ] += 1;
     92                    endforeach;
     93                endif;
    8194            endforeach;
    8295           
  • questions/trunk/components/charts/shortcodes.php

    r1131247 r1131329  
    5454       
    5555        $survey = new Questions_Survey( $atts[ 'id' ] );
    56         $ordered_data = Questions_AbstractData::order_for_charting( $survey->get_responses( FALSE, FALSE ) );
     56        $response = $survey->get_responses( FALSE, FALSE );
     57        $ordered_data = Questions_AbstractData::order_for_charting( $response );
    5758       
    5859        $html = '';
  • questions/trunk/init.php

    r1131247 r1131329  
    44Plugin URI: http://www.awesome.ug
    55Description: Drag & drop your survey/poll with the WordPress Questions plugin.
    6 Version: 1.0.0 beta 5
     6Version: 1.0.0 beta 6
    77Author: awesome.ug
    88Author URI: http://www.awesome.ug
Note: See TracChangeset for help on using the changeset viewer.