<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>Universal Mock Test Engine</title>
<style>
body{margin:0;font-family:Arial;background:#f9fafb;color:#111;}
.wrap{max-width:950px;margin:20px auto;padding:16px;}
header{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap;}
.badge{background:#fff;border:1px solid #ddd;padding:10px 14px;
border-radius:12px;font-weight:600;}
.card{background:#fff;border:1px solid #ddd;border-radius:14px;
padding:20px;margin-top:15px;box-shadow:0 2px 6px rgba(0,0,0,.08);}
.qtext{font-size:22px;line-height:1.5;}
.opts{display:grid;gap:12px;margin-top:18px;}
.opt{padding:12px;border:1px solid #ccc;border-radius:10px;
cursor:pointer;background:#fdfdfd;}
.opt:hover{background:#eff6ff;border-color:#2563eb;}
.nav{display:flex;gap:10px;flex-wrap:wrap;margin-top:18px;}
button{padding:10px 16px;border-radius:10px;border:1px solid #ccc;
cursor:pointer;background:#f3f4f6;font-weight:600;}
button.primary{background:#2563eb;color:#fff;border:none;}
button.primary:hover{background:#1d4ed8;}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(42px,1fr));
gap:8px;margin-top:14px;}
.pill{padding:10px;border-radius:10px;border:1px solid #ccc;
text-align:center;cursor:pointer;background:#fff;}
.pill.active{outline:2px solid #2563eb;}
.pill.done{background:#dbeafe;}
</style>
</head>
<body>
<div class="wrap">
<header>
<div class="badge" id="testInfo">Mock Test</div>
<div class="badge">Time Left: <span id="timer">12:13</span></div>
<div class="badge">Q: <span id="qidx">1</span>/<span id="qcount">0</span></div>
</header>
<div class="card">
<div class="qtext" id="qtext">Loading…</div>
<div id="options" class="opts"></div>
<div class="nav">
<button id="prevBtn">← Prev</button>
<button id="nextBtn">Next →</button>
<button id="clearBtn">Clear</button>
<button id="submitBtn" class="primary">Submit</button>
</div>
<div id="palette" class="grid"></div>
</div>
<div id="result" class="card" style="display:none;"></div>
</div>
<script>
/* ================= USER SETTINGS (बस यही बदलेगा) ================= */
// Marks
const POSITIVE_MARK = 4;
const NEGATIVE_MARK = 1;
// Timer in minutes
const TOTAL_MINUTES = 180;
// Title shown on top
const TEST_TITLE = "NEET UG Test - 1";
/* ================= ONLY PASTE QUESTIONS HERE ================= */
const QUESTIONS = [
{q:"What is the sum of 2 and 3?", options:["5","7","8","9"], answer:0},
{q:"What is the difference of 2 and 3?", options:["0","1","2","3"], answer:1},
];
/* ================= QUIZ ENGINE (No Need Touch) ================= */
let idx=0;
let choices = Array(QUESTIONS.length).fill(null);
const $ = s=>document.querySelector(s);
$("#testInfo").textContent =
`${TEST_TITLE} • +${POSITIVE_MARK}/-${NEGATIVE_MARK} • ${QUESTIONS.length} Q`;
$("#qcount").textContent = QUESTIONS.length;
function formatTime(sec){
let m=Math.floor(sec/60), s=sec%60;
return `${String(m).padStart(2,"0")}:${String(s).padStart(2,"0")}`;
}
function renderQuestion(){
const q=QUESTIONS[idx];
$("#qtext").textContent = `${idx+1}. ${q.q}`;
$("#qidx").textContent = idx+1;
$("#options").innerHTML="";
q.options.forEach((opt,j)=>{
const div=document.createElement("div");
div.className="opt";
div.innerHTML=`<input type="radio" name="q"
${choices[idx]===j?"checked":""}> ${opt}`;
div.onclick=()=>{
choices[idx]=j;
updatePalette();
renderQuestion();
};
$("#options").appendChild(div);
});
$("#prevBtn").disabled = idx===0;
$("#nextBtn").disabled = idx===QUESTIONS.length-1;
}
function updatePalette(){
$("#palette").innerHTML="";
QUESTIONS.forEach((_,i)=>{
const b=document.createElement("div");
b.className="pill"+(i===idx?" active":"")+(choices[i]!=null?" done":"");
b.textContent=i+1;
b.onclick=()=>{idx=i;renderQuestion();updatePalette();};
$("#palette").appendChild(b);
});
}
function computeScore(){
let correct=0, wrong=0, skipped=0;
choices.forEach((ch,i)=>{
if(ch==null) skipped++;
else if(ch===QUESTIONS[i].answer) correct++;
else wrong++;
});
let score = (correct*POSITIVE_MARK)-(wrong*NEGATIVE_MARK);
return {correct,wrong,skipped,score};
}
function submitQuiz(reason){
clearInterval(timerId);
const {correct,wrong,skipped,score}=computeScore();
$("#result").style.display="block";
$("#result").innerHTML=`
<h2>Result (${reason})</h2>
<p><b>Total:</b> ${QUESTIONS.length}</p>
<p>✅ Correct: ${correct}</p>
<p>❌ Wrong: ${wrong}</p>
<p>⏭ Skipped: ${skipped}</p>
<h3>Final Score: ${score}</h3>
<hr>
<h3>📌 Answer Review</h3>
<ol style="line-height:1.7;">
${QUESTIONS.map((q,i)=>{
let userChoice = choices[i];
let correctAns = q.answer;
return `
<li style="margin-bottom:15px;">
<b>Q${i+1}. ${q.q}</b><br>
<span style="color:${userChoice===correctAns?'green':'red'};">
Your Answer: ${
userChoice===null ? "Not Attempted ❌" : q.options[userChoice]
}
</span><br>
<span style="color:green;">
Correct Answer: ${q.options[correctAns]}
</span>
</li>
`;
}).join("")}
</ol>
`;
$("#result").scrollIntoView({behavior:"smooth"});
}
/* Buttons */
$("#prevBtn").onclick=()=>{if(idx>0){idx--;renderQuestion();updatePalette();}};
$("#nextBtn").onclick=()=>{if(idx<QUESTIONS.length-1){idx++;renderQuestion();updatePalette();}};
$("#clearBtn").onclick=()=>{choices[idx]=null;renderQuestion();updatePalette();};
$("#submitBtn").onclick=()=>submitQuiz("Submitted");
/* Timer Auto Submit */
let secondsLeft = TOTAL_MINUTES*60;
$("#timer").textContent = formatTime(secondsLeft);
const timerId=setInterval(()=>{
secondsLeft--;
$("#timer").textContent = formatTime(secondsLeft);
if(secondsLeft<=0) submitQuiz("Time Up ⏰ Auto Submitted");
},1000);
/* Init */
renderQuestion();
updatePalette();
</script>
</body>
</html>