情商(EQ)测试

情商(EQ)测试

So_Lua
2026-03-20 发布 / 正在检测是否收录...
<?php
/**
 * @title 情商(EQ)测试
 * @description 专业情商测试与评估工具
 * @tag 心理,EQ,情商测试
 */
session_start();

// 初始化EQ测试数据
if (!isset($_SESSION['eq_version'])) {
    $_SESSION['eq_version'] = '1'; // 默认标准版
    $_SESSION['eq_current_num'] = 1;
    $_SESSION['eq_answers'] = [];
    $_SESSION['eq_result'] = null;
}

// 处理开始测试请求
if (isset($_GET['action']) && $_GET['action'] === 'start_test') {
    $version = in_array($_GET['version'], ['1', '2']) ? $_GET['version'] : '1';
    $_SESSION['eq_version'] = $version;
    $_SESSION['eq_current_num'] = 1;
    $_SESSION['eq_answers'] = [];
    $_SESSION['eq_result'] = null;
    echo json_encode(['success' => true, 'version' => $version]);
    exit;
}

// 处理获取题目请求
if (isset($_GET['action']) && $_GET['action'] === 'get_question') {
    $version = $_SESSION['eq_version'] ?? '1';
    $num = $_SESSION['eq_current_num'] ?? 1;
    
    $questions = getEQQuestions($version);
    $max_questions = count($questions);
    
    if ($num <= $max_questions && isset($questions[$num])) {
        echo json_encode([
            'question' => $questions[$num]['question'],
            'optionA' => $questions[$num]['optionA'],
            'optionB' => $questions[$num]['optionB'],
            'optionC' => $questions[$num]['optionC'],
            'current_num' => $num,
            'max_questions' => $max_questions
        ]);
    } else {
        echo json_encode(['error' => '题目不存在,请重试']);
    }
    exit;
}

// 处理保存答案请求
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'save_answer') {
    $answer = $_POST['answer'] ?? '';
    $num = $_SESSION['eq_current_num'] ?? 1;
    $version = $_SESSION['eq_version'] ?? '1';
    
    if (in_array($answer, ['A', 'B', 'C'])) {
        $_SESSION['eq_answers'][$num] = $answer;
        $_SESSION['eq_current_num'] = $num + 1;
        
        $questions = getEQQuestions($version);
        $max_questions = count($questions);
        $is_last_question = ($num >= $max_questions);
        
        echo json_encode([
            'success' => true,
            'next_num' => $num + 1,
            'is_last_question' => $is_last_question,
            'max_questions' => $max_questions
        ]);
    } else {
        echo json_encode(['success' => false, 'error' => '无效答案']);
    }
    exit;
}

// 处理提交测试请求
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'submit_test') {
    $version = $_SESSION['eq_version'] ?? '1';
    $answers = $_SESSION['eq_answers'] ?? [];
    
    $questions = getEQQuestions($version);
    $max_questions = count($questions);
    
    // 验证答案数量
    if (count($answers) < $max_questions) {
        echo json_encode(['success' => false, 'error' => "请完成所有{$max_questions}道题目再提交"]);
        exit;
    }
    
    // 计算EQ分数
    $result = calculateEQScore($answers, $version);
    
    $_SESSION['eq_result'] = $result;
    
    echo json_encode([
        'success' => true,
        'score' => $result['total_score'],
        'level' => $result['level'],
        'description' => formatEQDescription($result)
    ]);
    exit;
}

// 处理重置测试
if (isset($_GET['action']) && $_GET['action'] === 'reset_test') {
    unset($_SESSION['eq_version']);
    unset($_SESSION['eq_current_num']);
    unset($_SESSION['eq_answers']);
    unset($_SESSION['eq_result']);
    echo json_encode(['success' => true]);
    exit;
}

// 获取EQ试题
function getEQQuestions($version) {
    // 标准版50题
    if ($version === '1') {
        return [
            1 => ['question' => '在压力下,我通常能够保持冷静', 'optionA' => '是的', 'optionB' => '不一定', 'optionC' => '不是的'],
            2 => ['question' => '我能清楚地意识到自己的情绪变化', 'optionA' => '是的', 'optionB' => '有时', 'optionC' => '很少'],
            3 => ['question' => '我善于理解他人的感受', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            4 => ['question' => '当遇到挫折时,我能够迅速调整心态', 'optionA' => '总是', 'optionB' => '常常', 'optionC' => '很少'],
            5 => ['question' => '我能够接受批评而不感到被冒犯', 'optionA' => '是的', 'optionB' => '部分情况下', 'optionC' => '不是的'],
            6 => ['question' => '当别人情绪低落时,我能够有效安慰他们', 'optionA' => '总能', 'optionB' => '有时', 'optionC' => '很难'],
            7 => ['question' => '我能够控制自己的负面情绪,不让它们影响他人', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            8 => ['question' => '在团队中,我善于调解冲突', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            9 => ['question' => '我能准确察觉他人未表达出的情绪', 'optionA' => '是的', 'optionB' => '偶尔', 'optionC' => '不是的'],
            10 => ['question' => '面对挑战,我相信自己有能力解决', 'optionA' => '非常相信', 'optionB' => '有些相信', 'optionC' => '不太相信'],
            11 => ['question' => '当事情不如意时,我会反省自己的责任', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            12 => ['question' => '我能够清晰表达自己的需求和感受', 'optionA' => '非常清晰', 'optionB' => '一般', 'optionC' => '不太清晰'],
            13 => ['question' => '我善于倾听他人的想法而不急于评判', 'optionA' => '总是', 'optionB' => '经常', 'optionC' => '很少'],
            14 => ['question' => '我能适应环境的变化', 'optionA' => '很容易', 'optionB' => '需要时间', 'optionC' => '很难'],
            15 => ['question' => '面对批评,我首先考虑如何改进', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            16 => ['question' => '我能够识别他人未说出口的担忧', 'optionA' => '经常', 'optionB' => '偶尔', 'optionC' => '很少'],
            17 => ['question' => '在做决定前,我会考虑对他人的情感影响', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            18 => ['question' => '我能够原谅他人的过错', 'optionA' => '通常能', 'optionB' => '需要时间', 'optionC' => '很难'],
            19 => ['question' => '我能控制冲动,不因情绪做决定', 'optionA' => '总是', 'optionB' => '大部分时候', 'optionC' => '很少'],
            20 => ['question' => '当我犯错时,我愿意承认并改正', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            21 => ['question' => '我能够感知团队的整体情绪氛围', 'optionA' => '非常容易', 'optionB' => '一般', 'optionC' => '困难'],
            22 => ['question' => '在争论中,我能保持冷静并理性表达', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            23 => ['question' => '我的朋友认为我是一个好的倾听者', 'optionA' => '是的', 'optionB' => '部分朋友', 'optionC' => '不是的'],
            24 => ['question' => '我能够设定适当的情绪界限', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            25 => ['question' => '当感到压力时,我有健康的方式来缓解', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            26 => ['question' => '我能够从他人的角度思考问题', 'optionA' => '总是', 'optionB' => '经常', 'optionC' => '很少'],
            27 => ['question' => '在工作中,我能有效管理自己的情绪', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            28 => ['question' => '我能够在不同场合调整自己的表达方式', 'optionA' => '非常灵活', 'optionB' => '一般', 'optionC' => '不太灵活'],
            29 => ['question' => '我善于鼓励和激励他人', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            30 => ['question' => '当他人分享快乐时,我能真诚地为他们高兴', 'optionA' => '总是', 'optionB' => '通常', 'optionC' => '有时勉强'],
            31 => ['question' => '我能够意识到自己的偏见如何影响判断', 'optionA' => '经常', 'optionB' => '有时', 'optionC' => '很少'],
            32 => ['question' => '面对冲突,我寻求双赢解决方案', 'optionA' => '总是', 'optionB' => '经常', 'optionC' => '很少'],
            33 => ['question' => '我能够管理他人对我的期望', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            34 => ['question' => '我能够识别自己的情绪触发点', 'optionA' => '非常清楚', 'optionB' => '部分了解', 'optionC' => '不太了解'],
            35 => ['question' => '在压力下,我仍能考虑他人感受', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            36 => ['question' => '我善于给予他人真诚的赞美', 'optionA' => '总是', 'optionB' => '经常', 'optionC' => '很少'],
            37 => ['question' => '我能够承认自己的情绪弱点', 'optionA' => '是的', 'optionB' => '有时', 'optionC' => '不是的'],
            38 => ['question' => '我能够在不伤害关系的情况下表达不同意见', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            39 => ['question' => '当需要时,我能够寻求情感支持', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            40 => ['question' => '我能够区分自己的情绪与事实', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            41 => ['question' => '我善于理解不同文化背景下的情感表达', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            42 => ['question' => '在做重要决定时,我平衡情感与理性', 'optionA' => '总是', 'optionB' => '通常', 'optionC' => '很少'],
            43 => ['question' => '我能够保持乐观,即使在困境中', 'optionA' => '总是', 'optionB' => '通常', 'optionC' => '很少'],
            44 => ['question' => '我能够从他人的非语言线索中获取情感信息', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            45 => ['question' => '面对失败,我能够从中学习并成长', 'optionA' => '总是', 'optionB' => '通常', 'optionC' => '很少'],
            46 => ['question' => '我能够在适当时候表达自己的脆弱', 'optionA' => '是的', 'optionB' => '有时', 'optionC' => '不是的'],
            47 => ['question' => '在团队中,我能够鼓舞他人情绪', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            48 => ['question' => '我能够识别何时需要暂时退出情绪化情境', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            49 => ['question' => '我相信建立真诚的人际关系很重要', 'optionA' => '强烈同意', 'optionB' => '同意', 'optionC' => '不太同意'],
            50 => ['question' => '我愿意为改善关系付出努力', 'optionA' => '总是', 'optionB' => '通常', 'optionC' => '很少']
        ];
    } 
    // 简版33题
    else {
        return [
            1 => ['question' => '在压力下,我通常能够保持冷静', 'optionA' => '是的', 'optionB' => '不一定', 'optionC' => '不是的'],
            2 => ['question' => '我能清楚地意识到自己的情绪变化', 'optionA' => '是的', 'optionB' => '有时', 'optionC' => '很少'],
            3 => ['question' => '我善于理解他人的感受', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            4 => ['question' => '当遇到挫折时,我能够迅速调整心态', 'optionA' => '总是', 'optionB' => '常常', 'optionC' => '很少'],
            5 => ['question' => '我能够接受批评而不感到被冒犯', 'optionA' => '是的', 'optionB' => '部分情况下', 'optionC' => '不是的'],
            6 => ['question' => '当别人情绪低落时,我能够安慰他们', 'optionA' => '总能', 'optionB' => '有时', 'optionC' => '很难'],
            7 => ['question' => '我能够控制自己的负面情绪,不让它们影响他人', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            8 => ['question' => '在团队中,我善于调解冲突', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            9 => ['question' => '我能准确察觉他人未表达出的情绪', 'optionA' => '是的', 'optionB' => '偶尔', 'optionC' => '不是的'],
            10 => ['question' => '面对挑战,我相信自己有能力解决', 'optionA' => '非常相信', 'optionB' => '有些相信', 'optionC' => '不太相信'],
            11 => ['question' => '当事情不如意时,我会反省自己的责任', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            12 => ['question' => '我能够清晰表达自己的需求和感受', 'optionA' => '非常清晰', 'optionB' => '一般', 'optionC' => '不太清晰'],
            13 => ['question' => '我善于倾听他人的想法而不急于评判', 'optionA' => '总是', 'optionB' => '经常', 'optionC' => '很少'],
            14 => ['question' => '我能适应环境的变化', 'optionA' => '很容易', 'optionB' => '需要时间', 'optionC' => '很难'],
            15 => ['question' => '面对批评,我首先考虑如何改进', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            16 => ['question' => '我能够识别他人未说出口的担忧', 'optionA' => '经常', 'optionB' => '偶尔', 'optionC' => '很少'],
            17 => ['question' => '在做决定前,我会考虑对他人的情感影响', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            18 => ['question' => '我能控制冲动,不因情绪做决定', 'optionA' => '总是', 'optionB' => '大部分时候', 'optionC' => '很少'],
            19 => ['question' => '当我犯错时,我愿意承认并改正', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            20 => ['question' => '我能够感知团队的整体情绪氛围', 'optionA' => '非常容易', 'optionB' => '一般', 'optionC' => '困难'],
            21 => ['question' => '在争论中,我能保持冷静并理性表达', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            22 => ['question' => '我的朋友认为我是一个好的倾听者', 'optionA' => '是的', 'optionB' => '部分朋友', 'optionC' => '不是的'],
            23 => ['question' => '当感到压力时,我有健康的方式来缓解', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            24 => ['question' => '我能够从他人的角度思考问题', 'optionA' => '总是', 'optionB' => '经常', 'optionC' => '很少'],
            25 => ['question' => '在工作中,我能有效管理自己的情绪', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            26 => ['question' => '我善于鼓励和激励他人', 'optionA' => '非常善于', 'optionB' => '一般', 'optionC' => '不太善于'],
            27 => ['question' => '我能够意识到自己的偏见如何影响判断', 'optionA' => '经常', 'optionB' => '有时', 'optionC' => '很少'],
            28 => ['question' => '面对冲突,我寻求双赢解决方案', 'optionA' => '总是', 'optionB' => '经常', 'optionC' => '很少'],
            29 => ['question' => '我能够识别自己的情绪触发点', 'optionA' => '非常清楚', 'optionB' => '部分了解', 'optionC' => '不太了解'],
            30 => ['question' => '我善于给予他人真诚的赞美', 'optionA' => '总是', 'optionB' => '经常', 'optionC' => '很少'],
            31 => ['question' => '我能够在不伤害关系的情况下表达不同意见', 'optionA' => '总是', 'optionB' => '有时', 'optionC' => '很少'],
            32 => ['question' => '面对失败,我能够从中学习并成长', 'optionA' => '总是', 'optionB' => '通常', 'optionC' => '很少'],
            33 => ['question' => '我相信建立真诚的人际关系很重要', 'optionA' => '强烈同意', 'optionB' => '同意', 'optionC' => '不太同意']
        ];
    }
}

// 计算EQ分数
function calculateEQScore($answers, $version) {
    $questions = getEQQuestions($version);
    
    // 评分映射
    $scoreMap = [
        'A' => 3, // 最高分
        'B' => 2, // 中等分
        'C' => 1  // 最低分
    ];
    
    $totalScore = 0;
    $maxPossibleScore = count($questions) * 3;
    
    foreach ($answers as $num => $answer) {
        if (isset($scoreMap[$answer])) {
            $totalScore += $scoreMap[$answer];
        }
    }
    
    // 根据总分计算EQ级别
    $percentage = ($totalScore / $maxPossibleScore) * 100;
    
    if ($percentage >= 85) {
        $level = "卓越";
        $levelDesc = "你的情商处于卓越水平";
    } elseif ($percentage >= 70) {
        $level = "优秀";
        $levelDesc = "你的情商处于优秀水平";
    } elseif ($percentage >= 60) {
        $level = "良好";
        $levelDesc = "你的情商处于良好水平";
    } elseif ($percentage >= 50) {
        $level = "一般";
        $levelDesc = "你的情商处于一般水平";
    } else {
        $level = "待提高";
        $levelDesc = "你的情商有待提高";
    }
    
    // 根据回答分析各维度
    $dimensions = analyzeDimensions($answers, $questions);
    
    return [
        'total_score' => $totalScore,
        'max_score' => $maxPossibleScore,
        'percentage' => round($percentage, 1),
        'level' => $level,
        'level_desc' => $levelDesc,
        'dimensions' => $dimensions
    ];
}

// 分析EQ各维度
function analyzeDimensions($answers, $questions) {
    $dimensions = [
        'self_awareness' => ['name' => '自我认知', 'score' => 0, 'max' => 0, 'questions' => [2, 10, 34, 37, 40]],
        'self_management' => ['name' => '自我管理', 'score' => 0, 'max' => 0, 'questions' => [1, 4, 7, 19, 25, 35, 43, 48]],
        'social_awareness' => ['name' => '社交意识', 'score' => 0, 'max' => 0, 'questions' => [3, 9, 16, 21, 26, 44, 47]],
        'relationship_management' => ['name' => '关系管理', 'score' => 0, 'max' => 0, 'questions' => [5, 6, 8, 12, 13, 17, 18, 22, 29, 32, 36, 38, 49, 50]]
    ];
    
    $scoreMap = [
        'A' => 3,
        'B' => 2,
        'C' => 1
    ];
    
    foreach ($dimensions as $key => &$dim) {
        foreach ($dim['questions'] as $qNum) {
            if (isset($answers[$qNum]) && isset($scoreMap[$answers[$qNum]])) {
                $dim['score'] += $scoreMap[$answers[$qNum]];
                $dim['max'] += 3;
            }
        }
        $dim['percentage'] = $dim['max'] > 0 ? round(($dim['score'] / $dim['max']) * 100, 1) : 0;
        
        if ($dim['percentage'] >= 80) {
            $dim['level'] = "很强";
        } elseif ($dim['percentage'] >= 65) {
            $dim['level'] = "较强";
        } elseif ($dim['percentage'] >= 50) {
            $dim['level'] = "中等";
        } else {
            $dim['level'] = "较弱";
        }
    }
    
    return $dimensions;
}

// 格式化EQ描述
function formatEQDescription($result) {
    $dimensions = $result['dimensions'];
    $percentage = $result['percentage'];
    $level = $result['level'];
    
    $html = "<p><strong>总体情商水平:</strong> {$result['level_desc']} (得分:{$result['total_score']}/{$result['max_score']}, 百分比:{$percentage}%)</p>";
    
    $html .= "<p><strong>各维度分析:</strong></p>";
    $html .= "<ul>";
    foreach ($dimensions as $dim) {
        $html .= "<li><strong>{$dim['name']}</strong>:{$dim['level']} ({$dim['percentage']}%)</li>";
    }
    $html .= "</ul>";
    
    // 根据总体水平和维度差异添加针对性建议
    $html .= "<p><strong>专业建议:</strong></p>";
    
    if ($level === "卓越") {
        $html .= "<p>您的情商处于卓越水平!您在情绪识别、管理以及人际互动方面展现出极高的能力。继续保持这份自我觉察和同理心,您将成为团队中不可或缺的情绪领导者。建议您可以尝试担任导师角色,帮助他人提升情商能力。</p>";
    } elseif ($level === "优秀") {
        $html .= "<p>您的情商处于优秀水平!您能够很好地理解和管理自己及他人的情绪。继续发挥您的优势,可以在薄弱维度上多加关注,尤其是";
        
        // 找出最弱的维度
        $weakest = array_reduce($dimensions, function($carry, $item) {
            return ($carry === null || $item['percentage'] < $carry['percentage']) ? $item : $carry;
        });
        
        $html .= "<strong>{$weakest['name']}</strong>方面,有进一步提升空间。建议通过有针对性的练习和反思,将您的情商提升至卓越水平。</p>";
    } elseif ($level === "良好") {
        $html .= "<p>您的情商处于良好水平,具有较好的情绪管理基础。建议您重点关注";
        
        // 找出较弱的维度
        $weakDims = array_filter($dimensions, function($dim) {
            return $dim['percentage'] < 60;
        });
        
        if (count($weakDims) > 0) {
            $dimNames = implode("、", array_column($weakDims, 'name'));
            $html .= "<strong>{$dimNames}</strong>这些维度,通过刻意练习和情境模拟来增强这些方面的能力。";
        } else {
            $html .= "保持现有优势,同时在各维度均衡发展。";
        }
        
        $html .= "情商是可以通过实践不断提升的能力,坚持自我反思和学习,您将看到显著进步。</p>";
    } elseif ($level === "一般") {
        $html .= "<p>您的情商处于一般水平,这表明您在情绪识别和管理方面有提升空间。情商是可以通过练习显著提高的能力。建议您:</p>";
        $html .= "<ul>";
        $html .= "<li>培养情绪日记习惯,每天记录和分析自己的情绪变化</li>";
        $html .= "<li>练习积极倾听,关注他人表达中的情感内容</li>";
        $html .= "<li>学习情绪调节技巧,如深呼吸、正念冥想等</li>";
        $html .= "<li>主动寻求反馈,了解自己在人际互动中的盲点</li>";
        $html .= "</ul>";
        $html .= "<p>通过持续努力,您可以在3-6个月内看到明显改善。</p>";
    } else { // 待提高
        $html .= "<p>您的情商测试结果显示有较大提升空间。良好的情商是个人和职业成功的重要基础,值得您投入时间和精力进行提升。</p>";
        $html .= "<p><strong>具体建议:</strong></p>";
        $html .= "<ul>";
        $html .= "<li><strong>开始自我觉察练习</strong>:每天花5分钟安静反思,识别和命名自己的情绪</li>";
        $html .= "<li><strong>学习情绪词汇</strong>:扩展情绪识别能力,不仅限于'好'或'坏'的情感描述</li>";
        $html .= "<li><strong>练习暂停技巧</strong>:在情绪激动时,学会暂停6秒(情绪神经传导所需时间)再反应</li>";
        $html .= "<li><strong>寻求专业指导</strong>:考虑情商培训课程或心理咨询,获得系统性指导</li>";
        $html .= "</ul>";
        $html .= "<p>记住,情商提升是一个渐进过程,每一次小的进步都值得肯定。您已经迈出了重要的第一步——认识并正视这个问题。</p>";
    }
    
    // 最后添加鼓励性总结
    $html .= "<p><strong>总结:</strong>情商是可以通过学习和实践不断提升的能力。无论您当前处于什么水平,保持开放心态和持续学习的态度,将帮助您在个人生活和职业发展中取得更大成功。真正的高情商不仅是理解和管理情绪,更是将这种能力转化为积极行动,创造更和谐的人际关系和更高效的工作环境。</p>";
    
    return $html;
}
?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>🧠 情商(EQ)测试</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #f7fafc;
            padding: 2rem;
            max-width: 800px;
            margin: 0 auto;
        }
        .tool-container {
            background: white;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        h1 {
            color: #4a5568;
            margin-bottom: 1.5rem;
            text-align: center;
            font-size: 1.8rem;
        }
        .version-selector {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin: 1.5rem 0 1.8rem;
            padding-bottom: 12px;
            border-bottom: 1px solid #edf2f7;
        }
        .version-btn {
            background: #e2e8f0;
            color: #4a5568;
            border: none;
            padding: 0.65rem 1.2rem;
            border-radius: 10px;
            cursor: pointer;
            font-size: 0.95rem;
            font-weight: 500;
            transition: all 0.3s;
            position: relative;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }
        .version-btn:hover {
            background: #cbd5e0;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        .version-btn.active {
            background: #667eea;
            color: white;
            font-weight: 600;
            box-shadow: 0 4px 10px rgba(102, 126, 234, 0.35);
        }
        .question-container {
            margin-bottom: 1.8rem;
            padding: 1.4rem;
            background: #f8fafc;
            border-radius: 10px;
            border: 1px solid #edf2f7;
            box-shadow: 0 2px 6px rgba(0,0,0,0.03);
        }
        .question-text {
            font-size: 1.15rem;
            margin-bottom: 1.2rem;
            line-height: 1.6;
            font-weight: 500;
            color: #2d3748;
        }
        .progress-info {
            text-align: center;
            font-size: 0.95rem;
            color: #4a5568;
            margin-bottom: 1rem;
            font-weight: 500;
        }
        .options-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 0.9rem;
            margin-top: 0.5rem;
        }
        .option-btn {
            background: white;
            border: 2px solid #cbd5e0;
            border-radius: 8px;
            padding: 1rem;
            text-align: left;
            cursor: pointer;
            transition: all 0.25s;
            font-size: 1.02rem;
            font-weight: 500;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        }
        .option-btn:hover {
            border-color: #667eea;
            background: #ebf4ff;
            transform: translateX(3px);
            box-shadow: 0 2px 6px rgba(102, 126, 234, 0.15);
        }
        .option-btn.selected {
            background: #667eea;
            color: white;
            border-color: #667eea;
            font-weight: 600;
            box-shadow: 0 3px 8px rgba(102, 126, 234, 0.3);
        }
        .controls {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin: 1.8rem 0;
        }
        button {
            background: #667eea;
            color: white;
            border: none;
            padding: 0.85rem 1.8rem;
            border-radius: 10px;
            cursor: pointer;
            font-size: 1.05rem;
            font-weight: 500;
            transition: all 0.3s;
            box-shadow: 0 3px 6px rgba(102, 126, 234, 0.3);
        }
        button:hover {
            background: #5a67d8;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
        }
        button:disabled {
            background: #a0aec0;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        #submit-btn {
            background: #38b2ac;
            box-shadow: 0 3px 6px rgba(56, 178, 172, 0.3);
        }
        #submit-btn:hover {
            background: #319795;
            box-shadow: 0 4px 8px rgba(56, 178, 172, 0.4);
        }
        #start-btn {
            background: #4299e1;
            box-shadow: 0 3px 6px rgba(66, 153, 225, 0.3);
        }
        #start-btn:hover {
            background: #3182ce;
            box-shadow: 0 4px 8px rgba(66, 153, 225, 0.4);
        }
        .result-container {
            margin-top: 1.5rem;
            padding: 1.8rem;
            border-radius: 10px;
            display: none;
            animation: fadeIn 0.4s ease;
            background: #f8fafc; /* 添加浅灰背景确保内容清晰 */
            border: 1px solid #edf2f7;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        /* 修复:移除渐变背景文字方案,改用高对比度纯色文字 */
        .eq-score {
            font-size: 3.8rem; /* 稍微增大确保醒目 */
            font-weight: 800;
            text-align: center;
            margin: 1rem 0;
            color: #2d3748; /* 默认深灰色,确保在任何背景下可见 */
            text-shadow: 0 3px 8px rgba(0, 0, 0, 0.15); /* 增强阴影提高可读性 */
            line-height: 1.2;
            letter-spacing: -0.5px;
        }
        .eq-level {
            text-align: center;
            font-size: 1.9rem;
            font-weight: 700;
            color: #4a5568;
            margin-bottom: 1.5rem;
            padding: 0.5rem 0;
        }
        .eq-description {
            line-height: 1.8;
            color: #2d3748;
            font-size: 1.05rem;
            margin-top: 1.5rem;
        }
        .eq-description p {
            margin-bottom: 1rem;
            padding-left: 1rem;
            border-left: 3px solid #667eea;
        }
        .eq-description strong {
            color: #2d3748;
        }
        .eq-description ul {
            padding-left: 2rem;
            margin: 1rem 0;
        }
        .eq-description li {
            margin-bottom: 0.5rem;
        }
        .dimensions-analysis {
            margin-top: 1.5rem;
            padding: 1.2rem;
            background: #ebf4ff;
            border-radius: 8px;
            border-left: 4px solid #667eea;
        }
        .dimension-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.5rem;
            font-weight: 500;
        }
        .reset-section {
            text-align: center;
            margin-top: 1.8rem;
            padding-top: 1.5rem;
            border-top: 1px dashed #e2e8f0;
        }
        .reset-btn {
            background: #ed8936;
            color: white;
            border: none;
            padding: 0.65rem 1.6rem;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.95rem;
            font-weight: 500;
            transition: all 0.3s;
            box-shadow: 0 2px 5px rgba(237, 137, 54, 0.3);
        }
        .reset-btn:hover {
            background: #dd6b20;
            transform: scale(1.03);
            box-shadow: 0 3px 7px rgba(237, 137, 54, 0.4);
        }
        .back-home {
            display: inline-block;
            margin-top: 1.2rem;
            color: #667eea;
            text-decoration: none;
            font-weight: 500;
            padding: 0.4rem 0.8rem;
            border-radius: 6px;
            transition: all 0.3s;
        }
        .back-home:hover {
            background: #f0f4ff;
            text-decoration: underline;
        }
        .loading {
            text-align: center;
            padding: 2rem;
            color: #718096;
            font-style: italic;
            font-size: 1.1rem;
        }
        .error {
            color: #e53e3e;
            text-align: center;
            padding: 1.5rem;
            background: #fff5f5;
            border-radius: 8px;
            margin: 1rem 0;
            font-weight: 500;
        }
        .start-container {
            text-align: center;
            padding: 2rem;
        }
        .version-desc {
            display: flex;
            justify-content: space-around;
            margin-top: 1rem;
            text-align: center;
            font-size: 0.9rem;
            color: #4a5568;
        }
        .version-desc div {
            padding: 0.5rem;
            min-width: 100px;
        }
        @media (max-width: 600px) {
            .options-container {
                grid-template-columns: 1fr;
            }
            .controls {
                flex-direction: column;
                align-items: center;
            }
            button {
                width: 100%;
                max-width: 320px;
                padding: 1rem;
            }
            .eq-score {
                font-size: 3.0rem; /* 移动端适当缩小 */
            }
            .eq-level {
                font-size: 1.6rem;
            }
        }
    </style>
</head>
<body>
    <div class="tool-container">
        <h1>🧠 情商(EQ)测试</h1>
        
        <div class="version-selector">
            <button class="version-btn active" data-version="1">标准版<br><small>50题</small></button>
            <button class="version-btn" data-version="2">简版<br><small>33题</small></button>
        </div>
        
        <div class="start-container" id="start-container">
            <p>选择测试版本后点击开始测试</p>
            <button id="start-btn">🚀 开始测试</button>
            <div class="version-desc">
                <div><strong>标准版 (50题)</strong><br>全面评估情商各维度</div>
                <div><strong>简版 (33题)</strong><br>快速了解情商水平</div>
            </div>
        </div>
        
        <div class="question-container" id="question-container" style="display:none">
            <div class="progress-info" id="progress-info">第 1 题 / 共 50 题</div>
            <div class="question-text" id="question-text">正在加载题目...</div>
            
            <div class="options-container">
                <div class="option-btn" data-value="A" id="option-a">选项A</div>
                <div class="option-btn" data-value="B" id="option-b">选项B</div>
                <div class="option-btn" data-value="C" id="option-c">选项C</div>
            </div>
        </div>
        
        <div class="controls">
            <button id="next-btn" disabled>✅ 选择答案</button>
            <button id="submit-all-btn" style="display:none">📤 提交测试</button>
        </div>
        
        <div class="result-container" id="result-container">
            <h2 style="text-align:center; margin-bottom:0.5rem">您的情商(EQ)测评结果</h2>
            <div class="eq-score" id="eq-score">120</div>
            <div class="eq-level" id="eq-level">优秀</div>
            
            <div class="eq-description" id="eq-description">
                <p><strong>总体情商水平:</strong> 优秀水平 (得分:120/150, 百分比:80%)</p>
                <p><strong>各维度分析:</strong></p>
                <ul>
                    <li><strong>自我认知</strong>:很强 (85%)</li>
                    <li><strong>自我管理</strong>:较强 (75%)</li>
                    <li><strong>社交意识</strong>:很强 (88%)</li>
                    <li><strong>关系管理</strong>:较强 (72%)</li>
                </ul>
                <p><strong>专业建议:</strong> 您的情商处于优秀水平!您在理解和管理自己及他人情绪方面表现突出,特别是在社交意识方面。建议您在关系管理维度进一步加强,例如提升冲突解决和影响力技巧。继续保持这种自我觉察和同理心,您将在个人和职业发展中获得更大成功。</p>
            </div>
        </div>
        
        <div class="reset-section">
            <button class="reset-btn" id="reset-btn">🔄 重新测试</button>
            <a href="../index.php" class="back-home">← 返回工具首页</a>
        </div>
    </div>

    <script>
        let currentVersion = '1';
        let currentNum = 1;
        let maxQuestions = 50;
        let selectedAnswer = null;
        let testStarted = false;
        
        document.addEventListener('DOMContentLoaded', function() {
            // 版本选择
            document.querySelectorAll('.version-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    if (testStarted) return;
                    
                    document.querySelectorAll('.version-btn').forEach(b => b.classList.remove('active'));
                    this.classList.add('active');
                    currentVersion = this.getAttribute('data-version');
                    
                    // 更新最大题数
                    maxQuestions = getVersionMaxQuestions(currentVersion);
                    document.getElementById('progress-info').textContent = `第 1 题 / 共 ${maxQuestions} 题`;
                });
            });
            
            // 开始测试
            document.getElementById('start-btn').addEventListener('click', startTest);
            
            // 选项选择
            document.querySelectorAll('.option-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    document.querySelectorAll('.option-btn').forEach(b => b.classList.remove('selected'));
                    this.classList.add('selected');
                    selectedAnswer = this.getAttribute('data-value');
                    document.getElementById('next-btn').disabled = false;
                });
            });
            
            // 下一题
            document.getElementById('next-btn').addEventListener('click', saveAnswer);
            
            // 提交全部
            document.getElementById('submit-all-btn').addEventListener('click', submitAllAnswers);
            
            // 重置测试
            document.getElementById('reset-btn').addEventListener('click', resetTest);
            
            // 检查是否有未完成的测试
            checkExistingTest();
        });
        
        // 检查是否有未完成的测试
        function checkExistingTest() {
            // 检查session中是否有未完成测试
        }
        
        // 开始测试
        function startTest() {
            if (!currentVersion) {
                alert('请选择测试版本');
                return;
            }
            
            fetch(`?action=start_test&version=${currentVersion}`)
                .then(response => response.json())
                .then(data => {
                    if (data.success) {
                        testStarted = true;
                        document.getElementById('start-container').style.display = 'none';
                        document.getElementById('question-container').style.display = 'block';
                        
                        currentNum = 1;
                        maxQuestions = getVersionMaxQuestions(currentVersion);
                        updateProgress();
                        loadQuestion();
                    } else {
                        alert('开始测试失败: ' + (data.error || '未知错误'));
                    }
                })
                .catch(error => {
                    console.error('开始测试失败:', error);
                    alert('开始测试失败: 网络错误');
                });
        }
        
        // 加载题目
        function loadQuestion() {
            document.getElementById('question-text').textContent = '💡 正在加载题目...';
            document.getElementById('option-a').textContent = '加载中...';
            document.getElementById('option-b').textContent = '加载中...';
            document.getElementById('option-c').textContent = '加载中...';
            document.getElementById('next-btn').disabled = true;
            document.querySelectorAll('.option-btn').forEach(btn => btn.classList.remove('selected'));
            
            fetch(`?action=get_question`)
                .then(response => response.json())
                .then(data => {
                    if (data.error) {
                        document.getElementById('question-text').innerHTML = `<div class="error">❌ ${data.error}</div>`;
                        return;
                    }
                    
                    document.getElementById('question-text').textContent = data.question;
                    document.getElementById('option-a').textContent = data.optionA;
                    document.getElementById('option-b').textContent = data.optionB;
                    document.getElementById('option-c').textContent = data.optionC;
                    updateProgress();
                })
                .catch(error => {
                    document.getElementById('question-text').innerHTML = 
                        `<div class="error">❌ 加载题目失败: ${error.message || '网络错误'}</div>`;
                });
        }
        
        // 更新进度显示
        function updateProgress() {
            document.getElementById('progress-info').textContent = `第 ${currentNum} 题 / 共 ${maxQuestions} 题`;
            
            // 更新按钮状态
            document.getElementById('submit-all-btn').style.display = (currentNum >= maxQuestions) ? 'inline-block' : 'none';
            document.getElementById('next-btn').style.display = (currentNum < maxQuestions) ? 'inline-block' : 'none';
            document.getElementById('next-btn').textContent = (currentNum < maxQuestions) ? '✅ 选择答案' : '✅ 选择答案';
        }
        
        // 保存答案
        function saveAnswer() {
            if (!selectedAnswer) {
                alert('请选择一个答案');
                return;
            }
            
            fetch('', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                },
                body: `action=save_answer&answer=${selectedAnswer}`
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    if (data.is_last_question) {
                        // 最后一题,显示提交按钮
                        document.getElementById('submit-all-btn').style.display = 'inline-block';
                        document.getElementById('next-btn').style.display = 'none';
                    } else {
                        // 加载下一题
                        currentNum = data.next_num;
                        selectedAnswer = null;
                        document.getElementById('next-btn').disabled = true;
                        document.querySelectorAll('.option-btn').forEach(btn => btn.classList.remove('selected'));
                        loadQuestion();
                    }
                } else {
                    alert('保存答案失败: ' + (data.error || '未知错误'));
                }
            })
            .catch(error => {
                console.error('保存答案失败:', error);
                alert('保存答案失败: 网络错误');
            });
        }
        
        // 提交所有答案
        function submitAllAnswers() {
            if (!selectedAnswer) {
                alert('请选择最后一题的答案');
                return;
            }
            
            // 先保存最后一题的答案
            fetch('', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                },
                body: `action=save_answer&answer=${selectedAnswer}`
            })
            .then(response => response.json())
            .then(saveData => {
                if (!saveData.success) {
                    throw new Error(saveData.error || '保存最后一题失败');
                }
                
                // 然后提交全部测试
                return fetch('', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                    },
                    body: `action=submit_test`
                });
            })
            .then(response => response.json())
            .then(result => {
                if (result.success) {
                    showResult(result.score, result.level, result.description);
                } else {
                    throw new Error(result.error || '提交测试失败');
                }
            })
            .catch(error => {
                console.error('提交测试失败:', error);
                alert('提交测试失败: ' + error.message);
            });
        }
        
        // 显示结果 - 修复:使用纯色文字替代渐变背景文字
        function showResult(score, level, description) {
            // 计算显示分数(基于百分比转换为常见EQ分数范围80-160)
            const percentage = (score / (maxQuestions * 3)) * 100;
            const displayedScore = Math.round(80 + (percentage / 100) * 80);
            
            const scoreElement = document.getElementById('eq-score');
            const levelElement = document.getElementById('eq-level');
            
            // 设置分数文字(纯色,高对比度)
            scoreElement.textContent = displayedScore;
            levelElement.textContent = level;
            document.getElementById('eq-description').innerHTML = description;
            
            // 隐藏题目区域,显示结果区域
            document.getElementById('question-container').style.display = 'none';
            document.getElementById('result-container').style.display = 'block';
            
            // 根据等级设置文字颜色(确保与背景高对比度)
            if (level === "卓越") {
                scoreElement.style.color = "#6b46c1"; // 深紫色
                levelElement.style.color = "#6b46c1";
                scoreElement.style.textShadow = "0 4px 10px rgba(107, 70, 193, 0.25)";
            } else if (level === "优秀") {
                scoreElement.style.color = "#2c5282"; // 深蓝色
                levelElement.style.color = "#2c5282";
                scoreElement.style.textShadow = "0 4px 10px rgba(44, 82, 130, 0.25)";
            } else if (level === "良好") {
                scoreElement.style.color = "#285e61"; // 深青色
                levelElement.style.color = "#285e61";
                scoreElement.style.textShadow = "0 4px 10px rgba(40, 94, 97, 0.25)";
            } else if (level === "一般") {
                scoreElement.style.color = "#8c5221"; // 深棕色
                levelElement.style.color = "#8c5221";
                scoreElement.style.textShadow = "0 4px 10px rgba(140, 82, 33, 0.25)";
            } else { // 待提高
                scoreElement.style.color = "#9c4221"; // 深橙色
                levelElement.style.color = "#9c4221";
                scoreElement.style.textShadow = "0 4px 10px rgba(156, 66, 33, 0.25)";
            }
        }
        
        // 重置测试
        function resetTest() {
            fetch('?action=reset_test')
                .then(response => response.json())
                .then(data => {
                    if (data.success) {
                        // 重置UI状态
                        testStarted = false;
                        currentNum = 1;
                        selectedAnswer = null;
                        
                        // 显示开始界面
                        document.getElementById('start-container').style.display = 'block';
                        document.getElementById('question-container').style.display = 'none';
                        document.getElementById('result-container').style.display = 'none';
                        
                        // 重置版本选择
                        document.querySelectorAll('.version-btn').forEach(btn => btn.classList.remove('active'));
                        document.querySelector(`.version-btn[data-version="${currentVersion}"]`).classList.add('active');
                        
                        // 重置进度
                        maxQuestions = getVersionMaxQuestions(currentVersion);
                        document.getElementById('progress-info').textContent = `第 1 题 / 共 ${maxQuestions} 题`;
                        
                        alert('测试已重置,您可以重新开始');
                    } else {
                        alert('重置失败: ' + (data.error || '未知错误'));
                    }
                })
                .catch(error => {
                    console.error('重置测试失败:', error);
                    alert('重置测试失败: 网络错误');
                });
        }
        
        // 获取版本对应的最大题数
        function getVersionMaxQuestions(version) {
            const versions = {
                '1': 50,
                '2': 33
            };
            return versions[version] || 50;
        }
    </script>
</body>
</html>
© 版权声明
THE END
喜欢就支持一下吧
点赞 0 分享 收藏

评论 (0)

取消