<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

session_start();

/* 🔒 Direct access prevent */
if (!isset($_POST['student_name'])) {
    die("⚠️ Start assessment properly");
}

/* ✅ Store student data */
$_SESSION['student_name'] = $_POST['student_name'];
$_SESSION['roll_no'] = $_POST['roll_no'];

/* 🔥 QUESTIONS */
$questions = [

["q"=>"When learning something new, you prefer:",
 "options"=>[
   ["Seeing diagrams or flowcharts","V"],
   ["Listening to explanations","A"],
   ["Trying it hands-on","K"]
 ]],

["q"=>"In class, you understand better when:",
 "options"=>[
   ["Teacher uses diagrams","V"],
   ["Teacher explains verbally","A"],
   ["You solve problems yourself","K"]
 ]],

["q"=>"While studying, you mostly:",
 "options"=>[
   ["Highlight and visualize notes","V"],
   ["Read aloud or discuss","A"],
   ["Practice problems","K"]
 ]],

["q"=>"You remember concepts better when:",
 "options"=>[
   ["You see it written","V"],
   ["You hear it explained","A"],
   ["You apply it practically","K"]
 ]],

["q"=>"During revision, you prefer:",
 "options"=>[
   ["Charts & mind maps","V"],
   ["Listening to recordings","A"],
   ["Solving sample questions","K"]
 ]],

["q"=>"In group study, you:",
 "options"=>[
   ["Draw diagrams","V"],
   ["Explain to others","A"],
   ["Demonstrate solutions","K"]
 ]],

["q"=>"When confused, you:",
 "options"=>[
   ["Look for visual examples","V"],
   ["Ask someone to explain","A"],
   ["Try it yourself","K"]
 ]],

["q"=>"Your favourite learning tool:",
 "options"=>[
   ["Whiteboard / slides","V"],
   ["Lectures / podcasts","A"],
   ["Labs / workshops","K"]
 ]],

["q"=>"You enjoy classes when:",
 "options"=>[
   ["Teacher uses visuals","V"],
   ["Teacher tells stories","A"],
   ["Class is interactive","K"]
 ]],

["q"=>"Before exams, you:",
 "options"=>[
   ["Revise diagrams","V"],
   ["Explain topics aloud","A"],
   ["Practice repeatedly","K"]
 ]],

["q"=>"You learn coding best by:",
 "options"=>[
   ["Flowcharts & logic","V"],
   ["Listening to explanations","A"],
   ["Writing and running code","K"]
 ]],

["q"=>"Math concepts are easier when:",
 "options"=>[
   ["Steps are visual","V"],
   ["Teacher explains clearly","A"],
   ["You solve many problems","K"]
 ]],

["q"=>"You prefer teachers who:",
 "options"=>[
   ["Use visual aids","V"],
   ["Explain verbally","A"],
   ["Give practice tasks","K"]
 ]],

["q"=>"You grasp ideas faster when:",
 "options"=>[
   ["You see examples","V"],
   ["You hear explanations","A"],
   ["You experiment","K"]
 ]],

["q"=>"You revise better by:",
 "options"=>[
   ["Making notes","V"],
   ["Discussing","A"],
   ["Practicing","K"]
 ]],

["q"=>"You understand science best when:",
 "options"=>[
   ["You see diagrams","V"],
   ["Teacher explains","A"],
   ["You do experiments","K"]
 ]],

["q"=>"You remember lessons longer when:",
 "options"=>[
   ["You visualize","V"],
   ["You listen","A"],
   ["You apply","K"]
 ]],

["q"=>"Learning becomes effective when:",
 "options"=>[
   ["Concepts are visual","V"],
   ["Concepts are discussed","A"],
   ["Concepts are practiced","K"]
 ]],

["q"=>"Your study strength is:",
 "options"=>[
   ["Observation","V"],
   ["Listening","A"],
   ["Doing","K"]
 ]],

["q"=>"You feel confident when:",
 "options"=>[
   ["You understand visually","V"],
   ["You can explain verbally","A"],
   ["You can solve independently","K"]
 ]]
];
?>

<!DOCTYPE html>
<html>
<head>
<title>Learning Style Quiz</title>
<style>
body{
    background:#020617;
    color:white;
    font-family:Arial;
    padding:40px;
}
.card{
    max-width:700px;
    margin:auto;
}
.q{
    margin-bottom:25px;
}
button{
    padding:12px 25px;
    border:none;
    border-radius:10px;
    background:#22c55e;
    font-weight:bold;
    cursor:pointer;
}
</style>
</head>

<body>

<div class="card">

<h2>🧠 Learning Style Assessment</h2>

<form method="POST" action="learning_style.php">

<?php foreach($questions as $i => $q): ?>
    <div class="q">
        <p><b>Q<?= $i+1 ?>. <?= $q['q'] ?></b></p>

        <?php foreach($q['options'] as $opt): ?>
            <input type="radio" name="q<?= $i ?>" value="<?= $opt[1] ?>" required>
            <?= $opt[0] ?><br>
        <?php endforeach; ?>
    </div>
<?php endforeach; ?>

<button type="submit">🚀 Submit Assessment</button>

</form>

</div>

</body>
</html>