HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/selfanalyse/emu-personality-test/test-report-new.php
<?php

/**
 *
 * Title : Test Report
 * Developer : Rohit Kashyap
 * Date : 17 Apr,2020
 * Description : User test report and their score with highchart.
 */
// ini_set('dsiplay_errors', 1);
// error_reporting(E_ALL);
include_once('../wp-config.php');

if (is_user_logged_in()) {
    $user_id = $current_user->ID;


    global $wpdb;
    $PSY_EXAMS = $wpdb->prefix . PSY_EXAMS;
    $PSY_ABILITY = $wpdb->prefix . PSY_ABILITY;
    $PSY_ABILITY_CLASS = $wpdb->prefix . PSY_ABILITY_CLASS;
    $PSY_USERS_DETAILS = $wpdb->prefix . PSY_USERS_DETAILS;
    $PSY_SP_OPTION_VALUE = $wpdb->prefix . PSY_SP_OPTION_VALUE;
    $PSY_ABILITY_RAW_SCORE = $wpdb->prefix . PSY_ABILITY_RAW_SCORE;
    $PSY_EMU_PER_RAW_SCORE = $wpdb->prefix . PSY_EMU_PER_RAW_SCORE;
    $PSY_TEST_GEN_TEST_TAKEN = $wpdb->prefix . PSY_TEST_GEN_TEST_TAKEN;
    $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER = $wpdb->prefix . PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER;

    $testID = $_REQUEST['testId'];

    $curDate = date('Y-m-d H:i:s');

    /**
     * IF test id is numeric and length is smaller than equal to 5
     */
    if (is_numeric($testID) && strlen($testID) <= 5) {

        $checkTest = $wpdb->get_var("SELECT count(test_taken_id) FROM $PSY_TEST_GEN_TEST_TAKEN where test_taken_id='$testID' and user_id='$user_id' and test_type='EMU' and status='Y'");

        /**
         * IF test id exist
         */
        if ($checkTest != '0') {


            /**
             * Get user date buy user id
             */
            $userData = $wpdb->get_row("SELECT ud.first_name,ud.last_name,ud.date_of_birth FROM $PSY_USERS_DETAILS as ud where user_id='$user_id'");

            $studentName = $userData->first_name . ' ' . $userData->last_name;
            $dob = date('d F, Y', strtotime($userData->date_of_birth));


            /**
             * Get user details from test taken table by test id
             */
            $getTestDetails = $wpdb->get_row("SELECT tt.total_questions,tt.class_id,tt.exam_category_id,tt.time_taken_in_seconds,tt.start_date,e.category_name,cl.class_name FROM $PSY_TEST_GEN_TEST_TAKEN as tt LEFT JOIN $PSY_EXAMS as e on e.exam_category_id=tt.exam_category_id LEFT JOIN $PSY_ABILITY_CLASS as cl on cl.class_id=tt.class_id where tt.test_taken_id='$testID' and tt.status='Y'");

            $exam_id = $getTestDetails->exam_category_id;
            $class_id = $getTestDetails->class_id != '0' ? $getTestDetails->class_id : '13';
            $class = $getTestDetails->class_name;
            $dateAttempt = date('d F, Y', strtotime($getTestDetails->start_date));
            $seconds = $getTestDetails->time_taken_in_seconds;
            $testDate = date('Y-m-d H:i:s', strtotime($getTestDetails->start_date));
            $date1 = str_replace('-', '/', $testDate);
            $tomorrow = date('Y-m-d H:i:s', strtotime($date1 . '+1 days'));

            $parent_subject = $wpdb->get_var("SELECT exam_category_id FROM $PSY_EXAMS where parent_id='$exam_id'");

            /**
             * Fetch Scores
             */

            /**
             * Calculating score and average of first 6 topics
             */

            $getMotivationScore = $wpdb->get_var("SELECT AVG(answer) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48355' and test_taken_id='$testID'");

            $getGMscore = $wpdb->get_var("SELECT answer FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48356' and test_taken_id='$testID'");

            $getSEstscore = $wpdb->get_var("SELECT answer FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48357' and test_taken_id='$testID'");

            $getPreservanceScore = $wpdb->get_var("SELECT AVG(CASE WHEN test_question_id IN(82953,82955,82957,82967) THEN answer * -1 ELSE answer END) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48358' and  test_question_id IN(82953,82954,82955,82956,82957,82960,82961,82962,82963,82965,82967,82968,82969,82982) and test_taken_id='$testID'");

            $getRefScore = $wpdb->get_var("SELECT AVG(answer) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48358' and test_question_id IN(82970,82971,82973,82974,82976,82977,82978,82979,82981) and test_taken_id='$testID'");

            $getNegEffScore = $wpdb->get_var("SELECT SUM(CASE WHEN test_question_id = 82975 THEN answer * -1 ELSE answer END) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48358' and test_question_id IN(82958,82959,82964,82966,82972,82975,82980) and test_taken_id='$testID'");


            /**
             * Calculating sum of last 5 topics
             */
            $getExvScore = $wpdb->get_var("SELECT SUM(CASE WHEN test_question_id = 82988 THEN answer * -1 ELSE answer END) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48359' and  test_question_id IN(82983,82988) and test_taken_id='$testID'");

            $getAggbScore = $wpdb->get_var("SELECT SUM(CASE WHEN test_question_id = 82984 THEN answer * -1 ELSE answer END) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48360' and  test_question_id IN(82984,82989) and test_taken_id='$testID'");

            $getConsScore = $wpdb->get_var("SELECT SUM(CASE WHEN test_question_id = 82990 THEN answer * -1 ELSE answer END) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48361' and  test_question_id IN(82985,82990) and test_taken_id='$testID'");

            $getEmStScore = $wpdb->get_var("SELECT SUM(CASE WHEN test_question_id = 82991 THEN answer * -1 ELSE answer END) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48362' and  test_question_id IN(82986,82991) and test_taken_id='$testID'");

            $getOpexpScore = $wpdb->get_var("SELECT SUM(CASE WHEN test_question_id = 82992 THEN answer * -1 ELSE answer END) FROM $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER where module_id='48363' and  test_question_id IN(82987,82992) and test_taken_id='$testID'");

            /**
             * Array for first 6 topics
             */
            $percentiledata = array("Motivation Calibration" => $getMotivationScore, "Growth Mindset" => $getGMscore, "Self Esteem" => $getSEstscore, "Perseverance" => $getPreservanceScore, "Reflective and adaptive help-seeking" => $getRefScore, "Negative affect and emotional response" => $getNegEffScore);



            /**
             * Array for last 5 topics and calculating score
             */
            $rankdata = array("Extraversion" => $getExvScore, "Agreeableness" => $getAggbScore, "Emotional Stability" => $getEmStScore, "Conscientiousness" => $getConsScore,  "Openness to Experiences" => $getOpexpScore);

            $rankArray = array();
            $defaultArray = array();
            $o=1;
            foreach ($rankdata as $key => $val) {

                $raw_score = number_format((float) $val, 1, '.', '');

                echo "<br>" . $key;
                echo $raw_score;

                if ($raw_score > 0) {
                    $defValue = 8;
                } else {
                    $defValue = 8 * (-1);
                }
                $minus_val = '';
                if($key == 'Extraversion' && $raw_score < 0){
                    $minus_val = 'Introvert';
                } else if($key == 'Agreeableness' && $raw_score < 0){
                    $minus_val = 'Careless';
                } else if($key == 'Emotional Stability' && $raw_score < 0){
                    $minus_val = 'Emotional';
                } else if($key == 'Conscientiousness' && $raw_score < 0){
                    $minus_val = 'Suspicious';
                } else if($key == 'Openness to Experiences' && $raw_score < 0){
                    $minus_val = 'Conventional, Uncreative';
                }
                

                //$getrank = $wpdb->get_var("SELECT rank FROM $PSY_EMU_PER_RAW_SCORE where raw_score=$raw_score");

                /**
                 * Create array for highchart according to raw score
                 */
                $rankArray[] = array("y" => (int) $raw_score, "name" => $key,"minus"=>$minus_val);

                /**
                 * Create defaut array values
                 */
                $defaultArray[] = array("y" => (int) $defValue, "name" => 'Default',"order"=>$o);

                $o++;
            }

            /**
             * Calculating score separately
             */
            $one = number_format((float) $getExvScore, 1, '.', '');
            $two = number_format((float) $getAggbScore, 1, '.', '');
            $three = number_format((float) $getConsScore, 1, '.', '');
            $four = number_format((float) $getEmStScore, 1, '.', '');
            $five = number_format((float) $getOpexpScore, 1, '.', '');


?>
            <link rel="stylesheet" href="/aptitude-test/css/bootstrap.min.css">
            <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css">


            <script src="/aptitude-test/js/jquery.min.js"></script>
            <script src="/aptitude-test/js/bootstrap.min.js"></script>
            <script src="/aptitude-test/js/highcharts.js"></script>
            <script src="https://code.highcharts.com/highcharts-more.js"></script>
            <script src="https://code.highcharts.com/modules/solid-gauge.js"></script>



            <style>
                .bold-txt {
                    font-weight: bold;
                    color: #000;
                }

                .col-md-2 {
                    width: 13.666667% !important;
                }

                /* MARGIN CSS */
                .mt-20 {
                    margin-top: 20px
                }

                .mb-20 {
                    margin-bottom: 20px
                }

                table {
                    border-collapse: collapse;
                    border-spacing: 0;
                    width: 100%;
                    border: 1px solid #ddd;
                }

                th,
                td {
                    text-align: left;
                    padding: 8px;
                }

                .header-logo {
                    width: 40%;
                    float: right;
                }

                .chart-header-box {
                    float: left;
                    width: 100%;

                    margin-top: 2em;
                    border-radius: 4px;
                    background: #fff;
                    padding: 10px;
                    border-bottom: 1px solid #cecece;
                }

                .chart-header-box h4 {
                    font-size: 16px;
                }

                .intro-box {
                    margin: 0;
                    padding-left: 14px;
                    background: #fff;
                    padding: 10px;

                    float: left;
                    width: 100%;
                }

                .intro-box h2 {
                    margin: 0;
                    color: #464646;
                    font-weight: 600;
                    font-size: 24px;
                    padding: 0 0 20px;
                }



                .one-circle-box {
                    border-radius: 50%;
                    text-align: center;
                    padding: 24px 0;
                    width: 140px;
                    margin: 0 auto;
                }

                .one-circle-box i {
                    font-size: 28px;
                }

                .chart-box {
                    border: 1px solid #cccccc;
                    box-shadow: 0 2px 4px 2px #c7c7c7;
                    margin: 2em 0;
                }

                #container {
                    /* height: 550px; */
                }

                .highcharts-data-table table {
                    font-family: Verdana, sans-serif;
                    border-collapse: collapse;
                    border: 1px solid #EBEBEB;
                    margin: 10px auto;
                    text-align: center;
                    width: 100%;
                    max-width: 500px;
                }

                .highcharts-data-table caption {
                    padding: 1em 0;
                    font-size: 1.2em;
                    color: #555;
                }

                .highcharts-data-table th {
                    font-weight: 600;
                    padding: 0.5em;
                }

                .highcharts-data-table td,
                .highcharts-data-table th,
                .highcharts-data-table caption {
                    padding: 0.5em;
                }

                .highcharts-data-table thead tr,
                .highcharts-data-table tr:nth-child(even) {
                    background: #f8f8f8;
                }

                .highcharts-data-table tr:hover {
                    background: #f1f7ff;
                }

                svg:not(:root) {
                    overflow: visible !important;
                }

                .highcharts-container {
                    overflow: visible !important;
                }

                .intro-box h5 {
                    margin: 0;
                    color: #fff;
                    font-size: 18px;
                    padding: 10px;
                    text-align: center;
                    background: #f1802b;
                }

                .ability-desc-box h2 {
                    margin: 0;
                    color: #464646;
                    font-weight: 600;
                    font-size: 20px;
                    padding: 30px 0 10px;
                }


                .intro-box p {
                    margin: 0;
                    font-size: 16px;
                }

                .ability-desc-box {
                    border-bottom: 1px solid #434348;
                    padding-bottom: 20px;
                }

                .sten-score {
                    border: 1px solid #b1b1b1;
                    box-shadow: 0 2px 4px 2px #9a9a9a;
                    padding: 10px;
                    margin-top: 1em;
                    /* background: #90ed7d; */
                }

                .sten-score h3 {
                    font-size: 18px;
                    margin: 0;
                    padding-bottom: 10px;
                }

                .description-ul {
                    padding: 20px;
                }

                .description-ul li {
                    list-style: decimal;
                    color: #000;
                    margin-bottom: 20px;
                    font-size: 15px;
                }

                .test-head {
                    font-size: 26px !important;
                    padding-bottom: 10px;
                }

                .chart-header-box h6 {
                    margin: 0;
                    font-size: 17px;
                    padding: 10px 0 30px;
                    line-height: 24px;
                    font-weight: 600;
                }

                .back-home-btn {
                    font-size: 14px;
                    background: #0085f7;
                    padding: 10px;
                    display: table;
                    margin: 0 auto;
                    color: #fff;
                    cursor: pointer;
                    border-radius: 4px;
                    font-weight: bold;
                }

                .fb-share {
                    background: #3b5998;
                    border-radius: 3px;
                    font-weight: 600;
                    padding: 5px 8px;
                    float: right;
                    position: relative;
                    top: -4px;
                    display: inline-flex;
                }

                .fb-share:hover {
                    cursor: pointer;
                    background: #213A6F
                }

                .fb-share svg {
                    width: 18px;
                    fill: white;
                    vertical-align: middle;
                    border-radius: 2px
                }

                .fb-share span {
                    vertical-align: middle;
                    color: white;
                    font-size: 14px;
                    padding: 0 3px
                }

                /* aptitude-test CSS */

                #btnPrint {
                    float: right;
                    margin-bottom: 12px;
                    background: #154479;
                    border: none;
                    color: #fff;
                    padding: 4px 10px;
                    font-weight: 600;
                    border-radius: 4px;
                }

                .topic {
                    padding: 10px 0px 10px 0px;
                    font-size: 20px;
                    list-style: none;
                }

                /* END aptitude-test CSS */
            </style>
            <script>
                // Load the fonts
                Highcharts.createElement('link', {
                    href: 'https://fonts.googleapis.com/css?family=Ubuntu:400,700',
                    rel: 'stylesheet',
                    type: 'text/css'
                }, null, document.getElementsByTagName('head')[0]);
                // Add the background image to the container
                Highcharts.addEvent(Highcharts.Chart, 'afterGetContainer', function() {
                    // eslint-disable-next-line no-invalid-this
                    this.container.style.background =
                        'url(https://www.highcharts.com/samples/graphics/sand.png)';
                });
                Highcharts.theme = {

                    chart: {
                        backgroundColor: null,
                        style: {
                            fontFamily: 'Ubuntu, sans-serif'
                        }
                    },
                    title: {
                        style: {
                            color: 'black',
                            fontSize: '16px',
                            fontWeight: 'bold'
                        }
                    },
                    subtitle: {
                        style: {
                            color: 'black'
                        }
                    },
                    tooltip: {
                        borderWidth: 0
                    },
                    labels: {
                        style: {
                            color: '#6e6e70'
                        }
                    },
                    legend: {
                        backgroundColor: '#E0E0E8',
                        itemStyle: {
                            fontWeight: 'bold',
                            fontSize: '13px'
                        }
                    },
                    xAxis: {
                        labels: {
                            style: {
                                color: '#6e6e70'
                            }
                        }
                    },
                    yAxis: {
                        labels: {
                            style: {
                                color: '#6e6e70'
                            }
                        }
                    },
                    plotOptions: {
                        series: {
                            shadow: true
                        },
                        candlestick: {
                            lineColor: '#404048'
                        },
                        map: {
                            shadow: false
                        }
                    },
                    // Highstock specific
                    navigator: {
                        xAxis: {
                            gridLineColor: '#D0D0D8'
                        }
                    },
                    rangeSelector: {
                        buttonTheme: {
                            fill: 'white',
                            stroke: '#C0C0C8',
                            'stroke-width': 1,
                            states: {
                                select: {
                                    fill: '#D0D0D8'
                                }
                            }
                        }
                    },
                    scrollbar: {
                        trackBorderColor: '#C0C0C8'
                    }
                };
                // Apply the theme
                Highcharts.setOptions(Highcharts.theme);
            </script>

            <!-- TOP TABLE SECTION -->
            <section style="background: #f1f1f1;" id="main">
                <div class="container">
                    <!----User details--->
                    <div class="row">

                        <div class="chart-header-box">
                            <div class="col-md-8">
                                <h4 class="test-head"><?php echo $getTestDetails->category_name; ?></h4>
                                <h4>Name : <span style="font-weight: bold;"> <?php echo $studentName; ?> </span>, <span> Class :</span> <span style="font-weight: bold;"><?php echo $class ?></span></h4>
                                <h4>Date Attempt : <span style="font-weight: bold;"><?php echo $dateAttempt; ?></span></h4>
                            </div>
                            <div class="col-md-4">
                                <img class="header-logo" src="http://staging.shinemetrics.com/wp-content/themes/psychometrics/images/shine-logo.png" alt="">
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="intro-box">
                            <!----percentile gauge---->
                            <?php
                            //$percentileArray = array();
                            /**
                             * Creating percentile gauge highcharts by calculating percentile from $PSY_EMU_PER_RAW_SCORE table
                             */
                            $i = 1;
                            foreach ($percentiledata as $key => $val) {

                                $percent_raw_score = number_format((float) $val, 1, '.', '');

                                $getPercentile = $wpdb->get_var("SELECT percentile_rounded FROM $PSY_EMU_PER_RAW_SCORE where raw_score=$percent_raw_score");

                                $percentile = (int) $getPercentile;


                            ?>
                                <div class="col-md-4">
                                    <div class="chart-box">
                                        <figure class="highcharts-figure">
                                            <div id="container_<?php echo $i ?>" style="height: 290px;"></div>
                                        </figure>
                                    </div>
                                </div>


                                <script type="text/javascript">
                                    var gaugeOptions = {
                                        chart: {
                                            type: 'solidgauge'
                                        },

                                        title: {
                                            text: '<?php echo $key ?>'
                                        },

                                        pane: {
                                            center: ['50%', '85%'],
                                            size: '140%',
                                            startAngle: -90,
                                            endAngle: 90,
                                            background: {
                                                backgroundColor: Highcharts.defaultOptions.legend.backgroundColor || '#EEE',
                                                innerRadius: '60%',
                                                outerRadius: '100%',
                                                shape: 'arc'
                                            }
                                        },

                                        exporting: {
                                            enabled: false
                                        },

                                        tooltip: {
                                            enabled: false
                                        },

                                        // the value axis
                                        yAxis: {
                                            stops: [
                                                [0.1, '#55BF3B'], // green
                                                [0.5, '#DDDF0D'], // yellow
                                                [0.9, '#DF5353'] // red
                                            ],
                                            lineWidth: 0,
                                            tickWidth: 0,
                                            minorTickInterval: null,
                                            tickAmount: 2,
                                            labels: {
                                                y: 16
                                            }
                                        },

                                        plotOptions: {
                                            solidgauge: {
                                                dataLabels: {
                                                    y: 5,
                                                    borderWidth: 0,
                                                    useHTML: true
                                                }
                                            }
                                        }
                                    };

                                    // The speed gauge
                                    var chartSpeed = Highcharts.chart('container_<?php echo $i ?>', Highcharts.merge(gaugeOptions, {
                                        yAxis: {
                                            min: 0,
                                            max: 100,
                                        },

                                        credits: {
                                            enabled: false
                                        },

                                        series: [{
                                            name: '<?php echo $key ?>',
                                            data: [<?php echo $percentile ?>],
                                            dataLabels: {
                                                format: '<div style="text-align:center">' +
                                                    '<span style="font-size:25px">{y}</span><br/>' +
                                                    '<span style="font-size:12px;opacity:0.4">Percentile</span>' +
                                                    '</div>'
                                            },
                                            tooltip: {
                                                valueSuffix: 'Percentile'
                                            }
                                        }]

                                    }));
                                </script>
                            <?php
                                $i++;
                            }
                            ?>
                        </div>
                    </div>
                    <!----percentile gauge end---->

                    <!----comparison highcharts---->
                    <div class="row">
                        <div class="intro-box">
                            <div class="col-md-2"></div>
                            <div class="col-md-8">
                                <div class="chart-box">
                                    <figure class="highcharts-figure">
                                        <div id="container" style="height: 370px;"></div>
                                    </figure>
                                </div>
                            </div>
                            <div class="col-md-2"></div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="intro-box">
						
                            <div class="col-md-2">
                                <!-- <div class="chart-box">
                                    <figure class="highcharts-figure">
                                        <ul style="margin-top: 44px;">
                                            <li class="topic">Introverted</li>
                                            <li class="topic">Careless</li>
                                            <li class="topic">Suspicious and Antagonistic</li>
                                            <li class="topic">Emotional Stability</li>
                                            <li class="topic">Conventional, Uncreative</li>
                                        </ul>
                                    </figure>
                                </div> -->
                            </div> 
                            <div class="col-md-8">
                                <div class="chart-box">
                                    <figure class="highcharts-figure">
                                        <div id="container_test" style="height: 370px;"></div>
                                    </figure>
                                </div>
                            </div>
							
                            <div class="col-md-2">
                                <!-- <div class="chart-box">
                                    <figure class="highcharts-figure">
                                        <ul style="margin-top: 44px;">
                                            <li class="topic">Extroverted</li>
                                            <li class="topic">Perfectionist</li>
                                            <li class="topic">Compassionate and Cooperative</li>
                                            <li class="topic">Emotional Stability</li>
                                            <li class="topic">Creativeness, Curiosity</li>
                                        </ul>
                                    </figure>
                                </div> -->
                            </div>
							
                        </div>
                    </div>
                </div>
            </section>

            <!-- END TOP TABLE SECTION -->


            <script>
                function popOut(pageURL, pageTitle,
                    popupWinWidth, popupWinHeight) {
                    var left = (screen.width - popupWinWidth) / 2;
                    var top = (screen.height - popupWinHeight) / 4;

                    var myWindow = window.open(pageURL, pageTitle,
                        'resizable=yes, width=' + popupWinWidth +
                        ', height=' + popupWinHeight + ', top=' +
                        top + ', left=' + left);
                }

                //comparison bar chart
                var chart = Highcharts.chart('container', {
                    chart: {
                        type: 'bar'
                    },
                    title: {
                        text: 'EMU - Personality Test'
                    },
                    plotOptions: {
                        series: {
                            grouping: false,
                            borderWidth: 0,
                        }
                    },
                    legend: {
                        enabled: false
                    },
                    tooltip: {
                        shared: true,
                        headerFormat: '<span style="font-size: 15px">{point.point.name}</span><br/>',
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y} </b><br/>'
                    },
                    xAxis: [{
                        type: 'category',
                        max: 4,
                        reversed: true,
                    }, {
                        opposite: true,
                        reversed: true,

                    }],
                    yAxis: [{
                        title: {
                            text: 'Rank'
                        },
                        max: 8,
                        min: -8,
                        tickInterval: 1,
                        showFirstLabel: true,
                    }],
                    series: [{
                        name: 'Range',
                        color: 'rgb(158, 159, 163)',
                        pointPlacement: -0.2,
                        linkedTo: 'main',
                        data: <?php echo json_encode($defaultArray); ?>,
                    }, {
                        name: 'Current',
                        id: 'main',
                        colorByPoint: true,

                        dataSorting: {
                            enabled: true,
                            matchByName: true,
                            sortKey: 'series.order'
                        },
                        dataLabels: [{
                            enabled: true,
                            inside: true,
                            style: {
                                fontSize: '16px'
                            }
                        }],
                        data: <?php echo json_encode($rankArray); ?>
                    }]
                });
                Highcharts.chart('container_test', {
                    chart: {
                        type: 'bar',
						 
                    },

                    title: {
                        text: 'Abilities'
                    },
                    xAxis: [{
                        visible: false,
						
                    }],
                    yAxis: [{
                        title: {
                            text: 'Rank'
                        },
						
                        max: 8,
                        min: -8,
                        tickInterval: 1,
                        showFirstLabel: true,
                    }],
					
                    plotOptions: {
                        series: {
                            pointPadding: -0.50
                        },
                    },
					
                    series: [{
                        name: 'Range',
                        color: 'rgb(158, 159, 163)',
                        pointPlacement: -0.2,
                        linkedTo: 'main',
						pointWidth: 30,
                        data: <?php echo json_encode($defaultArray); ?>,
                    }, {
                        name: '',
                        id: 'main',
						pointWidth: 30,
                        colorByPoint: true,
                        dataSorting: {
                            enabled: false,
                            matchByName: true,
                            sortKey: 'series.order'
                        },
                        dataLabels: [{
                            enabled: true,
                            inside: true,
                            style: {
                                fontSize: '16px'
                            }
                        }],
						
                        data: <?php echo json_encode($rankArray); ?>
                    },
					{
						name: 'Extraversion',
						pointWidth: 30,

					},
					{
						name: 'Agreeableness',
						pointWidth: 30,

					}, {
						name: 'Emotional Stability',
						pointWidth: 30,
					
					}, {
						name: 'Conscientiousness',
						pointWidth: 30,
						
					}, {
						name: 'Openness to Experiences',
						pointWidth: 30,
					
					}],
					
					
                });
                // Highcharts.chart('container_test', {
                //     chart: {
                //         type: 'bar'
                //     },
                //     title: {
                //         text: 'EMU - Personality Test'
                //     },
                //     plotOptions: {
                //         series: {
                //             grouping: false,
                //             borderWidth: 0,
                //         }
                //     },
                //     legend: {
                //         enabled: false
                //     },
                //     tooltip: {
                //         shared: true,
                //         headerFormat: '<span style="font-size: 15px">{point.point.name}</span><br/>',
                //         pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y} </b><br/>'
                //     },
                //     xAxis: [{
                //         type:'category',
                //         visible:false
                //     }],
                //     yAxis: [{
                //         title: {
                //             text: 'Rank'
                //         },
                //         max: 8,
                //         min: -8,
                //         tickInterval: 1,
                //         showFirstLabel: true,
                //     }],
                //     series: [{
                //         name: 'Range',
                //         color: 'rgb(158, 159, 163)',
                //         pointPlacement: -0.2,
                //         pointWidth: 30,
                //         linkedTo: 'main',
                //         data: <?php echo json_encode($defaultArray); ?>,
                //     }, {
                //         name: 'Current',
                //         id: 'main',
                //         colorByPoint: true,
                //         pointWidth: 30,
                //         dataSorting: {
                //             enabled: true,
                //             matchByName: true,
                //             sortKey: 'series.order'
                //         },
                //         dataLabels: [{
                //             enabled: true,
                //             inside: true,
                //             verticalAlign: 'top',
			    //             align: 'top',
                //             style: {
                //                 fontSize: '16px'
                //             }
                //         }],
                //         data: <?php echo json_encode($rankArray); ?>,
                        
                //     },{
				// 		name: 'Extraversion',
				// 		pointWidth: 30,
				// 	},
				// 	{
				// 		name: 'Agreeableness',
				// 		pointWidth: 30,
				// 	}, {
				// 		name: 'Emotional Stability',
				// 		pointWidth: 30,
				// 	}, {
				// 		name: 'Conscientiousness',
				// 		pointWidth: 30,
				// 	}, {
				// 		name: 'Openness to Experiences',
				// 		pointWidth: 30,
				// 	}]
                // });

                // Highcharts.chart('container_test', {
                //     chart: {
                //         type: 'bar'
                //     },
                //     title: {
                //         text: 'EMU - Personality Test'
                //     },
                //     xAxis: {
                //         visible:false
                //     },
                //     yAxis: {
                //         max: 10,
                //         min: -10,
                //         title: {
                //             text: 'Total fruit consumption'
                //         },
                //         stackLabels: {
                //             enabled: true,
                //             style: {
                //                 fontWeight: 'bold',
                //                 color: ( // theme
                //                     Highcharts.defaultOptions.title.style &&
                //                     Highcharts.defaultOptions.title.style.color
                //                 ) || 'gray'
                //             }
                //         }
                //     },
                //     legend: {
                //         align: 'right',
                //         x: -30,
                //         verticalAlign: 'top',
                //         y: 25,
                //         floating: true,
                //         backgroundColor: Highcharts.defaultOptions.legend.backgroundColor || 'white',
                //         borderColor: '#CCC',
                //         borderWidth: 1,
                //         shadow: false
                //     },
                //     tooltip: {
                //         headerFormat: '<b>{point.x}</b><br/>',
                //         pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
                //     },
                //     plotOptions: {
                //         bar: {
                //             stacking: 'normal',
                //             dataLabels: {
                //                 enabled: true
                //             }
                //         }
                //     },
                //     series: [{
                //         name: 'Range',
                //         color: 'rgb(158, 159, 163)',
                //         data: <?php echo json_encode($defaultArray); ?>,
                //     }, {
                //         name: 'Abilities',
                //         colorByPoint: true,
                //         dataLabels: [{
                //             enabled: true,
                //             inside: true,
                //             style: {
                //                 fontSize: '16px'
                //             }
                //         }],
                //         data: <?php echo json_encode($rankArray); ?>
                //     }]
                // });
                //bar chart share button
                $("#share_bar").click(function() {
                    var data = {
                        options: JSON.stringify(options_bar),
                        resources: {
                            // You can add your CSS styles here
                            css: ".highcharts-background { fill: #efefef; stroke: #a4edba; stroke-width: 2px}"
                        },
                        width: 500,
                        height: 500,
                        filename: 'test.png',
                        type: 'image/png',
                        async: true
                    };

                    var exportUrl = 'https://export.highcharts.com/';
                    $.post(exportUrl, data, function(data) {
                        var imageUrl = exportUrl + data;
                        console.log(imageUrl)
                        var urlCreator = window.URL || window.webkitURL;
                        //document.querySelector("#image").src = imageUrl;
                        //window.location = "https://wa.me/?text=" + encodeURIComponent(imageUrl);
                        window.open('https://www.facebook.com/sharer/sharer.php?u=' + imageUrl,
                            'facebook-share-dialog',
                            'width=800,height=600'
                        );
                        return false;
                    });
                });
            </script>
<?php
        } else {
            echo "Error : No test id found.";
        }
    } else {
        echo "Error : Invalid Test Id.";
    }
} else {
    echo "Error : Please login to view report.";
}
?>