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/counselor/emu-personality-report.php
<?php

/**
 *
 * Title : Test Report
 * Developer : Rohit Kashyap
 * Date : 18 Mar,2020
 * Description : User test report and their sten score in print format with highchart.
 */
include_once('../wp-config.php');



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;

$user_id = $_REQUEST['student_id'];
$testID = $_REQUEST['testId'];

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

if ($testID != '' && is_numeric($testID) && strlen($testID) <= 5 && is_numeric($user_id) && $user_id != '') {

    $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-PER' and status='Y'");

    if ($checkTest != '0') {



        $userData = $wpdb->get_row("SELECT ud.first_name,ud.last_name,ud.date_of_birth,ud.gender_id,ud.email_address,ud.mobile_number 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));
        $gender = $userData->gender_id;
        $email = $userData->email_address;
        $mobile = $userData->mobile_number;




        $getTestDetails = $wpdb->get_row("SELECT tt.total_questions,tt.class_id,tt.exam_category_id,tt.time_taken_in_seconds,tt.start_date,tt.finish_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));
        $finish_date = date('Y-m-d H:i:s', strtotime($getTestDetails->finish_date));
        $hourdiff = round((strtotime($curDate) - strtotime($finish_date)) / 3600, 1);

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

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

        $raw_score_mc = number_format((float) $getMotivationScore, 1, '.', '');
        $getPercentile_mc = $wpdb->get_var("SELECT percentile_rounded FROM $PSY_EMU_PER_RAW_SCORE where raw_score=$raw_score_mc");
        $percentile_mc = (int) $getPercentile_mc;
        $img_mc = strtolower(str_replace(" ", "-", "Motivation Calibration"));
        $image_mc = $testID . '-' . $img_mc . '.png';

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

        $raw_score_gm = number_format((float) $getGMscore, 1, '.', '');
        $getPercentile_gm = $wpdb->get_var("SELECT percentile_rounded FROM $PSY_EMU_PER_RAW_SCORE where raw_score=$raw_score_gm");
        $percentile_gm = (int) $getPercentile_gm;
        $img_gm = strtolower(str_replace(" ", "-", "Growth Mindset"));
        $image_gm = $testID . '-' . $img_gm . '.png';

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

        $raw_score_se = number_format((float) $getSEstscore, 1, '.', '');
        $getPercentile_se = $wpdb->get_var("SELECT percentile_rounded FROM $PSY_EMU_PER_RAW_SCORE where raw_score=$raw_score_se");
        $percentile_se = (int) $getPercentile_se;
        $img_se = strtolower(str_replace(" ", "-", "Self Esteem"));
        $image_se = $testID . '-' . $img_se . '.png';

        /***
         * Perservance
         */
        $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'");

        $raw_score_pv = number_format((float) $getPreservanceScore, 1, '.', '');
        $getPercentile_pv = $wpdb->get_var("SELECT percentile_rounded FROM $PSY_EMU_PER_RAW_SCORE where raw_score=$raw_score_pv");
        $percentile_pv = (int) $getPercentile_pv;
        $img_pv = strtolower(str_replace(" ", "-", "Perseverance"));
        $image_pv = $testID . '-' . $img_pv . '.png';

        /***
         * Reflective & Adaptaive
         */
        $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'");

        $raw_score_ra = number_format((float) $getRefScore, 1, '.', '');
        $getPercentile_ra = $wpdb->get_var("SELECT percentile_rounded FROM $PSY_EMU_PER_RAW_SCORE where raw_score=$raw_score_ra");
        $percentile_ra = (int) $getPercentile_ra;
        $img_ra = strtolower(str_replace(" ", "-", "Reflective and adaptive help-seeking"));
        $image_ra = $testID . '-' . $img_ra . '.png';

        /***
         * Negative Effect & Emotional Response
         */
        $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'");

        $raw_score_nef = number_format((float) $getNegEffScore, 1, '.', '');
        $getPercentile_nef = $wpdb->get_var("SELECT percentile_rounded FROM $PSY_EMU_PER_RAW_SCORE where raw_score=$raw_score_nef");
        $percentile_nef = (int) $getPercentile_nef;
        $img_nef = strtolower(str_replace(" ", "-", "Negative affect and emotional response"));
        $image_nef = $testID . '-' . $img_nef . '.png';

        /**
         * 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 last 5 topics and calculating score
         */
        $rankdata = array("Neuroticism" => $getEmStScore, "Agreeableness" => $getAggbScore, "Extraversion" => $getExvScore, "Conscientiousness" => $getConsScore,  "Openness to Experiences" => $getOpexpScore);



?>
        <!DOCTYPE html>
        <html <?php language_attributes(); ?>>

        <head>
            <title>Personality Test Report - ThinkEmu</title>
            <link rel="icon" href="/wp-content/themes/psychometrics/images/emu.ico" type="image/x-icon" />
            <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">
        </head>

        <style>
            @import url(https://fonts.googleapis.com/css?family=Lato);

            body {
                font-family: 'Lato', sans-serif;
            }

            .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 {
                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>

        <body>
            <!-- TOP TABLE SECTION -->
            <section style="background: #f1f1f1;padding: 2em 0;" id="main">
                <div class="container">
                    <!----User details--->
                    <div class="row">
                        <div class="chart-header-box" style="margin-bottom: 2em;">
                            <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="https://selfanalyse.com/wp-content/themes/psychometrics/images/emu-logo.png" alt="">
                            </div>
                        </div>
                    </div>
                    <!----First Page Content--->
                    <div class="row">
                        <div class="intro-box print-view-box">
                                <form action="/emu-personality-test/pdf.php" method="post" target="_blank">
                                    <input type="hidden" name="test" value="<?php echo $testID; ?>">
                                    <button id="btnPrint" type="submit">View as PDF</button>
                                </form>
                            <div class="col-md-12">
                                <h3>ABOUT PERSONALITY TESTS</h3>
                                <p>Personality is defined as the characteristic sets of behaviors, cognitions, and emotional patterns that distinguish individuals from one another. Our personalities are predicted by biological and environmental factors. While there is no generally agreed upon definition of personality, most theories focus on motivation and psychological interactions with one's environment. Personality has many dimensions which according to research may predict behavior, type of interpersonal relationships, success in career etc.
                                </p>
                                <p>The results from numerous research programs suggest that many nontraditional cognitive and behavioral factors also significantly and differentially contribute to academic success.</p>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="chart-header-box" style="margin-bottom: 2em;">
                            <div class="col-md-12">
                                <p>Personality tests are techniques designed to measure the various traits of personality. There are two types of personality tests: self-report inventories and projective tests. We use self-report inventories to measure personality traits as they are free from rater bias.</p>

                                <p>Personality Tests help in</p>
                                <p>
                                    <ul>
                                        <li>Understanding one’s strengths and weaknesses.</li>
                                        <li>Deciding what to study in school/college.</li>
                                        <li>Making informed decisions about careers.</li>
                                        <li>Understanding one’s own behavior.</li>
                                        <li>Improving inter-personal relationships</li>
                                    </ul>
                                </p>
                                <p>At EMU, we try and test various cognitive and behavioral factors, in order for you to understand yourself better. Research has shown that these factors usually play a role in predicting academic/professional success.</p>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- END TOP TABLE SECTION -->
            <div style="display: none;">
                <?php
                $path = '/var/www/selfanalyse/emu-personality-test/pdf-html/pdf-' . $testID . '.html';
                if (file_exists($path)) {
                    echo "exist";
                } else {
                    ob_start();
                    include_once('../emu-personality-test/pdf_content.php');
                    $html = ob_get_contents();
                    file_put_contents('/var/www/selfanalyse/emu-personality-test/pdf-html/pdf-' . $testID . '.html', $html);
                    ob_flush();
                }

                ?>
            </div>
        </body>

        </html>

    <?php
    } else {
    ?>
        <script>
            alert("No test details found");
            window.location.href = '/counselor/emu-personality-tests';
        </script>
    <?php
    }
} else {
    ?>
    <script>
        window.location.href = '/counselor/emu-personality-tests';
    </script>
<?php
}
?>