CTET 2026 ONLINE MOCK TEST 01
C
Candidate Name
✅ Verified
`;
const nameInput = document.getElementById("mq-name");
const agreeChk = document.getElementById("mq-agree");
const startBtn = document.getElementById("mq-start");
const backBtn = document.getElementById("mq-back");
const userName = document.getElementById("mq-user-name");
const userCircle = document.getElementById("mq-user-circle");
function updateUI(){
const nameVal = nameInput.value.trim();
const ok = !!nameVal && agreeChk.checked;
startBtn.disabled = !ok;
const n = nameVal || "Candidate Name";
userName.textContent = n;
userCircle.textContent = n.charAt(0).toUpperCase();
}
nameInput.addEventListener("input", updateUI);
agreeChk.addEventListener("change", updateUI);
backBtn.addEventListener("click", ()=>{ window.history.back(); });
startBtn.addEventListener("click", ()=>{
const nameVal = nameInput.value.trim();
studentName = nameVal || "Candidate";
startQuiz();
});
}
/* ========== QUIZ SCREEN ========== */
function startQuiz(){
const total = quizData.length;
container.innerHTML = `
Kohlberg Moral Development | 1 Mark / Question | No Negative Marking
Question Palette
Not Visited / Unanswered
Answered
Current Question
After submitting test, you won't be able to re-attempt this attempt.
`;
const answers = Array(total).fill(null);
let current = 0;
let totalTime = 20 * 60; // 20 minutes
let timerId = null;
let submitted = false;
const qCountEl = document.getElementById("mq-q-count");
const qEl = document.getElementById("mq-question");
const optEl = document.getElementById("mq-options");
const prevBtn = document.getElementById("mq-prev");
const clearBtn = document.getElementById("mq-clear");
const nextBtn = document.getElementById("mq-next");
const timerEl = document.getElementById("mq-timer").querySelector("span:last-child");
const paletteEl = document.getElementById("mq-palette");
const submitMainBtn = document.getElementById("mq-submit-main");
const overlay = document.getElementById("mq-overlay");
const cfTime = document.getElementById("mq-cf-time");
const cfAttempted = document.getElementById("mq-cf-attempted");
const cfUnattempted = document.getElementById("mq-cf-unattempted");
const cfCancel = document.getElementById("mq-cf-cancel");
const cfSubmit = document.getElementById("mq-cf-submit");
function formatTime(sec){
const m = Math.floor(sec/60);
const s = sec%60;
return (m<10?"0"+m:m)+":"+(s<10?"0"+s:s);
}
function startTimer(){
timerEl.textContent = formatTime(totalTime) + " MIN";
timerId = setInterval(()=>{
if(totalTime<=0){
clearInterval(timerId);
timerEl.textContent = "00:00 MIN";
if(!submitted){ showResult(true); }
return;
}
totalTime--;
timerEl.textContent = formatTime(totalTime) + " MIN";
},1000);
}
function renderPalette(){
paletteEl.innerHTML = "";
for(let i=0;i
{
if(submitted) return;
saveAnswer();
current = parseInt(btn.dataset.index,10);
loadQuestion(current);
});
paletteEl.appendChild(btn);
}
}
function updatePaletteStates(){
const items = paletteEl.querySelectorAll(".mock-palette-item");
items.forEach((it,idx)=>{
it.classList.remove("state-current","state-answered");
if(idx===current) it.classList.add("state-current");
if(answers[idx]) it.classList.add("state-answered");
});
}
function loadQuestion(index){
const item = quizData[index];
qCountEl.textContent = `Question ${index+1}/${total}`;
qEl.textContent = item.q;
optEl.innerHTML = "";
["A","B","C","D"].forEach(letter=>{
const text = item[letter.toLowerCase()];
const label = document.createElement("label");
label.className="mock-option";
const radio = document.createElement("input");
radio.type="radio";
radio.name="mq-option";
radio.value=letter;
if(answers[index]===letter) radio.checked=true;
const txt = document.createElement("div");
txt.className="mock-option-text";
txt.innerHTML = `${letter}${text}`;
label.appendChild(radio);
label.appendChild(txt);
optEl.appendChild(label);
});
prevBtn.disabled = (index===0);
updatePaletteStates();
}
function saveAnswer(){
const checked = container.querySelector('input[name="mq-option"]:checked');
if(checked){
answers[current] = checked.value;
}
updatePaletteStates();
}
function clearCurrentAnswer(){
const radios = container.querySelectorAll('input[name="mq-option"]');
radios.forEach(r=>r.checked=false);
answers[current] = null;
updatePaletteStates();
}
function disableQuizControls(){
prevBtn.disabled = true;
nextBtn.disabled = true;
clearBtn.disabled = true;
submitMainBtn.disabled = true;
const inputs = container.querySelectorAll('input[name="mq-option"]');
inputs.forEach(i=>i.disabled=true);
const items = container.querySelectorAll(".mock-palette-item");
items.forEach(i=>i.style.pointerEvents="none");
}
function letterToText(q, letter){
if(!letter) return "";
return q[letter.toLowerCase()] || "";
}
/* ===== Confirm Popup ===== */
function openConfirm(){
const attempted = answers.filter(v=>v!==null).length;
const unattempted = total-attempted;
cfTime.textContent = formatTime(totalTime);
cfAttempted.textContent = attempted;
cfUnattempted.textContent = unattempted;
overlay.style.display="flex";
}
function closeConfirm(){
overlay.style.display="none";
}
cfCancel.addEventListener("click", closeConfirm);
cfSubmit.addEventListener("click", ()=>{
closeConfirm();
showResult(false);
});
/* ===== RESULT ===== */
function showResult(auto=false){
submitted = true;
disableQuizControls();
if(timerId) clearInterval(timerId);
let score=0, correct=0, wrong=0;
quizData.forEach((q,i)=>{
if(answers[i]===q.correct){score++;correct++;}
else if(answers[i]!==null){wrong++;}
});
const attempted = correct+wrong;
const unattempted = quizData.length - attempted;
const percent = Math.round((score/quizData.length)*100);
const wrapper = document.querySelector(".mock-wrapper");
wrapper.innerHTML = `
प्रिय ${studentName || "विद्यार्थी"}, आपका टेस्ट सफलतापूर्वक सबमिट हो चुका है।
नीचे आपका रिज़ल्ट है। ${
auto ? "⏱ समय समाप्त होने पर टेस्ट स्वतः सबमिट हुआ।" : ""
}
Correct Answers
${correct}
Unattempted
${unattempted}
Final Score
${score}/${quizData.length}
Accuracy: ${percent}%
`;
const solBox = document.getElementById("mq-solutions");
const solBtn = document.getElementById("mq-res-sol");
const restartBtn= document.getElementById("mq-res-restart");
const nextBtn = document.getElementById("mq-res-next");
solBtn.addEventListener("click", ()=>{
if(solBox.style.display==="none"){
solBox.style.display="block";
solBtn.textContent="Hide Solutions";
renderSolutions(solBox, answers);
}else{
solBox.style.display="none";
solBtn.textContent="Solutions";
}
});
restartBtn.addEventListener("click", ()=>{
renderInstruction();
window.scrollTo({top:container.offsetTop-10,behavior:"smooth"});
});
nextBtn.addEventListener("click", ()=>{
alert("Next Mock Test link यहाँ लगाइए (window.location.href='YOUR_URL')");
});
}
function renderSolutions(solBox, answers){
solBox.innerHTML = "";
quizData.forEach((q,i)=>{
const userLetter = answers[i];
const userText = userLetter ? letterToText(q,userLetter) : "Attempt नहीं किया";
const correctLetter = q.correct;
const correctText = letterToText(q,correctLetter);
const isCorrect = userLetter === correctLetter;
const div = document.createElement("div");
div.className="mock-sol-item";
div.innerHTML = `
${q.q}
आपका उत्तर:
${userText}
सही उत्तर: ${correctText}
`;
solBox.appendChild(div);
});
}
// events
prevBtn.addEventListener("click", ()=>{
if(submitted) return;
saveAnswer();
if(current>0){
current--;
loadQuestion(current);
}
});
clearBtn.addEventListener("click", ()=>{
if(submitted) return;
clearCurrentAnswer();
});
nextBtn.addEventListener("click", ()=>{
if(submitted) return;
saveAnswer();
if(current < total-1){
current++;
loadQuestion(current);
}else{
alert("यह आख़िरी प्रश्न है। Test सबमिट करने के लिए नीचे लाल 'Submit Test' बटन पर क्लिक करें।");
}
});
submitMainBtn.addEventListener("click", ()=>{
if(submitted) return;
saveAnswer();
openConfirm();
});
renderPalette();
loadQuestion(current);
updatePaletteStates();
startTimer();
}
// init
renderInstruction();
})();
Nice Mock Test
Bahut acha hai sir, free me dene ke liye dhanywad
सर CTET PAPER 2 का भी दीजिये, अच्छा मॉक है